Set datatype of il_intruction_c objects containing an ST operator.
authorMario de Sousa <msousa@fe.up.pt>
Sun, 07 Oct 2012 09:45:54 +0100
changeset 674 b221168a36f1
parent 673 90d7636e3c39
child 675 59fc28d4b06c
Set datatype of il_intruction_c objects containing an ST operator.
stage3/narrow_candidate_datatypes.cc
stage3/narrow_candidate_datatypes.hh
--- a/stage3/narrow_candidate_datatypes.cc	Sun Oct 07 09:33:42 2012 +0100
+++ b/stage3/narrow_candidate_datatypes.cc	Sun Oct 07 09:45:54 2012 +0100
@@ -68,6 +68,7 @@
 narrow_candidate_datatypes_c::narrow_candidate_datatypes_c(symbol_c *ignore) {
 	search_varfb_instance_type = NULL;
 	fake_prev_il_instruction = NULL;
+	current_il_instruction   = NULL;
 	il_operand = NULL;
 }
 
@@ -635,9 +636,11 @@
 		intersect_prev_candidate_datatype_lists(&tmp_prev_il_instruction);
 		/* Tell the il_instruction the datatype that it must generate - this was chosen by the next il_instruction (remember: we are iterating backwards!) */
 		fake_prev_il_instruction = &tmp_prev_il_instruction;
+		current_il_instruction   = symbol;
 		symbol->il_instruction->datatype = symbol->datatype;
 		symbol->il_instruction->accept(*this);
 		fake_prev_il_instruction = NULL;
+		current_il_instruction   = NULL;
 	}
 	return NULL;
 }
@@ -937,6 +940,10 @@
 	il_operand->accept(*this);
 	/* set the desired datatype of the previous il instruction */
 	set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction);
+	/* In the case of the ST operator, we must set the datatype of the il_instruction_c object that points to this ST_operator_c ourselves,
+	 * since the following il_instruction_c objects have not done it, as is normal/standard for other instructions!
+	 */
+	current_il_instruction->datatype = symbol->datatype;
 	return NULL;
 }
 
--- a/stage3/narrow_candidate_datatypes.hh	Sun Oct 07 09:33:42 2012 +0100
+++ b/stage3/narrow_candidate_datatypes.hh	Sun Oct 07 09:45:54 2012 +0100
@@ -68,6 +68,7 @@
     search_base_type_c search_base_type;
     symbol_c *il_operand;
     il_instruction_c *fake_prev_il_instruction;
+    il_instruction_c   *current_il_instruction;
 
     bool is_widening_compatible(const struct widen_entry widen_table[], symbol_c *left_type, symbol_c *right_type, symbol_c *result_type, bool *deprecated_status = NULL);