963 * Notice that they will be overwriten while processing the parenthsized instruction list. |
963 * Notice that they will be overwriten while processing the parenthsized instruction list. |
964 */ |
964 */ |
965 il_default_variable_c old_implicit_variable_current = this->implicit_variable_current; |
965 il_default_variable_c old_implicit_variable_current = this->implicit_variable_current; |
966 il_default_variable_c old_implicit_variable_result = this->implicit_variable_result; |
966 il_default_variable_c old_implicit_variable_result = this->implicit_variable_result; |
967 |
967 |
968 /* If the symbol->il_operand is not NULL, then we instantiate a 'LD' operation and insert it into the simple_instr_list |
968 /* Stage2 will insert an artificial (and equivalent) LD <il_operand> to the simple_instr_list if necessary. We can therefore ignore the 'il_operand' entry! */ |
969 * (i.e. add an equivalent LD operation to the Abstract Syntax Tree), and let it be handled like any other LD operation! |
969 //if (NULL != symbol->il_operand) { do nothing!! } |
970 */ |
|
971 if (NULL != symbol->il_operand) { |
|
972 tmp_LD_operator = new LD_operator_c(); |
|
973 if (NULL == tmp_LD_operator) ERROR; |
|
974 /* copy all the location, datatpe, etc.. data from symbol->il_operand to the new object! */ |
|
975 *((symbol_c *)tmp_LD_operator) = *(symbol->il_operand); |
|
976 |
|
977 tmp_il_simple_operation = new il_simple_operation_c(tmp_LD_operator, symbol->il_operand); |
|
978 if (NULL == tmp_il_simple_operation) ERROR; |
|
979 /* copy all the location, datatpe, etc.. data from symbol->il_operand to the new object! */ |
|
980 *((symbol_c *)tmp_il_simple_operation) = *(symbol->il_operand); |
|
981 |
|
982 tmp_il_simple_instruction = new il_simple_instruction_c(tmp_il_simple_operation); |
|
983 if (NULL == tmp_il_simple_instruction) ERROR; |
|
984 /* copy all the location, datatpe, etc.. data from symbol->il_operand to the new object! */ |
|
985 *((symbol_c *)tmp_il_simple_instruction) = *(symbol->il_operand); |
|
986 |
|
987 if (NULL == symbol->simple_instr_list) { |
|
988 symbol->simple_instr_list = new simple_instr_list_c(); |
|
989 if (NULL == symbol->simple_instr_list) ERROR; |
|
990 /* copy all the location, datatpe, etc.. data from symbol->il_operand to the new object! */ |
|
991 *((symbol_c *)symbol->simple_instr_list) = *(symbol->il_operand); |
|
992 } |
|
993 list_c *tmp_list = dynamic_cast <list_c *>(symbol->simple_instr_list); |
|
994 if (NULL == tmp_list) ERROR; |
|
995 tmp_list->insert_element(tmp_il_simple_instruction, 0); |
|
996 } |
|
997 |
970 |
998 /* Now do the parenthesised instructions... */ |
971 /* Now do the parenthesised instructions... */ |
999 /* NOTE: the following code line will overwrite the variables implicit_variable_current and implicit_variable_result */ |
972 /* NOTE: the following code line will overwrite the variables implicit_variable_current and implicit_variable_result */ |
1000 symbol->simple_instr_list->accept(*this); |
973 symbol->simple_instr_list->accept(*this); |
1001 |
|
1002 /* delete/undo any changes made to the AST above */ |
|
1003 if (NULL != symbol->il_operand) { |
|
1004 delete tmp_LD_operator; |
|
1005 delete tmp_il_simple_operation; |
|
1006 delete tmp_il_simple_instruction; |
|
1007 list_c *tmp_list = dynamic_cast <list_c *>(symbol->simple_instr_list); |
|
1008 if (NULL == tmp_list) ERROR; |
|
1009 delete tmp_list->elements[0]; |
|
1010 tmp_list->remove_element(0); |
|
1011 if (0 == tmp_list->n) { |
|
1012 delete symbol->simple_instr_list; |
|
1013 symbol->simple_instr_list = NULL; |
|
1014 } |
|
1015 } |
|
1016 |
974 |
1017 /* Now do the operation, using the previous result! */ |
975 /* Now do the operation, using the previous result! */ |
1018 /* NOTE: The result of the previous instruction list in the parenthesis will be stored |
976 /* NOTE: The result of the previous instruction list in the parenthesis will be stored |
1019 * in a variable named IL_DEFVAR_BACK. This is done in the visitor |
977 * in a variable named IL_DEFVAR_BACK. This is done in the visitor |
1020 * to instruction_list_c objects... |
978 * to instruction_list_c objects... |