# HG changeset patch # User Mario de Sousa # Date 1330807368 0 # Node ID 319ee8b218f38f4f1f63fcf2c89733f66c9c54a3 # Parent fafa9abc166e4f6919a34993e7f1f976dc21e101 Handle JMP to labels preceding the JMP instruction itself. diff -r fafa9abc166e -r 319ee8b218f3 stage3/fill_candidate_datatypes.cc --- a/stage3/fill_candidate_datatypes.cc Sat Mar 03 20:27:20 2012 +0000 +++ b/stage3/fill_candidate_datatypes.cc Sat Mar 03 20:42:48 2012 +0000 @@ -800,7 +800,27 @@ /*| instruction_list il_instruction */ // SYM_LIST(instruction_list_c) -// void *visit(instruction_list_c *symbol); +void *fill_candidate_datatypes_c::visit(instruction_list_c *symbol) { + /* In order to execute the narrow algoritm ll the data type candidates correctly + * ĩn IL instruction lists containing JMPs to labels that come before the JMP instruction + * itself, we need to run the fill candidate datatypes algorithm twice on the Instruction List. + * e.g.: ... + * ld 23 + * label1:st byte_var + * ld 34 + * JMP label1 + * + * Note that the second time we run the algorithm, most of the candidate datatypes are already filled + * in, so it will be able to produce tha correct candidate datatypes for the IL instruction referenced + * by the label, as in the 2nd pass we already know the candidate datatypes of the JMP instruction! + */ + for(int j = 0; j < 2; j++) { + for(int i = 0; i < symbol->n; i++) { + symbol->elements[i]->accept(*this); + } + } + return NULL; +} diff -r fafa9abc166e -r 319ee8b218f3 stage3/fill_candidate_datatypes.hh --- a/stage3/fill_candidate_datatypes.hh Sat Mar 03 20:27:20 2012 +0000 +++ b/stage3/fill_candidate_datatypes.hh Sat Mar 03 20:42:48 2012 +0000 @@ -194,7 +194,7 @@ /***********************************/ /* B 2.1 Instructions and Operands */ /***********************************/ - // void *visit(instruction_list_c *symbol); + void *visit(instruction_list_c *symbol); void *visit(il_instruction_c *symbol); void *visit(il_simple_operation_c *symbol); void *visit(il_function_call_c *symbol);