--- a/stage3/narrow_candidate_datatypes.cc Mon Apr 03 18:30:50 2017 +0100
+++ b/stage3/narrow_candidate_datatypes.cc Mon Apr 03 22:06:40 2017 +0100
@@ -672,11 +672,29 @@
/* structure_initialization: '(' structure_element_initialization_list ')' */
/* structure_element_initialization_list ',' structure_element_initialization */
// SYM_LIST(structure_element_initialization_list_c)
-// Not needed ???
+void *narrow_candidate_datatypes_c::visit(structure_element_initialization_list_c *symbol) {
+ if (get_datatype_info_c::is_type_valid(symbol->datatype)) {
+ /* Note that in principle structure_element_initialization_list_c will have at most 1 candidate_datatype
+ * (the FB or structure in the type specification). However, our algorithm is more generic and will
+ * assume that more than 1 candidate_datatype is possible. In this case we need to iterate and check each
+ * candidate_datatype whether it is feasible, as they may all be feasible but not for the same ...
+ */
+ // assume symbol->datatype is a FB type
+ search_varfb_instance_type_c search_varfb_instance_type(symbol->datatype);
+ for (int k = 0; k < symbol->n; k++) {
+ structure_element_initialization_c *struct_elem = (structure_element_initialization_c *)symbol->elements[k];
+ symbol_c *type = search_varfb_instance_type.get_basetype_decl(struct_elem->structure_element_name);
+ set_datatype(type, struct_elem);
+ struct_elem->accept(*this);
+ if (struct_elem->datatype == NULL) ERROR; // should never occur. Already checked in fill_candidate_datatypes_c
+ }
+ }
+ return NULL;
+}
/* structure_element_name ASSIGN value */
// SYM_REF2(structure_element_initialization_c, structure_element_name, value)
-// Not needed ???
+void *narrow_candidate_datatypes_c::visit(structure_element_initialization_c *symbol) {set_datatype(symbol->datatype, symbol->value); return NULL;}
/* string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */
// SYM_REF4(string_type_declaration_c, string_type_name, elementary_string_type_name, string_type_declaration_size, string_type_declaration_init/* may be == NULL! */)