Пример #1
0
node* treeList(node *n)
{
  node *temp;

  if(n -> right == NULL && n -> left == NULL)
    {
      n -> left = n;
      n -> right = n;
      return(n);
    }

  else if(n -> right == NULL && n -> left != NULL)
    {
      n = appendL(n, treeList(n -> left));
      return(n);
    }

  else if(n -> left == NULL && n -> right != NULL)
    {
      n = appendR(n, treeList(n -> right));
      return(n);
    }
  
  else
    {
      temp = n -> right;
      n = appendL(n, treeList(n -> left));
      n = appendR(n, treeList(temp));
      return(n);
    }
}
Пример #2
0
void generate_RETURN(quad *quad){
	quad->taddress = nextInstructionLabel();
	instruction *t = (instruction *)malloc(sizeof(instruction));
	instruction *t1 = (instruction *)malloc(sizeof(instruction)); 
	t->arg1 = malloc(sizeof(vmarg));  
	t->result = malloc(sizeof(vmarg));
	t1->result = malloc(sizeof(vmarg));
	funcs *fun;

	if(quad->result!=NULL){      
		t->opcode = assign_v;
		make_retvaloperand(t->result);
		make_operand(quad->result, t->arg1);
		reset_operand(t->arg2);
		t->srcLine = quad->line;
		emitVmarg(t);
	}

	fun = topSym();
	fun->nodeR = appendR(fun->nodeR,nextInstructionLabel());
	t1->opcode = jump_v;
	reset_operand(t1->arg1);
	reset_operand(t1->arg2);
	t->arg1 = malloc(sizeof(vmarg));
	make_retvaloperand(t1->result);
	(t1->result)->type = label_a;
	t1->srcLine = quad->line;
	emitVmarg(t1);
}