absyntax_utils/search_expression_type.cc
changeset 350 2c3c4dc34979
parent 336 229eb3e29216
equal deleted inserted replaced
341:ba80c3ceb6fb 350:2c3c4dc34979
   200   }
   200   }
   201   return symbol;
   201   return symbol;
   202 }
   202 }
   203 
   203 
   204 
   204 
   205 integer_c search_expression_type_c::integer("1"); // what default value should we use here ???
       
   206 #include "search_type_code.c"
       
   207 
       
   208 /*static bool_type_name_c bool_type_name;*/
       
   209 
       
   210 /* A helper function... */
   205 /* A helper function... */
   211 void *search_expression_type_c::compute_boolean_expression(symbol_c *left_type, symbol_c *right_type) {
   206 void *search_expression_type_c::compute_boolean_expression(symbol_c *left_type, symbol_c *right_type) {
   212   if (!is_same_type(left_type, right_type))
   207   if (!is_same_type(left_type, right_type))
   213     ERROR;
   208     ERROR;
   214   if (!is_bool_type(left_type) && !is_binary_type(left_type))
   209   if (!is_bool_type(left_type) && !is_binary_type(left_type))
   383   symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this));
   378   symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this));
   384   return compute_boolean_expression(exp_type, exp_type);
   379   return compute_boolean_expression(exp_type, exp_type);
   385 }
   380 }
   386 
   381 
   387 void *search_expression_type_c::visit(function_invocation_c *symbol) {
   382 void *search_expression_type_c::visit(function_invocation_c *symbol) {
   388   function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name);
   383   function_declaration_c *f_decl = (function_declaration_c *)symbol->called_function_declaration;
   389   if (f_decl == function_symtable.end_value()) {
   384   if (f_decl == NULL) ERROR;
   390     void *res = compute_standard_function_default(symbol);
       
   391     if (res == NULL)
       
   392        ERROR;
       
   393     return res;
       
   394   }
       
   395   return base_type(f_decl->type_name);
   385   return base_type(f_decl->type_name);
   396 }
   386 }
   397 
   387 
   398 /*bool_type_name_c     search_expression_type_c::bool_type_name;*/
   388 /*bool_type_name_c     search_expression_type_c::bool_type_name;*/
   399 
   389