equal
deleted
inserted
replaced
1042 if (symbol->candidate_datatypes.size() != 1) ERROR; |
1042 if (symbol->candidate_datatypes.size() != 1) ERROR; |
1043 symbol_c *current_enumerated_spec_type = symbol->candidate_datatypes[0]; |
1043 symbol_c *current_enumerated_spec_type = symbol->candidate_datatypes[0]; |
1044 |
1044 |
1045 /* We already know the datatype of the enumerated_value(s) in the list, so we set them directly instead of recursively calling the enumerated_value_c visit method! */ |
1045 /* We already know the datatype of the enumerated_value(s) in the list, so we set them directly instead of recursively calling the enumerated_value_c visit method! */ |
1046 for(int i = 0; i < symbol->n; i++) |
1046 for(int i = 0; i < symbol->n; i++) |
1047 add_datatype_to_candidate_list(symbol->elements[i], current_enumerated_spec_type); // top->down algorithm!! |
1047 add_datatype_to_candidate_list(symbol->get_element(i), current_enumerated_spec_type); // top->down algorithm!! |
1048 |
1048 |
1049 return NULL; |
1049 return NULL; |
1050 } |
1050 } |
1051 |
1051 |
1052 |
1052 |
1180 search_varfb_instance_type_c search_varfb_instance_type(symbol->parent->candidate_datatypes[i]); |
1180 search_varfb_instance_type_c search_varfb_instance_type(symbol->parent->candidate_datatypes[i]); |
1181 // flag indicating all struct_elem->structure_element_name are structure elements found in the symbol->parent->candidate_datatypes[i] datatype |
1181 // flag indicating all struct_elem->structure_element_name are structure elements found in the symbol->parent->candidate_datatypes[i] datatype |
1182 int flag_all_elem_ok = 1; // assume all found |
1182 int flag_all_elem_ok = 1; // assume all found |
1183 for (int k = 0; k < symbol->n; k++) { |
1183 for (int k = 0; k < symbol->n; k++) { |
1184 // assume symbol->parent->candidate_datatypes[i] is a FB type... |
1184 // assume symbol->parent->candidate_datatypes[i] is a FB type... |
1185 structure_element_initialization_c *struct_elem = (structure_element_initialization_c *)symbol->elements[k]; |
1185 structure_element_initialization_c *struct_elem = (structure_element_initialization_c *)symbol->get_element(k); |
1186 symbol_c *type = search_varfb_instance_type.get_basetype_decl(struct_elem->structure_element_name); |
1186 symbol_c *type = search_varfb_instance_type.get_basetype_decl(struct_elem->structure_element_name); |
1187 if (!get_datatype_info_c::is_type_valid(type)) { |
1187 if (!get_datatype_info_c::is_type_valid(type)) { |
1188 // either get_datatype_info_c::is_type_valid(type) is not a FB type, or the element is not declared in that FB |
1188 // either get_datatype_info_c::is_type_valid(type) is not a FB type, or the element is not declared in that FB |
1189 // Lets try a struct type!! |
1189 // Lets try a struct type!! |
1190 // TODO... |
1190 // TODO... |
1417 |
1417 |
1418 |
1418 |
1419 |
1419 |
1420 // NOTE: this method is not required since fill_candidate_datatypes_c inherits from iterator_visitor_c. TODO: delete this method! |
1420 // NOTE: this method is not required since fill_candidate_datatypes_c inherits from iterator_visitor_c. TODO: delete this method! |
1421 void *fill_candidate_datatypes_c::visit(var1_list_c *symbol) { |
1421 void *fill_candidate_datatypes_c::visit(var1_list_c *symbol) { |
1422 for(int i = 0; i < symbol->n; i++) {symbol->elements[i]->accept(*this);} |
1422 for(int i = 0; i < symbol->n; i++) {symbol->get_element(i)->accept(*this);} |
1423 return NULL; |
1423 return NULL; |
1424 } |
1424 } |
1425 |
1425 |
1426 |
1426 |
1427 /* AT direct_variable */ |
1427 /* AT direct_variable */ |
1696 * in, so it will be able to produce tha correct candidate datatypes for the IL instruction referenced |
1696 * in, so it will be able to produce tha correct candidate datatypes for the IL instruction referenced |
1697 * by the label, as in the 2nd pass we already know the candidate datatypes of the JMP instruction! |
1697 * by the label, as in the 2nd pass we already know the candidate datatypes of the JMP instruction! |
1698 */ |
1698 */ |
1699 for(int j = 0; j < 2; j++) { |
1699 for(int j = 0; j < 2; j++) { |
1700 for(int i = 0; i < symbol->n; i++) { |
1700 for(int i = 0; i < symbol->n; i++) { |
1701 symbol->elements[i]->accept(*this); |
1701 symbol->get_element(i)->accept(*this); |
1702 } |
1702 } |
1703 } |
1703 } |
1704 return NULL; |
1704 return NULL; |
1705 } |
1705 } |
1706 |
1706 |
1811 * 'LD <il_operand>' IL instruction. |
1811 * 'LD <il_operand>' IL instruction. |
1812 * Just to be cosistent, we will copy the datatype info back into the il_operand, even though this should not be necessary! |
1812 * Just to be cosistent, we will copy the datatype info back into the il_operand, even though this should not be necessary! |
1813 */ |
1813 */ |
1814 if ((NULL != symbol->il_operand) && ((NULL == symbol->simple_instr_list) || (0 == ((list_c *)symbol->simple_instr_list)->n))) ERROR; // stage2 is not behaving as we expect it to! |
1814 if ((NULL != symbol->il_operand) && ((NULL == symbol->simple_instr_list) || (0 == ((list_c *)symbol->simple_instr_list)->n))) ERROR; // stage2 is not behaving as we expect it to! |
1815 if (NULL != symbol->il_operand) |
1815 if (NULL != symbol->il_operand) |
1816 symbol->il_operand->candidate_datatypes = ((list_c *)symbol->simple_instr_list)->elements[0]->candidate_datatypes; |
1816 symbol->il_operand->candidate_datatypes = ((list_c *)symbol->simple_instr_list)->get_element(0)->candidate_datatypes; |
1817 |
1817 |
1818 /* Now check the if the data type semantics of operation are correct, */ |
1818 /* Now check the if the data type semantics of operation are correct, */ |
1819 il_operand = symbol->simple_instr_list; |
1819 il_operand = symbol->simple_instr_list; |
1820 prev_il_instruction = prev_il_instruction_backup; |
1820 prev_il_instruction = prev_il_instruction_backup; |
1821 symbol->il_expr_operator->accept(*this); |
1821 symbol->il_expr_operator->accept(*this); |
1908 void *fill_candidate_datatypes_c::visit(simple_instr_list_c *symbol) { |
1908 void *fill_candidate_datatypes_c::visit(simple_instr_list_c *symbol) { |
1909 if (symbol->n <= 0) |
1909 if (symbol->n <= 0) |
1910 return NULL; /* List is empty! Nothing to do. */ |
1910 return NULL; /* List is empty! Nothing to do. */ |
1911 |
1911 |
1912 for(int i = 0; i < symbol->n; i++) |
1912 for(int i = 0; i < symbol->n; i++) |
1913 symbol->elements[i]->accept(*this); |
1913 symbol->get_element(i)->accept(*this); |
1914 |
1914 |
1915 /* This object has (inherits) the same candidate datatypes as the last il_instruction */ |
1915 /* This object has (inherits) the same candidate datatypes as the last il_instruction */ |
1916 symbol->candidate_datatypes = symbol->elements[symbol->n-1]->candidate_datatypes; |
1916 symbol->candidate_datatypes = symbol->get_element(symbol->n-1)->candidate_datatypes; |
1917 |
1917 |
1918 if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
1918 if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
1919 return NULL; |
1919 return NULL; |
1920 } |
1920 } |
1921 |
1921 |