stage3/fill_candidate_datatypes.cc
changeset 431 5792016eedd8
parent 429 26bec44c591f
child 435 82cb6a64a763
equal deleted inserted replaced
430:d7a6221f64d7 431:5792016eedd8
  1718 	 * This guarantees that the remainder of the expression in which the function call is inserted
  1718 	 * This guarantees that the remainder of the expression in which the function call is inserted
  1719 	 * is treated as if the function call returns correctly, and therefore does not generate
  1719 	 * is treated as if the function call returns correctly, and therefore does not generate
  1720 	 * spurious error messages.
  1720 	 * spurious error messages.
  1721 	 * Even if the parameters to the function call are invalid, doing this is still safe, as the 
  1721 	 * Even if the parameters to the function call are invalid, doing this is still safe, as the 
  1722 	 * expressions inside the function call will themselves have erros and will  guarantee that 
  1722 	 * expressions inside the function call will themselves have erros and will  guarantee that 
  1723 	 * compilation is aborted in stage3.
  1723 	 * compilation is aborted in stage3 (in print_datatypes_error_c).
  1724 	 */
  1724 	 */
  1725 	if (function_symtable.multiplicity(symbol->function_name) == 1) {
  1725 	if (function_symtable.multiplicity(symbol->function_name) == 1) {
  1726 		f_decl = function_symtable.get_value(lower);
  1726 		f_decl = function_symtable.get_value(lower);
  1727 		returned_parameter_type = base_type(f_decl->type_name);
  1727 		returned_parameter_type = base_type(f_decl->type_name);
  1728 		symbol->candidate_functions.push_back(f_decl);
  1728 		symbol->candidate_functions.push_back(f_decl);
  1803 	if (symbol->nonformal_param_list != NULL) {
  1803 	if (symbol->nonformal_param_list != NULL) {
  1804 		symbol->nonformal_param_list->accept(*this);
  1804 		symbol->nonformal_param_list->accept(*this);
  1805 		compatible = match_nonformal_call(symbol, fb_decl);
  1805 		compatible = match_nonformal_call(symbol, fb_decl);
  1806 	}
  1806 	}
  1807 
  1807 
  1808 	if (compatible) 
  1808 	/* The print_datatypes_error_c does not rely on this called_fb_declaration pointer being != NULL to conclude that
  1809 		symbol->called_fb_declaration = fb_decl;
  1809 	 * we have a datat type incompatibility error, so setting it to the correct fb_decl is actually safe,
       
  1810 	 * as the compiler will never reach the compilation stage!
       
  1811 	 */
       
  1812 	symbol->called_fb_declaration = fb_decl;
  1810 
  1813 
  1811 	if (debug) std::cout << "FB [] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1814 	if (debug) std::cout << "FB [] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1812 	return NULL;
  1815 	return NULL;
  1813 }
  1816 }
  1814 
  1817