Small code cleanup (move common code to a function)
authormjsousa
Wed, 21 Aug 2013 21:34:43 +0100
changeset 839 99d9ef4d210b
parent 838 13ea7c080018
child 840 60cea9fea6e6
Small code cleanup (move common code to a function)
stage3/narrow_candidate_datatypes.cc
stage3/narrow_candidate_datatypes.hh
--- a/stage3/narrow_candidate_datatypes.cc	Wed Aug 21 21:26:55 2013 +0100
+++ b/stage3/narrow_candidate_datatypes.cc	Wed Aug 21 21:34:43 2013 +0100
@@ -1243,11 +1243,7 @@
 
 
 
-
-void *narrow_candidate_datatypes_c::visit( LD_operator_c *symbol)  {return set_il_operand_datatype(il_operand, symbol->datatype);}
-void *narrow_candidate_datatypes_c::visit(LDN_operator_c *symbol)  {return set_il_operand_datatype(il_operand, symbol->datatype);}
-
-void *narrow_candidate_datatypes_c::visit(ST_operator_c *symbol) {
+void *narrow_candidate_datatypes_c::narrow_store_operator(symbol_c *symbol) {
 	if (symbol->candidate_datatypes.size() == 1) {
 		symbol->datatype = symbol->candidate_datatypes[0];
 		/* set the desired datatype of the previous il instruction */
@@ -1263,22 +1259,13 @@
 	return NULL;
 }
 
-void *narrow_candidate_datatypes_c::visit(STN_operator_c *symbol) {
-	if (symbol->candidate_datatypes.size() == 1) {
-		symbol->datatype = symbol->candidate_datatypes[0];
-		/* 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;
-	}
-	
-	/* set the datatype for the operand */
-	set_il_operand_datatype(il_operand, symbol->datatype);
-	return NULL;
-}
-
+
+
+void *narrow_candidate_datatypes_c::visit(  LD_operator_c *symbol)  {return set_il_operand_datatype(il_operand, symbol->datatype);}
+void *narrow_candidate_datatypes_c::visit( LDN_operator_c *symbol)  {return set_il_operand_datatype(il_operand, symbol->datatype);}
+
+void *narrow_candidate_datatypes_c::visit(  ST_operator_c *symbol)  {return narrow_store_operator(symbol);}
+void *narrow_candidate_datatypes_c::visit( STN_operator_c *symbol)  {return narrow_store_operator(symbol);}
 
 
 /* NOTE: the standard allows syntax in which the NOT operator is followed by an optional <il_operand>
--- a/stage3/narrow_candidate_datatypes.hh	Wed Aug 21 21:26:55 2013 +0100
+++ b/stage3/narrow_candidate_datatypes.hh	Wed Aug 21 21:34:43 2013 +0100
@@ -78,6 +78,7 @@
     void  narrow_formal_call         (symbol_c *f_call, symbol_c *f_decl, int *ext_parm_count = NULL);
     void *narrow_implicit_il_fb_call (symbol_c *symbol, const char *param_name, symbol_c *&called_fb_declaration);
     void *narrow_S_and_R_operator    (symbol_c *symbol, const char *param_name, symbol_c * called_fb_declaration);
+    void *narrow_store_operator      (symbol_c *symbol);
     void *narrow_conditional_operator(symbol_c *symbol);
     void *narrow_binary_operator    (const struct widen_entry widen_table[], symbol_c *symbol,                                     bool *deprecated_operation = NULL);
     void *narrow_binary_expression  (const struct widen_entry widen_table[], symbol_c *symbol, symbol_c *l_expr, symbol_c *r_expr, bool *deprecated_operation = NULL, bool allow_enums = false);