stage3/narrow_candidate_datatypes.cc
changeset 1054 57c08195c962
parent 1047 34b733cb6641
equal deleted inserted replaced
1053:e94368340160 1054:57c08195c962
   105 }
   105 }
   106 
   106 
   107 
   107 
   108 
   108 
   109 /* Only set the symbol's desired datatype to 'datatype' if that datatype is in the candidate_datatype list */
   109 /* Only set the symbol's desired datatype to 'datatype' if that datatype is in the candidate_datatype list */
   110 // static void set_datatype_in_prev_il_instructions(symbol_c *datatype, std::vector <symbol_c *> prev_il_instructions) {
   110 // NOTE: This function is virtual! The forced_narrow_candidate_datatypes_c has a slightly different version of this fuinction!!
   111 static void set_datatype_in_prev_il_instructions(symbol_c *datatype, il_instruction_c *symbol) {
   111 void narrow_candidate_datatypes_c::set_datatype_in_prev_il_instructions(symbol_c *datatype, il_instruction_c *symbol) {
   112 	if (NULL == symbol) ERROR;
   112 	if (NULL == symbol) ERROR;
   113 	for (unsigned int i = 0; i < symbol->prev_il_instruction.size(); i++)
   113 	for (unsigned int i = 0; i < symbol->prev_il_instruction.size(); i++)
   114 		set_datatype(datatype, symbol->prev_il_instruction[i]);
   114 		set_datatype(datatype, symbol->prev_il_instruction[i]);
   115 }
   115 }
   116 
   116 
  1279  *       In this case, when we call il_operand->accept(*this);, the prev_il_instruction pointer will be overwritten!
  1279  *       In this case, when we call il_operand->accept(*this);, the prev_il_instruction pointer will be overwritten!
  1280  *
  1280  *
  1281  *       So, if yoy wish to set the prev_il_instruction->datatype = symbol->datatype;
  1281  *       So, if yoy wish to set the prev_il_instruction->datatype = symbol->datatype;
  1282  *       do it __before__ calling set_il_operand_datatype() (which in turn calls il_operand->accept(*this)) !!
  1282  *       do it __before__ calling set_il_operand_datatype() (which in turn calls il_operand->accept(*this)) !!
  1283  */
  1283  */
       
  1284 int  count = 0;
  1284 void *narrow_candidate_datatypes_c::set_il_operand_datatype(symbol_c *il_operand, symbol_c *datatype) {
  1285 void *narrow_candidate_datatypes_c::set_il_operand_datatype(symbol_c *il_operand, symbol_c *datatype) {
  1285 	if (NULL == il_operand) return NULL; /* if no IL operand => error in the source code!! */
  1286 	if (NULL == il_operand) return NULL; /* if no IL operand => error in the source code!! */
  1286 
  1287 
  1287 	/* If il_operand already has a non-NULL datatype (remember, narrow algorithm runs twice over IL lists!),
  1288 	/* If il_operand already has a non-NULL datatype (remember, narrow algorithm runs twice over IL lists!),
  1288 	 * but narrow algorithm has not yet been able to determine what datatype it should take? This is strange,
  1289 	 * but narrow algorithm has not yet been able to determine what datatype it should take? This is strange,