61 if ((typeid(*left_type) == typeid(*widen_table[k].left)) && (typeid(*right_type) == typeid(*widen_table[k].right))) |
61 if ((typeid(*left_type) == typeid(*widen_table[k].left)) && (typeid(*right_type) == typeid(*widen_table[k].right))) |
62 return widen_table[k].result; |
62 return widen_table[k].result; |
63 return NULL; |
63 return NULL; |
64 } |
64 } |
65 |
65 |
|
66 |
|
67 |
|
68 |
66 /* returns true if compatible function/FB invocation, otherwise returns false */ |
69 /* returns true if compatible function/FB invocation, otherwise returns false */ |
67 bool fill_candidate_datatypes_c::match_nonformal_call(symbol_c *f_call, symbol_c *f_decl) { |
70 bool fill_candidate_datatypes_c::match_nonformal_call(symbol_c *f_call, symbol_c *f_decl) { |
68 symbol_c *call_param_value, *param_type; |
71 symbol_c *call_param_value, *param_type; |
69 identifier_c *param_name; |
72 identifier_c *param_name; |
70 function_param_iterator_c fp_iterator(f_decl); |
73 function_param_iterator_c fp_iterator(f_decl); |
96 } |
99 } |
97 /* call is compatible! */ |
100 /* call is compatible! */ |
98 return true; |
101 return true; |
99 } |
102 } |
100 |
103 |
|
104 |
|
105 |
101 /* returns true if compatible function/FB invocation, otherwise returns false */ |
106 /* returns true if compatible function/FB invocation, otherwise returns false */ |
102 bool fill_candidate_datatypes_c::match_formal_call(symbol_c *f_call, symbol_c *f_decl) { |
107 bool fill_candidate_datatypes_c::match_formal_call(symbol_c *f_call, symbol_c *f_decl) { |
103 symbol_c *call_param_value, *call_param_name, *param_type; |
108 symbol_c *call_param_value, *call_param_name, *param_type; |
104 symbol_c *verify_duplicate_param; |
109 symbol_c *verify_duplicate_param; |
105 identifier_c *param_name; |
110 identifier_c *param_name; |
126 std::vector <symbol_c *>&call_param_types = call_param_value->candidate_datatypes; |
131 std::vector <symbol_c *>&call_param_types = call_param_value->candidate_datatypes; |
127 |
132 |
128 |
133 |
129 /* Find the corresponding parameter in function declaration */ |
134 /* Find the corresponding parameter in function declaration */ |
130 param_name = fp_iterator.search(call_param_name); |
135 param_name = fp_iterator.search(call_param_name); |
131 if(param_name == NULL) { |
136 if(param_name == NULL) return false; |
132 return false; |
137 /* Get the parameter type */ |
133 } else { |
138 param_type = base_type(fp_iterator.param_type()); |
134 /* Get the parameter type */ |
139 /* check whether one of the candidate_data_types of the value being passed is the same as the param_type */ |
135 param_type = base_type(fp_iterator.param_type()); |
140 for (i = 0; i < call_param_types.size(); i++) { |
136 for (i = 0; i < call_param_types.size(); i++) { |
141 /* If found (correct data type being passed), then stop the search */ |
137 /* If the declared parameter and the parameter from the function call have the same type */ |
142 if(is_type_equal(param_type, call_param_types[i])) break; |
138 if(is_type_equal(param_type, call_param_types[i])) |
143 } |
139 break; |
144 /* if we reached the end of the loop, and no compatible type found, then return false */ |
140 } |
145 if (i >= call_param_types.size()) return false; |
141 if (i >= call_param_types.size()) |
146 |
142 return false;; |
147 } |
143 } |
148 /* call is compatible! */ |
144 } |
|
145 return true; |
149 return true; |
146 } |
150 } |
|
151 |
|
152 |
|
153 |
147 |
154 |
148 /* a helper function... */ |
155 /* a helper function... */ |
149 symbol_c *fill_candidate_datatypes_c::base_type(symbol_c *symbol) { |
156 symbol_c *fill_candidate_datatypes_c::base_type(symbol_c *symbol) { |
150 /* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used |
157 /* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used |
151 * in the code. |
158 * in the code. |
1678 |
1685 |
1679 if (debug) std::cout << "function()\n"; |
1686 if (debug) std::cout << "function()\n"; |
1680 parameter_list->accept(*this); |
1687 parameter_list->accept(*this); |
1681 for(; lower != upper; lower++) { |
1688 for(; lower != upper; lower++) { |
1682 bool compatible = false; |
1689 bool compatible = false; |
|
1690 |
1683 f_decl = function_symtable.get_value(lower); |
1691 f_decl = function_symtable.get_value(lower); |
1684 /* Check if function declaration in symbol_table is compatible with parameters */ |
1692 /* Check if function declaration in symbol_table is compatible with parameters */ |
1685 if (NULL != symbol->nonformal_param_list) compatible=match_nonformal_call(symbol, f_decl); |
1693 if (NULL != symbol->nonformal_param_list) compatible=match_nonformal_call(symbol, f_decl); |
1686 if (NULL != symbol-> formal_param_list) compatible= match_formal_call(symbol, f_decl); |
1694 if (NULL != symbol-> formal_param_list) compatible= match_formal_call(symbol, f_decl); |
1687 if (compatible) { |
1695 if (compatible) { |
1701 } |
1709 } |
1702 } |
1710 } |
1703 if (debug) std::cout << "end_function() [" << symbol->candidate_datatypes.size() << "] result.\n"; |
1711 if (debug) std::cout << "end_function() [" << symbol->candidate_datatypes.size() << "] result.\n"; |
1704 return NULL; |
1712 return NULL; |
1705 } |
1713 } |
|
1714 |
|
1715 |
1706 |
1716 |
1707 /********************/ |
1717 /********************/ |
1708 /* B 3.2 Statements */ |
1718 /* B 3.2 Statements */ |
1709 /********************/ |
1719 /********************/ |
1710 // SYM_LIST(statement_list_c) |
1720 // SYM_LIST(statement_list_c) |