stage3/narrow_candidate_datatypes.cc
changeset 444 92d40d2a7adc
parent 443 ff4d26b7e51d
child 445 e6c34ee82954
equal deleted inserted replaced
443:ff4d26b7e51d 444:92d40d2a7adc
   413 	symbol->il_instruction->accept(*this);
   413 	symbol->il_instruction->accept(*this);
   414 	return NULL;
   414 	return NULL;
   415 }
   415 }
   416 
   416 
   417 
   417 
       
   418 
       
   419 
       
   420 /*************************************************************************************************/
       
   421 /* Important NOTE:                                                                               */
       
   422 /*                                                                                               */
       
   423 /*   The visit() methods for all the IL instructions must be idem-potent, as they may            */
       
   424 /*   potentially be called twice to narrow the same object. In other words, they may be called   */
       
   425 /*   to narrow an object that has already been previously narrowed.                              */
       
   426 /*   This occurs when that IL instruction imediately precedes an IL non-formal function          */
       
   427 /*   invocation:                                                                                 */
       
   428 /*      LD 45.5                                                                                  */
       
   429 /*      SIN                                                                                      */
       
   430 /*                                                                                               */
       
   431 /*   In the above case, 'LD 45.5' will be narrowed once when the code that handles the           */
       
   432 /*   SIN function call                                                                           */
       
   433 /*                                                                                               */
       
   434 /*   narrow_nonformal_call(...), which is called by narrow_function_invocation(...), which is    */
       
   435 /*   in turn called by visit(il_function_call_c *)                                               */
       
   436 /*                                                                                               */
       
   437 /*   calls the call_param_value->accept(*this), where call_param_value will be a pointer         */
       
   438 /*   to the preceding IL instruction (in the above case, 'LD 45.5').                             */
       
   439 /*                                                                                               */
       
   440 /*   That same IL instruction will be again narrowed when called by the for() loop in            */
       
   441 /*   the visit(instruction_list_c *) visitor method.                                             */
       
   442 /*************************************************************************************************/
       
   443  
       
   444 
       
   445 
       
   446 
       
   447 
   418 // void *visit(instruction_list_c *symbol);
   448 // void *visit(instruction_list_c *symbol);
   419 void *narrow_candidate_datatypes_c::visit(il_simple_operation_c *symbol) {
   449 void *narrow_candidate_datatypes_c::visit(il_simple_operation_c *symbol) {
   420 	/* Tell the il_simple_operator the datatype that it must generate - this was chosen by the next il_instruction (we iterate backwards!) */
   450 	/* Tell the il_simple_operator the datatype that it must generate - this was chosen by the next il_instruction (we iterate backwards!) */
   421 	symbol->il_simple_operator->datatype = symbol->datatype;
   451 	symbol->il_simple_operator->datatype = symbol->datatype;
   422 	/* recursive call to see whether data types are compatible */
   452 	/* recursive call to see whether data types are compatible */