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::set_datatype_in_prev_il_instructions(symbol_c *datatype, il_instruction_c *symbol) { |
|
124 if (NULL == symbol) ERROR; |
|
125 /* In the forced_narrow_candidate_datatypes algorithm, we do NOT set any datatypes to invalid_type_name_c |
|
126 * Any IL instructions that really are of an invalid_type_name_c (because the IL code is buggy?) have already |
|
127 * been set by the standard narrow_candidate_datatypes algorithm. |
|
128 * |
|
129 * Remember too that valid IL code may also have some IL instructions correctly set to invalid_type_name_c, especially |
|
130 * in cases where the data in the accumulator will not be used in the current IL instruction |
|
131 * For example: |
|
132 * LD bool_var |
|
133 * JMPC label1 |
|
134 * LD 34 |
|
135 * ST int_var |
|
136 * lable1: <---- This IL instruction_c (with NULL symbol->il_instruction) has invalid_type_name_c datatype!! |
|
137 * LD T#3s And yet, the code is legal!!! |
|
138 * ST time_var |
|
139 */ |
|
140 if (!get_datatype_info_c::is_type_valid(datatype)) return; |
|
141 // Call the 'original' version of the set_datatype_in_prev_il_instructions() function, from narrow_candidate_datatypes_c |
|
142 return narrow_candidate_datatypes_c::set_datatype_in_prev_il_instructions(datatype, symbol); |
|
143 } |
|
144 |
|
145 |
|
146 |
123 void forced_narrow_candidate_datatypes_c::forced_narrow_il_instruction(symbol_c *symbol, std::vector <symbol_c *> &next_il_instruction) { |
147 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) { |
148 if (NULL == symbol->datatype) { |
125 if (symbol->candidate_datatypes.empty()) { |
149 if (symbol->candidate_datatypes.empty()) { |
126 symbol->datatype = &(get_datatype_info_c::invalid_type_name); // This will occur in the situations (a) in the above example |
150 symbol->datatype = &(get_datatype_info_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)! |
151 // 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)! |