stage3/print_datatypes_error.cc
changeset 431 5792016eedd8
parent 430 d7a6221f64d7
child 434 c1278e52bcbc
equal deleted inserted replaced
430:d7a6221f64d7 431:5792016eedd8
  1032 
  1032 
  1033 	if ((NULL != symbol->formal_param_list) && (NULL != symbol->nonformal_param_list)) 
  1033 	if ((NULL != symbol->formal_param_list) && (NULL != symbol->nonformal_param_list)) 
  1034 		ERROR;
  1034 		ERROR;
  1035 
  1035 
  1036 	symbol_c *f_decl = symbol->called_function_declaration;
  1036 	symbol_c *f_decl = symbol->called_function_declaration;
  1037 	if (NULL == symbol->called_function_declaration) {
  1037 	if (NULL == f_decl) {
  1038 		STAGE3_ERROR(0, symbol, symbol, "Unable to resolve which overloaded function '%s' is being invoked.", ((identifier_c *)symbol->function_name)->value);
  1038 		STAGE3_ERROR(0, symbol, symbol, "Unable to resolve which overloaded function '%s' is being invoked.", ((identifier_c *)symbol->function_name)->value);
  1039 		/* we now try to find any function declaration with the same name, just so we can provide some relevant error messages */
  1039 		/* we now try to find any function declaration with the same name, just so we can provide some relevant error messages */
  1040 		function_symtable_t::iterator lower = function_symtable.lower_bound(symbol->function_name);
  1040 		function_symtable_t::iterator lower = function_symtable.lower_bound(symbol->function_name);
  1041 		if (lower == function_symtable.end()) ERROR;
  1041 		if (lower == function_symtable.end()) ERROR;
  1042 		f_decl = function_symtable.get_value(lower);
  1042 		f_decl = function_symtable.get_value(lower);
  1117 	bool function_invocation_error = false;
  1117 	bool function_invocation_error = false;
  1118 
  1118 
  1119 	if ((NULL != symbol->formal_param_list) && (NULL != symbol->nonformal_param_list)) 
  1119 	if ((NULL != symbol->formal_param_list) && (NULL != symbol->nonformal_param_list)) 
  1120 		ERROR;
  1120 		ERROR;
  1121 
  1121 
       
  1122 	symbol_c *f_decl = symbol->called_fb_declaration;
       
  1123 	if (NULL == f_decl) {
       
  1124 		/* Due to the way the syntax analysis is buit (i.e. stage 2), this should never occur.
       
  1125 		 * I.e., a FB invocation using an undefined FB variable is not possible in the current implementation of stage 2.
       
  1126 		 */
       
  1127 		ERROR;
       
  1128 // 		STAGE3_ERROR(0, symbol, symbol, "Undefined FB variable '%s'", ((identifier_c *)symbol->fb_name)->value);
       
  1129 	}
       
  1130 
  1122 	if (NULL != symbol->formal_param_list) {
  1131 	if (NULL != symbol->formal_param_list) {
  1123 		symbol->formal_param_list->accept(*this);
  1132 		symbol->formal_param_list->accept(*this);
       
  1133 		function_param_iterator_c fp_iterator(f_decl);
  1124 		while ((param_name = fcp_iterator.next_f()) != NULL) {
  1134 		while ((param_name = fcp_iterator.next_f()) != NULL) {
  1125 			param_value = fcp_iterator.get_current_value();
  1135 			param_value = fcp_iterator.get_current_value();
  1126 			if (NULL == param_value->datatype) {
  1136 			/* Find the corresponding parameter in function declaration */
       
  1137 			if (NULL == fp_iterator.search(param_name)) {
       
  1138 				STAGE3_ERROR(0, symbol, symbol, "Invalid parameter '%s' when invoking FB '%s'", ((identifier_c *)param_name)->value, ((identifier_c *)symbol->fb_name)->value);		  
       
  1139 			} else if (NULL == param_value->datatype) {
  1127 				function_invocation_error = true;
  1140 				function_invocation_error = true;
  1128 				STAGE3_ERROR(0, symbol, symbol, "Invalid parameter '%s' in FB invocation: %s", ((identifier_c *)param_name)->value, ((identifier_c *)symbol->fb_name)->value);
  1141 				STAGE3_ERROR(0, symbol, symbol, "Data type incompatibility between parameter '%s' and value being passed, when invoking FB '%s'", ((identifier_c *)param_name)->value, ((identifier_c *)symbol->fb_name)->value);
  1129 			}
  1142 			}
  1130 		}
  1143 		}
  1131 	}
  1144 	}
  1132 	if (NULL != symbol->nonformal_param_list) {
  1145 	if (NULL != symbol->nonformal_param_list) {
  1133 		symbol->nonformal_param_list->accept(*this);
  1146 		symbol->nonformal_param_list->accept(*this);