118 forced_narrow_candidate_datatypes_c::~forced_narrow_candidate_datatypes_c(void) { |
118 forced_narrow_candidate_datatypes_c::~forced_narrow_candidate_datatypes_c(void) { |
119 } |
119 } |
120 |
120 |
121 |
121 |
122 |
122 |
|
123 void forced_narrow_candidate_datatypes_c::forced_narrow_il_instruction(symbol_c *symbol, std::vector <symbol_c *> &next_il_instruction) { |
|
124 if (NULL == symbol->datatype) { |
|
125 if (symbol->candidate_datatypes.empty()) { |
|
126 symbol->datatype = &(search_constant_type_c::invalid_type_name); // This will occur in the situations (a) in the above example |
|
127 // return NULL; // No need to return control to the visit() method of the base class... But we do so, just to be safe (called at the end of this function)! |
|
128 } else { |
|
129 if (next_il_instruction.empty()) { |
|
130 symbol->datatype = symbol->candidate_datatypes[0]; // This will occur in the situations (b) in the above example |
|
131 } else { |
|
132 symbol_c *next_datatype = NULL; |
|
133 |
|
134 /* find the datatype of the following IL instructions (they should all be identical by now, but we don't have an assertion checking for this. */ |
|
135 for (unsigned int i=0; i < next_il_instruction.size(); i++) |
|
136 if (NULL != next_il_instruction[i]->datatype) |
|
137 next_datatype = next_il_instruction[i]->datatype; |
|
138 if (get_datatype_info_c::is_type_valid(next_datatype)) { |
|
139 // This will occur in the situations (c) in the above example |
|
140 symbol->datatype = symbol->candidate_datatypes[0]; |
|
141 } else { |
|
142 // This will occur in the situations (d) in the above example |
|
143 // it is not possible to determine the exact situation in the current pass, so we can't do anything just yet. Leave it for the next time around! |
|
144 } |
|
145 } |
|
146 } |
|
147 } |
|
148 } |
123 |
149 |
124 |
150 |
125 |
151 |
126 /****************************************/ |
152 /****************************************/ |
127 /* B.2 - Language IL (Instruction List) */ |
153 /* B.2 - Language IL (Instruction List) */ |
157 |
183 |
158 /* | label ':' [il_incomplete_instruction] eol_list */ |
184 /* | label ':' [il_incomplete_instruction] eol_list */ |
159 // SYM_REF2(il_instruction_c, label, il_instruction) |
185 // SYM_REF2(il_instruction_c, label, il_instruction) |
160 // void *visit(instruction_list_c *symbol); |
186 // void *visit(instruction_list_c *symbol); |
161 void *forced_narrow_candidate_datatypes_c::visit(il_instruction_c *symbol) { |
187 void *forced_narrow_candidate_datatypes_c::visit(il_instruction_c *symbol) { |
162 if (NULL == symbol->datatype) { |
188 forced_narrow_il_instruction(symbol, symbol->next_il_instruction); |
163 if (symbol->candidate_datatypes.empty()) { |
|
164 symbol->datatype = &(search_constant_type_c::invalid_type_name); // This will occur in the situations (a) in the above example |
|
165 // return NULL; // No need to return control to the visit() method of the base class... But we do so, just to be safe (called at the end of this function)! |
|
166 } else { |
|
167 if (symbol->next_il_instruction.empty()) { |
|
168 symbol->datatype = symbol->candidate_datatypes[0]; // This will occur in the situations (b) in the above example |
|
169 } else { |
|
170 symbol_c *next_datatype = NULL; |
|
171 |
|
172 /* find the datatype of the following IL instructions (they should all be identical by now, but we don't have an assertion checking for this. */ |
|
173 for (unsigned int i=0; i < symbol->next_il_instruction.size(); i++) |
|
174 if (NULL != symbol->next_il_instruction[i]->datatype) |
|
175 next_datatype = symbol->next_il_instruction[i]->datatype; |
|
176 if (get_datatype_info_c::is_type_valid(next_datatype)) { |
|
177 // This will occur in the situations (c) in the above example |
|
178 symbol->datatype = symbol->candidate_datatypes[0]; |
|
179 } else { |
|
180 // This will occur in the situations (d) in the above example |
|
181 // it is not possible to determine the exact situation in the current pass, so we can't do anything just yet. Leave it for the next time around! |
|
182 } |
|
183 } |
|
184 } |
|
185 } |
|
186 |
189 |
187 /* return control to the visit() method of the base class! */ |
190 /* return control to the visit() method of the base class! */ |
188 narrow_candidate_datatypes_c::visit(symbol); // This handle the situations (e) in the above example |
191 return narrow_candidate_datatypes_c::visit(symbol); // This handles the situations (e) in the above example |
189 |
|
190 return NULL; |
|
191 } |
192 } |
192 |
193 |
193 |
194 |
194 |
195 |
195 |
196 |
228 |
229 |
229 // void *visit(il_operand_list_c *symbol); |
230 // void *visit(il_operand_list_c *symbol); |
230 // void *forced_narrow_candidate_datatypes_c::visit(simple_instr_list_c *symbol) |
231 // void *forced_narrow_candidate_datatypes_c::visit(simple_instr_list_c *symbol) |
231 |
232 |
232 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;) |
233 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;) |
233 // void *forced_narrow_candidate_datatypes_c::visit(il_simple_instruction_c*symbol) |
234 void *forced_narrow_candidate_datatypes_c::visit(il_simple_instruction_c*symbol) { |
|
235 forced_narrow_il_instruction(symbol, symbol->next_il_instruction); |
|
236 |
|
237 /* return control to the visit() method of the base class! */ |
|
238 return narrow_candidate_datatypes_c::visit(symbol); // This handle the situations (e) in the above example |
|
239 } |
|
240 |
234 |
241 |
235 /* |
242 /* |
236 void *visit(il_param_list_c *symbol); |
243 void *visit(il_param_list_c *symbol); |
237 void *visit(il_param_assignment_c *symbol); |
244 void *visit(il_param_assignment_c *symbol); |
238 void *visit(il_param_out_assignment_c *symbol); |
245 void *visit(il_param_out_assignment_c *symbol); |