--- a/absyntax_utils/decompose_var_instance_name.cc Tue Dec 15 16:29:44 2009 +0100
+++ b/absyntax_utils/decompose_var_instance_name.cc Tue Dec 15 20:50:30 2009 +0100
@@ -46,21 +46,22 @@
previously_returned_variable_name = NULL;
}
-symbol_c *decompose_var_instance_name_c::next_part(void) {
+symbol_c *decompose_var_instance_name_c::next_part(bool increment) {
/* We must always start from the top!
* See note in the structured_variable_c visitor
* to understand why...
*/
symbol_c *res = (symbol_c *)variable_name->accept(*this);
- next_variable_name = current_recursive_variable_name;
+ if (increment)
+ next_variable_name = current_recursive_variable_name;
if (previously_returned_variable_name == res)
- return NULL;
- previously_returned_variable_name = res;
+ return NULL;
+ if (increment)
+ previously_returned_variable_name = res;
return res;
}
-
/*************************/
/* B.1 - Common elements */
/*************************/
@@ -123,7 +124,7 @@
* so we do not have to recursevily visit it again...
* return (void *)symbol->field_selector->accept(*this); -> NOT REQUIRED!!
*/
- return (void *)symbol->field_selector;
+ return (void *)symbol->field_selector;
}
current_recursive_variable_name = symbol;
--- a/absyntax_utils/decompose_var_instance_name.hh Tue Dec 15 16:29:44 2009 +0100
+++ b/absyntax_utils/decompose_var_instance_name.hh Tue Dec 15 20:50:30 2009 +0100
@@ -53,7 +53,7 @@
public:
decompose_var_instance_name_c(symbol_c *variable_instance_name);
- symbol_c *next_part(void);
+ symbol_c *next_part(bool increment = true);
private:
/*************************/
--- a/absyntax_utils/search_varfb_instance_type.cc Tue Dec 15 16:29:44 2009 +0100
+++ b/absyntax_utils/search_varfb_instance_type.cc Tue Dec 15 20:50:30 2009 +0100
@@ -180,31 +180,12 @@
/* No. It is not a function block, so we let
* the base class take care of it...
*/
- current_structelement_name = decompose_var_instance_name->next_part();
- if (NULL == current_structelement_name) {
- /* this is it... !
- * No need to look any further...
- */
- /* NOTE: we could simply do a
- * return (void *)symbol;
- * nevertheless, note that this search_varfb_instance_type_c
- * class inherits from the search_base_type_c class,
- * which means that it will usually return the base type,
- * and not the derived type (*). If we are to be consistent,
- * we should guarantee that we always return the base type.
- * To do this we could use
- * return (void *)symbol->accept(*this);
- * since this class inherits from the search_base_type_c.
- * However, in this case we don't want it to follow
- * the structs as this search_varfb_instance_type_c does.
- * We therefore have to create a new search_base_type_c
- * instance to search through this type without going
- * through the structs...
- */
+ if (NULL == decompose_var_instance_name->next_part(false)) {
return base_type(type_name);
}
- else
- return search_base_type_c::visit(type_name);
+ else {
+ return search_base_type_c::visit(type_name);
+ }
}
/********************************/
@@ -213,16 +194,17 @@
/* identifier ':' array_spec_init */
void *search_varfb_instance_type_c::visit(array_type_declaration_c *symbol) {
+ this->is_complex = true;
return symbol->array_spec_init->accept(*this);
}
-/* array_specification [ASSIGN array_initialization} */
+/* array_specification [ASSIGN array_initialization] */
/* array_initialization may be NULL ! */
void *search_varfb_instance_type_c::visit(array_spec_init_c *symbol) {
this->is_complex = true;
return symbol->array_specification->accept(*this);
}
-
+
/* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
void *search_varfb_instance_type_c::visit(array_specification_c *symbol) {
this->is_complex = true;
@@ -253,6 +235,9 @@
/* structure_declaration: STRUCT structure_element_declaration_list END_STRUCT */
/* structure_element_declaration_list structure_element_declaration ';' */
void *search_varfb_instance_type_c::visit(structure_element_declaration_list_c *symbol) {
+ /* make sure that we have decomposed all structure elements of the variable name */
+ current_structelement_name = decompose_var_instance_name->next_part();
+ /* now search the structure declaration */
return visit_list(symbol);
}
--- a/stage4/generate_c/generate_c_il.cc Tue Dec 15 16:29:44 2009 +0100
+++ b/stage4/generate_c/generate_c_il.cc Tue Dec 15 20:50:30 2009 +0100
@@ -657,23 +657,27 @@
symbol->subscripted_variable->accept(*this);
break;
case complextype_suffix_vg:
+ symbol->subscripted_variable->accept(*this);
+
current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable);
- symbol->subscripted_variable->accept(*this);
- if (current_array_type != NULL) {
- s4o.print(".table");
- symbol->subscript_list->accept(*this);
- current_array_type = NULL;
- }
+ if (current_array_type == NULL) ERROR;
+
+ s4o.print(".table");
+ symbol->subscript_list->accept(*this);
+
+ current_array_type = NULL;
break;
default:
if (this->is_variable_prefix_null()) {
- current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable);
- symbol->subscripted_variable->accept(*this);
- if (current_array_type != NULL) {
- s4o.print(".table");
- symbol->subscript_list->accept(*this);
- current_array_type = NULL;
- }
+ symbol->subscripted_variable->accept(*this);
+
+ current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable);
+ if (current_array_type == NULL) ERROR;
+
+ s4o.print(".table");
+ symbol->subscript_list->accept(*this);
+
+ current_array_type = NULL;
}
else
print_getter(symbol);
--- a/stage4/generate_c/generate_c_inlinefcall.cc Tue Dec 15 16:29:44 2009 +0100
+++ b/stage4/generate_c/generate_c_inlinefcall.cc Tue Dec 15 20:50:30 2009 +0100
@@ -317,13 +317,15 @@
symbol->subscripted_variable->accept(*this);
break;
case complextype_suffix_vg:
+ symbol->subscripted_variable->accept(*this);
+
current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable);
- symbol->subscripted_variable->accept(*this);
- if (current_array_type != NULL) {
- s4o.print(".table");
- symbol->subscript_list->accept(*this);
- current_array_type = NULL;
- }
+ if (current_array_type == NULL) ERROR;
+
+ s4o.print(".table");
+ symbol->subscript_list->accept(*this);
+
+ current_array_type = NULL;
break;
default:
print_getter(symbol);
--- a/stage4/generate_c/generate_c_st.cc Tue Dec 15 16:29:44 2009 +0100
+++ b/stage4/generate_c/generate_c_st.cc Tue Dec 15 20:50:30 2009 +0100
@@ -292,23 +292,27 @@
symbol->subscripted_variable->accept(*this);
break;
case complextype_suffix_vg:
+ symbol->subscripted_variable->accept(*this);
+
current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable);
- symbol->subscripted_variable->accept(*this);
- if (current_array_type != NULL) {
- s4o.print(".table");
- symbol->subscript_list->accept(*this);
- current_array_type = NULL;
- }
+ if (current_array_type == NULL) ERROR;
+
+ s4o.print(".table");
+ symbol->subscript_list->accept(*this);
+
+ current_array_type = NULL;
break;
default:
if (this->is_variable_prefix_null()) {
+ symbol->subscripted_variable->accept(*this);
+
current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable);
- symbol->subscripted_variable->accept(*this);
- if (current_array_type != NULL) {
- s4o.print(".table");
- symbol->subscript_list->accept(*this);
- current_array_type = NULL;
- }
+ if (current_array_type == NULL) ERROR;
+
+ s4o.print(".table");
+ symbol->subscript_list->accept(*this);
+
+ current_array_type = NULL;
}
else
print_getter(symbol);