stage3/visit_expression_type.cc
changeset 263 bcb92f5b9a91
parent 262 197ba42d78b2
child 266 2f6d8866ec8d
equal deleted inserted replaced
262:197ba42d78b2 263:bcb92f5b9a91
   648 symbol_c *visit_expression_type_c::compute_expression(symbol_c *left_type,      symbol_c *right_type,     is_data_type_t is_data_type,
   648 symbol_c *visit_expression_type_c::compute_expression(symbol_c *left_type,      symbol_c *right_type,     is_data_type_t is_data_type,
   649 						      symbol_c *left_expr, symbol_c *right_expr) {
   649 						      symbol_c *left_expr, symbol_c *right_expr) {
   650   bool error = false;
   650   bool error = false;
   651 
   651 
   652   if (!(this->*is_data_type)(left_type)) {
   652   if (!(this->*is_data_type)(left_type)) {
       
   653     if (debug) printf("visit_expression_type_c::compute_expression(): invalid left_type\n");
   653     if (left_expr != NULL)
   654     if (left_expr != NULL)
   654       STAGE3_ERROR(left_expr, left_expr, "Invalid data type of left operand.");
   655       STAGE3_ERROR(left_expr, left_expr, "Invalid data type of left operand.");
   655     error = true;
   656     error = true;
   656   }
   657   }
   657   if (!(this->*is_data_type)(right_type)) {
   658   if (!(this->*is_data_type)(right_type)) {
       
   659     if (debug) printf("visit_expression_type_c::compute_expression(): invalid right_type\n");
   658     if (right_expr != NULL)
   660     if (right_expr != NULL)
   659       STAGE3_ERROR(right_expr, right_expr, "Invalid data type of right operand.");
   661       STAGE3_ERROR(right_expr, right_expr, "Invalid data type of right operand.");
   660     error = true;
   662     error = true;
   661   }
   663   }
   662   if (!is_compatible_type(left_type, right_type)) {
   664   if (!is_compatible_type(left_type, right_type)) {
       
   665     if (debug) printf("visit_expression_type_c::compute_expression(): left_type & right_type are incompatible\n");
   663     if ((left_expr != NULL) && (right_expr != NULL))
   666     if ((left_expr != NULL) && (right_expr != NULL))
   664       STAGE3_ERROR(left_expr, right_expr, "Type mismatch between operands.");
   667       STAGE3_ERROR(left_expr, right_expr, "Type mismatch between operands.");
   665     error = true;
   668     error = true;
   666   }
   669   }
   667 
   670 
   804 
   807 
   805 void visit_expression_type_c::check_formal_parameter(symbol_c *call_param_name, symbol_c *call_param_type, symbol_c *f_decl) {
   808 void visit_expression_type_c::check_formal_parameter(symbol_c *call_param_name, symbol_c *call_param_type, symbol_c *f_decl) {
   806   symbol_c *param_type;
   809   symbol_c *param_type;
   807   identifier_c *param_name;
   810   identifier_c *param_name;
   808   function_param_iterator_c       fp_iterator(f_decl);
   811   function_param_iterator_c       fp_iterator(f_decl);
   809 
   812  
   810   /* Find the corresponding parameter of the function being called */
   813   /* Find the corresponding parameter of the function being called */
   811   param_name = fp_iterator.search(call_param_name);
   814   param_name = fp_iterator.search(call_param_name);
   812   if(param_name == NULL) {
   815   if(param_name == NULL) {
   813     STAGE3_ERROR(call_param_name, call_param_name, "Invalid parameter in function/FB call.");
   816     STAGE3_ERROR(call_param_name, call_param_name, "Invalid parameter in function/FB call.");
   814   } else {
   817   } else {