Ejemplo n.º 1
0
void FunRef::doSemanticCheck()
{
    ASSERT(children_.size() == 1);
    Node* resType = children_[0];
    resType->computeType();

    funDecl()->computeType();
    type_ = adjustMode(resType->type(), context_, location_);
}
Ejemplo n.º 2
0
void CGModule_C::emitFrame( CGFrame *f ){
	CGFrame_C *frame=dynamic_cast<CGFrame_C*>(f);
	assert( frame );

	int k,n_use[7]={0};

	for( k=0;k<frame->regs.size();++k ){
		CGReg *r=frame->regs[k];
		if( r->isint() && r->id>=14 && r->color>=0 && r->color<7 ) ++n_use[r->color];
	}
	
	if( frame->extern_jsrs ){
		n_use[3]=n_use[4]=n_use[5]=-1;
	}

	int local_sz=frame->local_sz;
	CGFun * fun = frame->fun;

	//create frame
	funDecl(fun);
	out << " {\n";
	
	out << "  ANY eax, edx, ecx, ebx, esi, edi;\n";
	if (local_sz > 0) {
		out << "  ANY";
		for (int i = 0; i < local_sz; i ++) {
			out << " v" << i;
			if (i < local_sz - 1) { out << ","; }
		}
		out << ";\n";
	}
	if (fun->type == CG_FLOAT64 || fun->type == CG_FLOAT32 || fun->type == CG_INT64) {
		out << typeName(fun->type) << " retv;\n";
	}
	
	CGAsm *as, *pv;
	for( as=frame->assem.begin;as!=frame->assem.end;as=as->succ ){
		const char *p=as->assem;
		if( !p ) continue;
		out<<p;
		pv = as;
	}
	if (!(pv->stm && pv->stm->ret())) {
		out << "  return ((" << typeName(frame->fun->type) << ")0);\n";
	}
	out << "}\n";
}
Ejemplo n.º 3
0
void CGModule_C::emitFunDeclaration(CGFun * f) {
	funDecl(f);
	out << ";\n";
}
Ejemplo n.º 4
0
void FunRef::dump(ostream& os) const
{
    os << "FunRef(" << funDecl() << ")";
}