stage3/fill_candidate_datatypes.cc
changeset 464 319ee8b218f3
parent 462 f7dada0a8952
child 465 b52ec62773db
equal deleted inserted replaced
463:fafa9abc166e 464:319ee8b218f3
   798 /* B 2.1 Instructions and Operands */
   798 /* B 2.1 Instructions and Operands */
   799 /***********************************/
   799 /***********************************/
   800 
   800 
   801 /*| instruction_list il_instruction */
   801 /*| instruction_list il_instruction */
   802 // SYM_LIST(instruction_list_c)
   802 // SYM_LIST(instruction_list_c)
   803 // void *visit(instruction_list_c *symbol);
   803 void *fill_candidate_datatypes_c::visit(instruction_list_c *symbol) {
       
   804 	/* In order to execute the narrow algoritm ll the data type candidates correctly
       
   805 	 * ĩn IL instruction lists containing JMPs to labels that come before the JMP instruction
       
   806 	 * itself, we need to run the fill candidate datatypes algorithm twice on the Instruction List.
       
   807 	 * e.g.:  ...
       
   808 	 *          ld 23
       
   809 	 *   label1:st byte_var
       
   810 	 *          ld 34
       
   811 	 *          JMP label1     
       
   812 	 *
       
   813 	 * Note that the second time we run the algorithm, most of the candidate datatypes are already filled
       
   814 	 * in, so it will be able to produce tha correct candidate datatypes for the IL instruction referenced
       
   815 	 * by the label, as in the 2nd pass we already know the candidate datatypes of the JMP instruction!
       
   816 	 */
       
   817 	for(int j = 0; j < 2; j++) {
       
   818 		for(int i = 0; i < symbol->n; i++) {
       
   819 			symbol->elements[i]->accept(*this);
       
   820 		}
       
   821 	}
       
   822 	return NULL;
       
   823 }
   804 
   824 
   805 
   825 
   806 
   826 
   807 /* | label ':' [il_incomplete_instruction] eol_list */
   827 /* | label ':' [il_incomplete_instruction] eol_list */
   808 // SYM_REF2(il_instruction_c, label, il_instruction)
   828 // SYM_REF2(il_instruction_c, label, il_instruction)