Exemplo n.º 1
0
/*
 *	print a quad structure
 */
void	print_quad( QUAD *quad)
{
	switch( quad->operator)
	{
	case '|':
	case '^':
	case '&':
	case '+':
	case '-':
	case '*':
	case '/':
	case '%':
  case '<':
  case '>':
       printf( "\t");
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     printf( " %c ", quad->operator);
	     print_quad_operand( quad->op2_type, quad->op2_index);
	     break;
  case LE:
  case GE:
  case EQ:
  case NE:
       printf( "\t");
       print_quad_operand( quad->dst_type, quad->dst_index);
       printf( " = ");
       print_quad_operand( quad->op1_type, quad->op1_index);
       printf( " %s ", relational[ quad->operator - LE]);
       print_quad_operand( quad->op2_type, quad->op2_index);
       break;
	case UMINUS:
       printf( "\t");
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = - ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     break;
	case '~' :
       printf( "\t");
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = ~ ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     break;
	case '=':
       printf( "\t");
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     break;
  case IFTRUE:
      printf( "\t");
      printf( "IFTRUE ");
      print_quad_operand( quad->dst_type, quad->dst_index);
      printf( " GOTO ");
      print_quad_operand( quad->op1_type, quad->op1_index);
      break;
  case IFFALSE:
      printf( "\t");
      printf( "IFFALSE ");
      print_quad_operand( quad->dst_type, quad->dst_index);
      printf( " GOTO ");
      print_quad_operand( quad->op1_type, quad->op1_index);
      break;
  case LABEL:
      print_quad_operand( quad->dst_type, quad->dst_index);
      printf( ": ");
      break;
  case GOTO:
      printf( "\t");
      printf( "GOTO ");
      print_quad_operand( quad->dst_type, quad->dst_index);
      break;
  case ']':
      printf( "\t");
      print_quad_operand( quad->dst_type, quad->dst_index);
      printf( " = ");
      print_quad_operand( quad->op1_type, quad->op1_index);
      printf( " [ ");
      print_quad_operand( quad->op2_type, quad->op2_index);
      printf( " ] ");
      break;
	}
	printf( "\n");
	//	printf( "\nnext: %08.8x\n", (int)quad->next);
	return;
}
Exemplo n.º 2
0
/*
 *	print a quad structure
 */
void	print_quad( QUAD *quad)
{
	printf("\t");
	switch( quad->operator)
	{
	case IF:
		printf("IFTRUE ");
		print_quad_operand(quad->dst_type, quad->dst_index);
		printf(" GOTO ");
		print_quad_operand(quad->op1_type, quad->op1_index);
		break;
	case LABEL:
		printf("\r");
		print_quad_operand(quad->dst_type, quad->dst_index);
		printf(": ");
		break;
	case GOTO:
		printf("GOTO ");
		print_quad_operand(quad->dst_type, quad->dst_index);
		break;
	case '|':
	case '^':
	case '&':
	case '+':
	case '-':
	case '*':
	case '/':
	case '%':
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     printf( " %c ", quad->operator);
	     print_quad_operand( quad->op2_type, quad->op2_index);
	     break;
	case UMINUS:
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = - ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     break;
	case UPLUS:
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = + ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     break;
	case '~' :
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = ~ ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     break;
	case '=':
	     print_quad_operand( quad->dst_type, quad->dst_index);
	     printf( " = ");
	     print_quad_operand( quad->op1_type, quad->op1_index);
	     break;
	}
	printf( "\n");
	//	printf( "\nnext: %08.8x\n", (int)quad->next);
	return;
}