stage3/fill_candidate_datatypes.cc
changeset 454 099aa5d655de
parent 453 4733f662362a
child 455 933c0dccc82f
equal deleted inserted replaced
453:4733f662362a 454:099aa5d655de
    43 #include <string>
    43 #include <string>
    44 #include <string.h>
    44 #include <string.h>
    45 #include <strings.h>
    45 #include <strings.h>
    46 
    46 
    47 /* set to 1 to see debug info during execution */
    47 /* set to 1 to see debug info during execution */
    48 static int debug = 1;
    48 static int debug = 0;
    49 
    49 
    50 fill_candidate_datatypes_c::fill_candidate_datatypes_c(symbol_c *ignore) {
    50 fill_candidate_datatypes_c::fill_candidate_datatypes_c(symbol_c *ignore) {
    51 }
    51 }
    52 
    52 
    53 fill_candidate_datatypes_c::~fill_candidate_datatypes_c(void) {
    53 fill_candidate_datatypes_c::~fill_candidate_datatypes_c(void) {
   919   /* Now check the if the data type semantics of operation are correct,  */
   919   /* Now check the if the data type semantics of operation are correct,  */
   920   il_operand = symbol->simple_instr_list;
   920   il_operand = symbol->simple_instr_list;
   921   prev_il_instruction = prev_il_instruction_backup;
   921   prev_il_instruction = prev_il_instruction_backup;
   922   symbol->il_expr_operator->accept(*this);
   922   symbol->il_expr_operator->accept(*this);
   923   il_operand = NULL;
   923   il_operand = NULL;
       
   924   
       
   925   /* This object has the same candidate datatypes as the il_expr_operator. */
       
   926   copy_candidate_datatype_list(symbol->il_expr_operator/*from*/, symbol/*to*/);
   924   return NULL;
   927   return NULL;
   925 }
   928 }
   926 
   929 
   927 void *fill_candidate_datatypes_c::visit(il_jump_operation_c *symbol) {
   930 void *fill_candidate_datatypes_c::visit(il_jump_operation_c *symbol) {
   928   /* recursive call to fill the candidate data types list */
   931   /* recursive call to fill the candidate data types list */
   996 
   999 
   997 
  1000 
   998 /* | simple_instr_list il_simple_instruction */
  1001 /* | simple_instr_list il_simple_instruction */
   999 /* This object is referenced by il_expression_c objects */
  1002 /* This object is referenced by il_expression_c objects */
  1000 void *fill_candidate_datatypes_c::visit(simple_instr_list_c *symbol) {
  1003 void *fill_candidate_datatypes_c::visit(simple_instr_list_c *symbol) {
  1001 std::cout << "simple_instr_list_c [filling starting]\n";
       
  1002   if (symbol->n <= 0)
  1004   if (symbol->n <= 0)
  1003     return NULL;  /* List is empty! Nothing to do. */
  1005     return NULL;  /* List is empty! Nothing to do. */
  1004     
  1006     
  1005   for(int i = 0; i < symbol->n; i++)
  1007   for(int i = 0; i < symbol->n; i++)
  1006     symbol->elements[i]->accept(*this);
  1008     symbol->elements[i]->accept(*this);
  1007 
  1009 
  1008   /* This object has (inherits) the same candidate datatypes as the last il_instruction */
  1010   /* This object has (inherits) the same candidate datatypes as the last il_instruction */
  1009   copy_candidate_datatype_list(symbol->elements[symbol->n-1] /*from*/, symbol /*to*/);	
  1011   copy_candidate_datatype_list(symbol->elements[symbol->n-1] /*from*/, symbol /*to*/);	
  1010   
  1012   
  1011   if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n";
  1013   if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n";
  1012 std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n";
       
  1013   return NULL;
  1014   return NULL;
  1014 }
  1015 }
  1015 
  1016 
  1016 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;)
  1017 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;)
  1017 void *fill_candidate_datatypes_c::visit(il_simple_instruction_c *symbol) {
  1018 void *fill_candidate_datatypes_c::visit(il_simple_instruction_c *symbol) {