Exemplo n.º 1
0
// Working correctly
void ir_class_decln_list(nodeType* n)
{
	nodeType* class_decln_list = get_operand(n,0);
	nodeType* class_decln = get_operand(n,1);
	generate(class_decln_list);
	generate(class_decln);
}
Exemplo n.º 2
0
void ir_for(nodeType* n)
{
	nodeType* initialize = get_operand(n,0);
	nodeType* expr = get_operand(n,1);
	nodeType* increament = get_operand(n,2);
	nodeType* stmt = get_operand(n,3);
	char initializenext[16], begin[16];
	memset(initializenext,0,16);
	memset(begin,0,16);
	strcat(initializenext,newlabel());
	strcat(begin,newlabel());
	set_T(expr,begin);
	set_F(expr,n->opr.next);
	generate(initialize);				//generate code for initialization expression
	
	//##for break statement##
	char initial_break_label[16];
	memset(initial_break_label,0,16);
	strcpy(initial_break_label,break_label);
	memset(break_label,0,16);
	strcpy(break_label,newlabel());
	//#####for continue statement############
	char initial_continue_label[16];
	memset(initial_continue_label,0,16);
	strcpy(initial_continue_label,continue_label);
	memset(continue_label,0,16);
	strcpy(continue_label,newlabel());
	//#######################################
	loop_flag = loop_flag + 1;

	debugger("br %s\n",initializenext);
	fprintf(output,"br %s\n",initializenext);
	debugger("%s: \n",begin);
	fprintf(output,"%s: ",begin);
	
	generate(stmt);
	
	prepost_put = 0;
	debugger("%s:\n",continue_label);
	fprintf(output,"%s:\n",continue_label);
	
	generate(increament);
	
	debugger("%s: ",initializenext);
	fprintf(output,"%s: ",initializenext);
	seen_bool_flow = 1;
	
	generate(expr);
	
	seen_bool_flow = 0;
	debugger("%s: \n",break_label);
	fprintf(output,"%s: \n",break_label);

	//for break statement
	loop_flag = loop_flag - 1;
	memset(break_label,0,16);
	strcpy(break_label,initial_break_label);
	memset(continue_label,0,16);
	strcpy(continue_label,initial_continue_label);
}
Exemplo n.º 3
0
// recursive function to print .fields public etc for all fields of a class
void ir_fieldlist(nodeType* n)
{
	if(n->opr.oper==EMPTY)		// base case 1
		return;
	nodeType* lc=get_operand(n,0);		
	nodeType* rc=get_operand(n,1);
	nodeType* s;
	if(n->opr.oper==FIELD_ARG)		// base case when list degenerates to single arg
	{
		s=get_operand(n,0);
		debugger(" .field public ");				// all fields are public !!!
		fprintf(output," .field public ");
		print_type(get_operand(n,1));
		debugger(" %s ",s->id.symrec->sym_name); 	// get the uid and print it
		fprintf(output," %s ",s->id.symrec->sym_name); 	// get the uid and print it
		return;
	}
	else 						// else recurse on the formal arg list of lc 
	{
		ir_fieldlist(lc);
		debugger("\n");
		fprintf(output,"\n");
	}	
	ir_fieldlist(rc);		// finally print the right child (actually just a formal arg)
	return;
}
Exemplo n.º 4
0
void ir_array_rhs(nodeType* n)
{
	nodeType* array_name = get_operand(n,0);
	nodeType* array_index = get_operand(n,1);
	debugger("ldloc %s\n",array_name->id.symrec->uid ); 
	fprintf(output,"ldloc %s\n",array_name->id.symrec->uid ); 
	generate(array_index);
	//~ debugger("ldelem.i4\n");
	//~ fprintf(output,"ldelem.i4\n");
	switch(n->opr.datatype)
	{
		case MY_INT:
			debugger("ldelem.i4\n");
			fprintf(output,"ldelem.i4\n");
			break;
		case MY_FLOAT:
			debugger("ldelem.r4\n");
			fprintf(output,"ldelem.r4\n");
			break;
		case MY_BOOL:
			debugger("ldelem.u1\n");
			fprintf(output,"ldelem.u1\n");
			break;
		default:
			debugger("IN DEFAULT OF Array LHS\n");
	}
}
Exemplo n.º 5
0
void ir_ternary(nodeType* n)
{
	nodeType* expr = get_operand(n,0);
	nodeType* stmt1 = get_operand(n,1);
	nodeType* stmt2 = get_operand(n,2);
	set_T(expr,newlabel());
	set_F(expr,newlabel());
	memset(stmt1->opr.next,0,16);
	memset(stmt2->opr.next,0,16);
	memset(n->opr.next,0,16);
	strcpy(stmt1->opr.next,n->opr.next);
	strcpy(stmt2->opr.next,n->opr.next);
	strcpy(n->opr.next,newlabel());
	
	seen_bool_flow = 1;
	generate(expr);
	seen_bool_flow = 0;
	
	debugger("%s:\n",get_T(expr));
	fprintf(output,"%s:\n",get_T(expr));
	prepost_put = 1;
	generate(stmt1);
	prepost_put = 0;
	debugger("br.s %s\n ",n->opr.next);
	fprintf(output,"br.s %s\n",n->opr.next);
	debugger("%s:\n",get_F(expr));
	fprintf(output,"%s:\n",get_F(expr));
	prepost_put = 1;
	generate(stmt2);
	prepost_put = 0;
	debugger("%s:\n",n->opr.next);
	fprintf(output,"%s:\n",n->opr.next);
}	
Exemplo n.º 6
0
// Working correctly
void ir_fun_def_list(nodeType* n)
{
	nodeType* fun_def_list = get_operand(n,0);
	nodeType* fun_def = get_operand(n,1);
	generate(fun_def_list);
	generate(fun_def);
}
Exemplo n.º 7
0
void ir_if(nodeType* n)
{
	nodeType* expr = get_operand(n,0);
	nodeType* stmt = get_operand(n,1);
	set_T(expr,newlabel());
	set_F(expr,n->opr.next);
	
	memset(stmt->opr.next,0,16);
	strcat(stmt->opr.next,n->opr.next);
	
	debugger("expr true label:%s\n",get_T(expr));
	debugger("expr false label:%s\n",get_F(expr));
	
	seen_bool_flow = 1;prepost_put = 1;
	
	generate(expr);
	
	seen_bool_flow = 0;prepost_put = 0;
	
	debugger("%s:\n",get_T(expr));
	fprintf(output,"%s:\n",get_T(expr));
	
	generate(stmt);
	
	return;
}	
Exemplo n.º 8
0
void ir_explist(nodeType* n)
{
	nodeType* exp=get_operand(n,0);
	nodeType* assexp=get_operand(n,1);
	generate(exp);
	generate(assexp);
}
Exemplo n.º 9
0
void create_formal_args(nodeType* n)
{
	if(n->opr.oper==EMPTY)
		return;
	nodeType* lc=get_operand(n,0);
	nodeType* rc=get_operand(n,1);
	nodeType* s;
	if(n->opr.oper==FORMAL_ARG)
	{
		s=get_operand(n,1);
		switch(s->con_i.value)
		{
				case MY_INT: 
							strcat(mybuf," int32 ");
							break;
				case MY_FLOAT: 
							strcat(mybuf," float32 "); 
							break;
				case MY_BOOL:
							strcat(mybuf," bool ");
							break;
				default:	
							strcat(mybuf," unhandled type ");
							break;					
		}
		return;
	}
	else
	{
		create_formal_args(lc);
		strcat(mybuf,",");
	}	
	create_formal_args(rc);
	return;
}
Exemplo n.º 10
0
void ir_bool_flow(nodeType* n)
{
	nodeType* B1 = get_operand(n,0);
	nodeType* B2 = get_operand(n,1);
	debugger("n true label:%s\n",get_T(n));
	debugger("n false label:%s\n",get_F(n));
	switch(n->opr.oper)
	{
	case BOOL_OR:
		debugger("MATCHED BOOL_OR in ir_bool_flow\n");
		set_T(B1,n->opr.T);
		set_F(B1,newlabel());
		set_T(B2,n->opr.T);
		set_F(B2,n->opr.F);
		generate(B1);
		debugger("%s:",get_F(B1)); 
		fprintf(output,"%s:",get_F(B1)); 
		debugger("seen_bool_flow : %d\n",seen_bool_flow);
		generate(B2);
		break;
	case BOOL_EQ:
		//the rule is to load value of B1 and B2 on stack then use beq to jump accordingly so we have to switch of seen_bool_flow flag and restart later.
		seen_bool_flow = 0;
		generate(B1);
		generate(B2);
		seen_bool_flow = 1;
		debugger("MATCHED BOOL_EQ in ir_relop_flow\n");
		debugger("beq %s\n",get_T(n));
		fprintf(output,"beq %s\n",get_T(n));
		debugger("br %s\n",get_F(n));
		fprintf(output,"br %s\n",get_F(n));
		break;
	case NEQ:
		debugger("NOT EQUAL TO\n");
		//the rule is to load value of B1 and B2 on stack then use bne.un to jump accordingly so we have to switch of seen_bool_flow flag and restart later.
		seen_bool_flow = 0;
		generate(B1);
		generate(B2);
		seen_bool_flow = 1;
		debugger("MATCHED NEQ in ir_relop_flow\n");
		debugger("bne.un %s\n",get_T(n));
		fprintf(output,"bne.un %s\n",get_T(n));
		debugger("br %s\n",get_F(n));
		fprintf(output,"br %s\n",get_F(n));
		break;
	case BOOL_AND:
		set_T(B1,newlabel());
		set_F(B1, get_F(n));
		set_T(B2, get_T(n));
		set_F(B2, get_F(n));
		generate(B1);
		debugger("%s:",get_T(B1)); 
		fprintf(output,"%s:",get_T(B1)); 
		generate(B2);
		break;
	default: debugger("Bool DEFAULT\n");
	}
	
}
Exemplo n.º 11
0
/*----------------------------------------------------------------------------*/
  int 
  match_window(packet_t* p, uint8_t* s, window_t* w)
  {
    operator_t op = w->operation;
    uint16_t lhs = get_operand(p, s, w->size, w->lhs_location, w->lhs);
    uint16_t rhs = get_operand(p, s, w->size, w->rhs_location, w->rhs);
    return compare(op, lhs, rhs);
  }
Exemplo n.º 12
0
void ir_array_lhs(nodeType* n)
{
	nodeType* array_name = get_operand(n,0);
	nodeType* array_index = get_operand(n,1);
	debugger("ldloc %s\n",array_name->id.symrec->uid ); //number[i] = i
	fprintf(output,"ldloc %s\n",array_name->id.symrec->uid ); //number[i] = i
	generate(array_index);
}	
Exemplo n.º 13
0
// to handle situations 
void ir_method_invoc(nodeType* n)
{
	nodeType* ident = get_operand(n,0);	// ident	
	nodeType* method = get_operand(n,1);	// method
	nodeType* arglist = get_operand(n,2);	// arglist
	ir_load_ref(n);
	generate(arglist);
	
}
Exemplo n.º 14
0
void ir_case_stmt_list(nodeType* n)
{
	nodeType* casestmtlist = get_operand(n,0);
	nodeType* casestmt = get_operand(n,1);
	nodeType* default_stmt = get_operand(n,2);
	generate(casestmtlist);	
	generate(casestmt);	
	generate(default_stmt);	
}	
Exemplo n.º 15
0
void ir_bool(nodeType* n)
{
	debugger("in ir_bool\n");
	nodeType* B1 = get_operand(n,0);
	nodeType* B2 = get_operand(n,1);
	char* label1;
	char* label2;
	switch(n->opr.oper)
	{
		case NEQ:
			generate(B1);
			generate(B2);
			debugger("ceq\n");
			fprintf(output,"ceq\n");
			debugger("ldc.i4.0\n");
			fprintf(output,"ldc.i4.0\n");
			debugger("ceq\n");
			fprintf(output,"ceq\n");
			break;
		case BOOL_EQ:
			generate(B1);
			generate(B2);
			debugger("ceq\n");
			fprintf(output,"ceq\n");
			break;
		case BOOL_OR:
			generate(B1);
			label1 = strdup(newlabel());
			debugger("brtrue %s\n",label1);
			fprintf(output,"brtrue %s\n",label1);
			generate(B2);
			label2 = strdup(newlabel());
			debugger("br.s %s\n",label2);
			fprintf(output,"br.s %s\n",label2);
			debugger("%s: ldc.i4.1 \n",label1);
			fprintf(output,"%s: ldc.i4.1 \n",label1);
			debugger("%s: ",label2);
			fprintf(output,"%s: ",label2);
			break;
		case BOOL_AND:
			generate(B1);
			label1 = strdup(newlabel());
			debugger("brfalse %s\n",label1);
			fprintf(output,"brfalse %s\n",label1);
			generate(B2);
			label2 = strdup(newlabel());
			debugger("br.s %s\n",label2);
			fprintf(output,"br.s %s\n",label2);
			debugger("%s: ldc.i4.0\n",label1);
			fprintf(output,"%s: ldc.i4.0\n",label1);
			debugger("%s: ",label2);
			fprintf(output,"%s: ",label2);
			break;
		default: debugger("Bool DEFAULT\n");
	}
}
Exemplo n.º 16
0
void ir_var_dec(nodeType* n)
{
	nodeType* Idlist = get_operand(n,0);
	nodeType* Type = get_operand(n,1);
	debugger(".locals init(");
	fprintf(output,".locals init(");
	print_vardec_code(Idlist,Type);
	debugger(")\n");
	fprintf(output,")\n");
}
Exemplo n.º 17
0
void ir_case_stmt(nodeType* n)
{
	nodeType* const_exp = get_operand(n,0);
	nodeType* stmt = get_operand(n,1);
	char mylabel[16];
	memset(mylabel,0,16);
	strcat(mylabel,newlabel());
	debugger("%s: ",mylabel);
	fprintf(output,"%s: ",mylabel);
	generate(stmt);
	insert_queue(const_exp,mylabel);
}	
Exemplo n.º 18
0
QString isa_65c816::decode_name_arg(const char arg, int &size)
{
	QString decode;
	decode.reserve(7);
	unsigned int operand = get_operand(0) | get_operand(1) | get_operand(2);
	switch(arg){
		case 'l':
			size += 3;
			return "$" + to_hex(operand & 0xFFFFFF, 6);
		case 'w':
			size += 2;
			return "$" + to_hex(operand & 0x00FFFF, 4);
		case 'b':
			size++;
			return "$" + to_hex(operand & 0x0000FF, 2);	
		case 'r':
			size++;
			return label_op(operand & 0x0000FF, 2, &ROM_buffer::branch_address);
		case 'R':
			size += 2;
			return label_op(operand & 0x00FFFF, 4, &ROM_buffer::branch_address);
		case 'j':
			size += 2;
			return label_op(operand & 0x00FFFF, 4, &ROM_buffer::jump_address);
		case 'J':
			size += 3;
			return label_op(operand & 0xFFFFFF, 6, &ROM_buffer::jump_address);
		case 'a':
			size += 1 + A_state;
			if(A_state){
				return "#$" + to_hex(operand & 0x00FFFF, 4);	
			}else{
				return "#$" + to_hex(operand & 0x0000FF, 2);	
			}
		case 'i':
			size += 1 + I_state;
			if(I_state){
				return "#$" + to_hex(operand & 0x00FFFF, 4);	
			}else{
				return "#$" + to_hex(operand & 0x0000FF, 2);	
			}
		case 'f':
			A_state = (operand & 0x20) ? data.at(delta-1) == (char)0xC2 : A_state;
			I_state = (operand & 0x10) ? data.at(delta-1) == (char)0xC2 : I_state;
		case 'c':
			size++;
			return "#$" + to_hex(operand & 0x0000FF, 2);	
		default:
			qFatal("Invalid name decode arg");
	}
	return "";
}
Exemplo n.º 19
0
void ir_while(nodeType* n)
{
	nodeType* expr = get_operand(n,0);
	nodeType* stmt = get_operand(n,1);
	char begin[16];
	memset(begin,0,16);
	strcat(begin,newlabel());
	set_T(expr,newlabel());
	set_F(expr,n->opr.next);
	memset(stmt->opr.next,0,16);
	strcpy(stmt->opr.next,begin);
	debugger("%s:\n",begin);
	fprintf(output,"%s:\n",begin);
	
	seen_bool_flow = 1;prepost_put = 1;
	generate(expr);
	seen_bool_flow = 0;prepost_put = 0;
	
	debugger("%s:\n",get_T(expr));
	fprintf(output,"%s:\n",get_T(expr));

	//##for break statement##
	char initial_break_label[16];
	memset(initial_break_label,0,16);
	strcat(initial_break_label,break_label);
	memset(break_label,0,16);
	loop_flag = loop_flag + 1;
	strcat(break_label,n->opr.next);
	//#####for continue statement############
	char initial_continue_label[16];
	memset(initial_continue_label,0,16);
	strcpy(initial_continue_label,continue_label);
	memset(continue_label,0,16);
	strcpy(continue_label,begin);
	debugger("CONTINUE LABEL: %s\n",continue_label);
	//#######################################

	
	generate(stmt);
	
	debugger("br.s %s\n ",begin);
	fprintf(output,"br.s %s\n",begin);

	//for break statement
	loop_flag = loop_flag - 1;
	memset(break_label,0,16);
	strcat(break_label,initial_break_label);
	memset(continue_label,0,16);
	strcpy(continue_label,initial_continue_label);	
}	
Exemplo n.º 20
0
void ir_cast(nodeType* n)
{
	debugger("IN IRCAST\n");
	nodeType* unary_op = get_operand(n,0);
	nodeType* cast_exp = get_operand(n,1);
	if(unary_op->con_i.value == MY_MINUS)
		{
			generate(cast_exp);
			debugger("neg\n");
			fprintf(output,"neg\n");
		}
	else
			generate(cast_exp);
}	
Exemplo n.º 21
0
//done
void scan_operands (operands_t operands) {
  printf("scan_operands() for %s\n", lc3_get_format_name(operands));
  int operandCount = 0;
  int numOperands  = count_bits(operands);
  int errorCount   = numErrors;
  for (operand_t op = FMT_R1; op <= FMT_STR; op <<= 1) {
    //if the bits are set
    //printf(" ");
    if(op & operands){
      //create a token
      char* token = next_token();
      //get the operand of that token
      if(token != NULL){
      get_operand(op,token);
      
        //if errorocunt is not equal return
       if (errorCount != numErrors)
        return; // error, so skip processing remainder of line
      //inc operand count
      operandCount++;
      //if the count is less then the operands 
      if(operandCount < numOperands){
        //get comma or error
        get_comma_or_error();
      }
      //check errorcount again
      if (errorCount != numErrors)
      return; // error, so skip processing remainder of line

    }
  }
  }
}
Exemplo n.º 22
0
void ir_compound_stmt(nodeType* n)
{
	
	debugger("{\n");
	fprintf(output,"{\n");
	
	if(main_found==1)		// main flag set so this is entrypoint
	{
		debugger(" .entrypoint\n");
		fprintf(output," .entrypoint\n");
		main_found=0;
	}
	if(in_func==1)		// in every function need to set max stack 
	{
		debugger(".maxstack %d\n",MAXSTACK_SIZE);		// GIGLAMESH use a define here
		fprintf(output,".maxstack %d\n",MAXSTACK_SIZE);
		in_func=0;
	}
	nodeType* stmtlist = get_operand(n,0);
	memset(stmtlist->opr.next,0,16);
	strcat(stmtlist->opr.next,newlabel());		// attach a new label to stmt next
	generate(stmtlist);
	
	debugger("%s:\n",stmtlist->opr.next);
	fprintf(output,"%s:\n",stmtlist->opr.next);

	debugger("}\n");
	fprintf(output,"}\n");
}
Exemplo n.º 23
0
void ir_stmtlist(nodeType* n)
{
	nodeType* Stmtlist = get_operand(n,0);
	nodeType* Stmt = get_operand(n,1);
	memset(Stmtlist->opr.next,0,16);
	strcat(Stmtlist->opr.next,newlabel());
	debugger("Stmtlist next:%s \n",Stmtlist->opr.next);
	debugger("Stmtlist type:%d \n",Stmtlist->type);
	debugger("Stmtlist nops:%d \n",Stmtlist->opr.nops);
	generate(Stmtlist);
	memset(Stmt->opr.next,0,16);
	strcat(Stmt->opr.next,n->opr.next);	
	debugger("%s: \n",Stmtlist->opr.next);
	fprintf(output,"%s: \n",Stmtlist->opr.next);
	generate(Stmt);
}
Exemplo n.º 24
0
/* Interpret the operand of the option currently being processed as a tone pitch in Herz.
 * If it's "off", then return 0.
 */
static int pitch_operand (const char *description) {
   const char *operand = get_operand();
   if (strcmp(operand, "off") == 0) {
      return 0;
   }
   return to_integer(operand, description, &minimum_pitch, &maximum_pitch);
}
Exemplo n.º 25
0
void ir_return(nodeType* n)
{
	if(n->opr.nops != 0)
	{
		nodeType* return_exp = get_operand(n,0);
		generate(return_exp);
	}
	debugger("ret \n");
	fprintf(output,"ret \n");
}
Exemplo n.º 26
0
void ir_relop_flow(nodeType* n)
{
	int temp_bool_flow = seen_bool_flow;
	seen_bool_flow = 0;
	nodeType* B1 = get_operand(n,0);
	nodeType* B2 = get_operand(n,1);
	generate(B1);
	generate(B2);
	switch(n->opr.oper)
	{
		case LT:
			debugger("MATCHED LT in ir_relop_flow\n");
			debugger("blt %s\n",get_T(n));
			fprintf(output,"blt %s\n",get_T(n));
			debugger("br %s\n",get_F(n));
			fprintf(output,"br %s\n",get_F(n));
			break;
		case GT:
			debugger("MATCHED GT in ir_relop_flow\n");
			debugger("bgt %s\n",get_T(n));
			fprintf(output,"bgt %s\n",get_T(n));
			debugger("br %s\n",get_F(n));
			fprintf(output,"br %s\n",get_F(n));
			break;
		case LE:
			debugger("MATCHED LE in ir_relop_flow\n");
			debugger("ble %s\n",get_T(n));
			fprintf(output,"ble %s\n",get_T(n));
			debugger("br %s\n",get_F(n));
			fprintf(output,"br %s\n",get_F(n));
			break;
		case GE:
			debugger("MATCHED GE in ir_relop_flow\n");
			debugger("bge %s\n",get_T(n));
			fprintf(output,"bge %s\n",get_T(n));
			debugger("br %s\n",get_F(n));
			fprintf(output,"br %s\n",get_F(n));
			break;
		default:
			debugger("Relational Flow default\n");
	}
	seen_bool_flow = temp_bool_flow;
}
Exemplo n.º 27
0
char* ir_async(nodeType* n)
{
	debugger("Entered Async\n");
	nodeType* func = get_operand(n,0);
	nodeType* fun_name = get_operand(func,0);
	char* sign,*pch;
	sign = strdup(fun_name->id.symrec->signature);
	memset(thread_id,0,16);
	strcpy(thread_id,newuid());
	debugger(".locals init (class [mscorlib]System.Threading.Thread %s)\n",thread_id);
	fprintf(output,".locals init (class [mscorlib]System.Threading.Thread %s)\n",thread_id);
	debugger("ldnull\n");
	fprintf(output,"ldnull\n");
	debugger("ldftn ");
	fprintf(output,"ldftn ");
	
	if(strcmp(sign,"")==0)	
		return;	
	pch = strtok (sign," ::");
	debugger("%s ",pch);
	fprintf(output,"%s ",pch);
	
	debugger("class ");
	fprintf(output,"class ");
	debugger("%s::",fun_name->id.symrec->my_st->parent->owner_name);
	fprintf(output,"%s::",fun_name->id.symrec->my_st->parent->owner_name);
	debugger("%s",fun_name->id.symrec->sym_name);
	fprintf(output,"%s",fun_name->id.symrec->sym_name);
	debugger("()\n");
	fprintf(output,"()\n");
	debugger("newobj instance void class [mscorlib]System.Threading.ThreadStart::'.ctor'(object, native int)\n");
	fprintf(output,"newobj instance void class [mscorlib]System.Threading.ThreadStart::'.ctor'(object, native int)\n");
	debugger("newobj instance void class [mscorlib]System.Threading.Thread::'.ctor'(class [mscorlib]System.Threading.ThreadStart)\n");
	fprintf(output,"newobj instance void class [mscorlib]System.Threading.Thread::'.ctor'(class [mscorlib]System.Threading.ThreadStart)\n");
	debugger("stloc %s\n",thread_id); 
	fprintf(output,"stloc %s\n",thread_id); 
	debugger("ldloc %s\n",thread_id); 
	fprintf(output,"ldloc %s\n",thread_id); 
	debugger("callvirt instance void class [mscorlib]System.Threading.Thread::Start()\n");
	fprintf(output,"callvirt instance void class [mscorlib]System.Threading.Thread::Start()\n");
	return thread_id;
}
Exemplo n.º 28
0
void ir_array_declaration(nodeType* n)
{
	nodeType* array_name = get_operand(n,0);
	nodeType* array_type = get_operand(n,1);
	nodeType* array_size = get_operand(n,2);
	
	debugger(".locals init (");
	fprintf(output,".locals init (");
	print_type(array_type);
	debugger("[] ");
	fprintf(output,"[] ");
	debugger(" %s )\n",array_name->id.symrec->uid); 	
	fprintf(output," %s )\n",array_name->id.symrec->uid); 	
	
	generate(array_size);
	
	debugger("newarr [mscorlib]System.Int32\n"); 		// create a new array
	fprintf(output,"newarr [mscorlib]System.Int32\n"); 
	debugger("stloc %s\n",array_name->id.symrec->uid );
	fprintf(output,"stloc %s\n",array_name->id.symrec->uid );
}
Exemplo n.º 29
0
// expects a fundef node 
// constructor cant be static 
// so static node will have no relevance here
void ir_constructor(nodeType* n)
{
	nodeType* modifier = get_operand(n,0);		// modifier node
	nodeType* static_or_not = get_operand(n,1);		// static node
	nodeType* fun_name = get_operand(n,2);	
	nodeType* formal_arguments = get_operand(n,3);
	nodeType* return_type =get_operand(n,4);
	nodeType* compound =get_operand(n,5);
	
	debugger("SIGNATURE OF CONSTR %s\n",fun_name->id.symrec->signature);
	
	debugger(".method public hidebysig specialname rtspecialname instance default void '.ctor' (");
	fprintf(output,".method public hidebysig specialname rtspecialname instance default void '.ctor' (");
	print_formal_args(formal_arguments);
	fprintf(output,")  cil managed \n");
   
    debugger("{\n");
    fprintf(output,"{\n");
	
	debugger("\t.maxstack %d\n",MAXSTACK_SIZE);
	fprintf(output,"\t.maxstack %d\n",MAXSTACK_SIZE);
	debugger("\tldarg.0\n");
	fprintf(output,"\tldarg.0\n");
	debugger("\tcall instance void object::'.ctor'()\n");
	fprintf(output,"\tcall instance void object::'.ctor'()\n");
		
	generate(compound);			// this needs some special changes
	
	debugger("\tret\n"); 
	fprintf(output,"\tret\n"); 
    debugger("}\n");
    fprintf(output,"}\n");
}
Exemplo n.º 30
0
void print_vardec_code(nodeType* Idlist,nodeType* Type)
{
	if(Idlist->type==typeId)
	{
		print_type(Type);
		debugger(" %s ",Idlist->id.symrec->uid); 
		fprintf(output," %s ",Idlist->id.symrec->uid); 
		return;
	}
	else
	{
		nodeType* lc=get_operand(Idlist,0);
		nodeType* rc=get_operand(Idlist,1);
		print_vardec_code(lc,Type);
		debugger(",");
		fprintf(output,",");
		print_type(Type);
		debugger(" %s ",rc->id.symrec->uid); 
		fprintf(output," %s ",rc->id.symrec->uid); 
	}	
	return;
}