stage3/visit_expression_type.cc
changeset 259 b6d7c71ff6d8
parent 258 d7d92b2f87e9
child 260 70dfd493e639
equal deleted inserted replaced
258:d7d92b2f87e9 259:b6d7c71ff6d8
    48                                   ((symbol1)->last_column  < (symbol2)->last_column)  ? (symbol2) :    \
    48                                   ((symbol1)->last_column  < (symbol2)->last_column)  ? (symbol2) :    \
    49                                   ((symbol1)->last_column  > (symbol2)->last_column)  ? (symbol1) :    \
    49                                   ((symbol1)->last_column  > (symbol2)->last_column)  ? (symbol1) :    \
    50                                   (symbol1))
    50                                   (symbol1))
    51 
    51 
    52 #define STAGE3_ERROR(symbol1, symbol2, msg) {                                          \
    52 #define STAGE3_ERROR(symbol1, symbol2, msg) {                                          \
    53     /*printf("semantic error between (%d:%d) and (%d:%d): %s\n",                         \
    53     fprintf(stderr, "semantic error between (%d:%d) and (%d:%d): %s\n",                \
    54            FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column, \
    54            FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column, \
    55            LAST_(symbol1,symbol2) ->last_line,  LAST_(symbol1,symbol2) ->last_column,  \
    55            LAST_(symbol1,symbol2) ->last_line,  LAST_(symbol1,symbol2) ->last_column,  \
    56            msg);*/                                                                       \
    56            msg);                                                                       \
    57     il_error = true;                                                                   \
    57     il_error = true;                                                                   \
    58   }
    58   }
    59 
    59 
    60 
    60 
    61 
    61 /* set to 1 to see debug info during execution */
       
    62 static int debug = 0;
    62 
    63 
    63 
    64 
    64 void *visit_expression_type_c::visit(program_declaration_c *symbol) {
    65 void *visit_expression_type_c::visit(program_declaration_c *symbol) {
    65   search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
    66   search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
    66   symbol->var_declarations->accept(*this);
    67   symbol->var_declarations->accept(*this);
    67   //printf("checking semantics in body of program %s\n", ((token_c *)(symbol->program_type_name))->value);
    68   if (debug) printf("checking semantics in body of program %s\n", ((token_c *)(symbol->program_type_name))->value);
    68   il_parenthesis_level = 0;
    69   il_parenthesis_level = 0;
    69   il_error = false;
    70   il_error = false;
    70   il_default_variable_type = NULL;
    71   il_default_variable_type = NULL;
    71   symbol->function_block_body->accept(*this);
    72   symbol->function_block_body->accept(*this);
    72   il_default_variable_type = NULL;
    73   il_default_variable_type = NULL;
    76 }
    77 }
    77 
    78 
    78 void *visit_expression_type_c::visit(function_declaration_c *symbol) {
    79 void *visit_expression_type_c::visit(function_declaration_c *symbol) {
    79   search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
    80   search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
    80   symbol->var_declarations_list->accept(*this);
    81   symbol->var_declarations_list->accept(*this);
    81   //printf("checking semantics in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value);
    82   if (debug) printf("checking semantics in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value);
    82   il_parenthesis_level = 0;
    83   il_parenthesis_level = 0;
    83   il_error = false;
    84   il_error = false;
    84   il_default_variable_type = NULL;
    85   il_default_variable_type = NULL;
    85   symbol->function_body->accept(*this);
    86   symbol->function_body->accept(*this);
    86   il_default_variable_type = NULL;
    87   il_default_variable_type = NULL;
    90 }
    91 }
    91 
    92 
    92 void *visit_expression_type_c::visit(function_block_declaration_c *symbol) {
    93 void *visit_expression_type_c::visit(function_block_declaration_c *symbol) {
    93   search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
    94   search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
    94   symbol->var_declarations->accept(*this);
    95   symbol->var_declarations->accept(*this);
    95   //printf("checking semantics in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value);
    96   if (debug) printf("checking semantics in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value);
    96   il_parenthesis_level = 0;
    97   il_parenthesis_level = 0;
    97   il_error = false;
    98   il_error = false;
    98   il_default_variable_type = NULL;
    99   il_default_variable_type = NULL;
    99   symbol->fblock_body->accept(*this);
   100   symbol->fblock_body->accept(*this);
   100   il_default_variable_type = NULL;
   101   il_default_variable_type = NULL;