Access elements[] in list_c through a new get_element() method.
authorMario de Sousa <msousa@fe.up.pt>
Mon, 03 Apr 2017 22:18:22 +0100
changeset 1041 56ebe2a31b5b
parent 1040 e8563dcaefca
child 1042 6d1cdb7da363
Access elements[] in list_c through a new get_element() method.
absyntax/absyntax.cc
absyntax/absyntax.hh
absyntax/visitor.cc
absyntax/visitor.hh
absyntax_utils/add_en_eno_param_decl.cc
absyntax_utils/add_en_eno_param_decl.hh
absyntax_utils/array_dimension_iterator.cc
absyntax_utils/array_dimension_iterator.hh
absyntax_utils/case_element_iterator.cc
absyntax_utils/case_element_iterator.hh
absyntax_utils/decompose_var_instance_name.cc
absyntax_utils/decompose_var_instance_name.hh
absyntax_utils/function_call_iterator.cc
absyntax_utils/function_call_iterator.hh
absyntax_utils/function_call_param_iterator.cc
absyntax_utils/function_call_param_iterator.hh
absyntax_utils/function_param_iterator.cc
absyntax_utils/function_param_iterator.hh
absyntax_utils/get_datatype_info.cc
absyntax_utils/get_sizeof_datatype.cc
absyntax_utils/get_sizeof_datatype.hh
absyntax_utils/search_base_type.cc
absyntax_utils/search_base_type.hh
absyntax_utils/search_fb_instance_decl.cc
absyntax_utils/search_fb_instance_decl.hh
absyntax_utils/search_fb_typedecl.cc
absyntax_utils/search_fb_typedecl.hh
absyntax_utils/search_var_instance_decl.cc
absyntax_utils/search_varfb_instance_type.cc
absyntax_utils/search_varfb_instance_type.hh
absyntax_utils/spec_init_separator.cc
absyntax_utils/spec_init_separator.hh
absyntax_utils/type_initial_value.cc
absyntax_utils/type_initial_value.hh
main.cc
stage1_2/create_enumtype_conversion_functions.cc
stage1_2/iec_bison.yy
stage1_2/stage1_2.cc
stage1_2/stage1_2.hh
stage1_2/stage1_2_priv.hh
stage3/array_range_check.cc
stage3/case_elements_check.cc
stage3/constant_folding.cc
stage3/fill_candidate_datatypes.cc
stage3/fill_candidate_datatypes.hh
stage3/flow_control_analysis.cc
stage3/forced_narrow_candidate_datatypes.cc
stage3/narrow_candidate_datatypes.cc
stage3/narrow_candidate_datatypes.hh
stage3/print_datatypes_error.cc
stage3/print_datatypes_error.hh
stage3/remove_forward_dependencies.cc
stage3/stage3.cc
stage3/stage3.hh
stage4/generate_c/generate_c.cc
stage4/generate_c/generate_c.hh
stage4/generate_c/generate_c_base.cc
stage4/generate_c/generate_c_configbody.cc
stage4/generate_c/generate_c_il.cc
stage4/generate_c/generate_c_inlinefcall.cc
stage4/generate_c/generate_c_sfc.cc
stage4/generate_c/generate_c_sfcdecl.cc
stage4/generate_c/generate_c_st.cc
stage4/generate_c/generate_c_typedecl.cc
stage4/generate_c/generate_c_vardecl.cc
stage4/generate_c/generate_location_list.cc
stage4/generate_c/generate_var_list.cc
stage4/generate_iec/generate_iec.cc
stage4/generate_iec/generate_iec.hh
stage4/stage4.hh
util/dsymtable.cc
util/dsymtable.hh
util/strdup.hh
util/symtable.cc
util/symtable.hh
--- a/absyntax/absyntax.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax/absyntax.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -99,6 +99,9 @@
 }
 
 
+/* get element in position pos of the list */
+symbol_c *list_c::get_element(int pos) {return elements[pos];}
+
 /* append a new element to the end of the list */
 void list_c::add_element(symbol_c *elem) {
   // printf("list_c::add_element()\n");
--- a/absyntax/absyntax.hh	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax/absyntax.hh	Mon Apr 03 22:18:22 2017 +0100
@@ -260,6 +260,7 @@
     virtual const char *absyntax_cname(void) {return "list_c";};
 
     int c,n; /* c: current capacity of list (malloc'd memory);  n: current number of elements in list */
+  private:
     symbol_c **elements;
 
   public:
@@ -271,6 +272,8 @@
            int fl = 0, int fc = 0, const char *ffile = NULL /* filename */, long int forder=0, /* order in which it is read by lexcial analyser */
            int ll = 0, int lc = 0, const char *lfile = NULL /* filename */, long int lorder=0  /* order in which it is read by lexcial analyser */
           );
+     /* get element in position pos of the list */
+    virtual symbol_c *get_element(int pos);
      /* append a new element to the end of the list */
     virtual void add_element(symbol_c *elem);
      /* insert a new element before position pos. */
--- a/absyntax/visitor.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax/visitor.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -168,7 +168,7 @@
 
 void *iterator_visitor_c::visit_list(list_c *list) {
   for(int i = 0; i < list->n; i++) {
-    list->elements[i]->accept(*this);
+    list->get_element(i)->accept(*this);
   }
   return NULL;
 }
@@ -310,7 +310,7 @@
 
 void *search_visitor_c::visit_list(list_c *list) {
   for(int i = 0; i < list->n; i++) {
-    void *res = list->elements[i]->accept(*this);
+    void *res = list->get_element(i)->accept(*this);
     if (res != NULL)
       return res;
   }
--- a/absyntax_utils/add_en_eno_param_decl.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/add_en_eno_param_decl.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -84,7 +84,7 @@
 
 void* add_en_eno_param_decl_c::iterate_list(list_c *list) {
   for (int i = 0; i < list->n; i++) {
-    list->elements[i]->accept(*this);
+    list->get_element(i)->accept(*this);
   }
   return NULL;
 }
--- a/absyntax_utils/array_dimension_iterator.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/array_dimension_iterator.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -64,7 +64,7 @@
 void* array_dimension_iterator_c::iterate_list(list_c *list) {
   void *res;
   for (int i = 0; i < list->n; i++) {
-    res = list->elements[i]->accept(*this);
+    res = list->get_element(i)->accept(*this);
     if (res != NULL)
         return res;
   }
--- a/absyntax_utils/case_element_iterator.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/case_element_iterator.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -78,7 +78,7 @@
 void* case_element_iterator_c::iterate_list(list_c *list) {
   void *res;
   for (int i = 0; i < list->n; i++) {
-    res = list->elements[i]->accept(*this);
+    res = list->get_element(i)->accept(*this);
     if (res != NULL)
         return res;
   }
--- a/absyntax_utils/function_call_param_iterator.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/function_call_param_iterator.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -67,7 +67,7 @@
   switch (current_operation) {
     case iterate_nf_op:
       for(int i = 0; i < list->n; i++) {
-        void *res = list->elements[i]->accept(*this);
+        void *res = list->get_element(i)->accept(*this);
         if (NULL != res) {
           /* It went through the handle_parameter_assignment() function,
            * and is therefore a parameter assignment (<param> = <value>),
@@ -77,7 +77,7 @@
         } else {
           param_count++;
           if (param_count == iterate_nf_next_param) {
-            return list->elements[i];
+            return list->get_element(i);
           }
         }
       }
@@ -86,7 +86,7 @@
 
     case iterate_f_op:
       for(int i = 0; i < list->n; i++) {
-        void *res = list->elements[i]->accept(*this);
+        void *res = list->get_element(i)->accept(*this);
         if (NULL != res) {
           /* It went through the handle_parameter_assignment() function,
            * and is therefore a parameter assignment (<param> = <value>),
@@ -105,7 +105,7 @@
 
     case search_f_op:
       for(int i = 0; i < list->n; i++) {
-        void *res = list->elements[i]->accept(*this);
+        void *res = list->get_element(i)->accept(*this);
         if (res != NULL)
           return res;
       }
--- a/absyntax_utils/function_param_iterator.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/function_param_iterator.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -167,7 +167,7 @@
   switch (current_operation) {
     case iterate_op:
       if (next_param <= param_count + list->n)
-        return list->elements[next_param - param_count - 1];
+        return list->get_element(next_param - param_count - 1);
 
       /* the desired param is not on this list... */
       param_count += list->n;
@@ -175,7 +175,7 @@
 
     case search_op:
       for(int i = 0; i < list->n; i++) {
-        symbol_c *sym = list->elements[i];
+        symbol_c *sym = list->get_element(i);
         extensible_input_parameter_c *extensible_parameter = dynamic_cast<extensible_input_parameter_c *>(sym);
         if (extensible_parameter != NULL) {
           sym = extensible_parameter->var_name;
@@ -243,7 +243,7 @@
 void* function_param_iterator_c::iterate_list(list_c *list) {
   void *res;
   for (int i = 0; i < list->n; i++) {
-    res = list->elements[i]->accept(*this);
+    res = list->get_element(i)->accept(*this);
     if (res != NULL)
         return res;
   }
--- a/absyntax_utils/get_datatype_info.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/get_datatype_info.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -362,7 +362,7 @@
     void *visit(structure_element_declaration_list_c *symbol) {
       /* now search the structure declaration */
       for(int i = 0; i < symbol->n; i++) {
-        void *tmp = symbol->elements[i]->accept(*this);
+        void *tmp = symbol->get_element(i)->accept(*this);
         if (NULL != tmp) return tmp;
       }
       return NULL; // not found!!
@@ -713,8 +713,8 @@
   
   // comparison of each subrange start and end elements
   for (int i = 0; i < subrange_list_1->n; i++) {
-    subrange_c *subrange_1 = dynamic_cast<subrange_c *>(subrange_list_1->elements[i]);
-    subrange_c *subrange_2 = dynamic_cast<subrange_c *>(subrange_list_2->elements[i]);
+    subrange_c *subrange_1 = dynamic_cast<subrange_c *>(subrange_list_1->get_element(i));
+    subrange_c *subrange_2 = dynamic_cast<subrange_c *>(subrange_list_2->get_element(i));
     if ((NULL == subrange_1) || (NULL == subrange_2)) ERROR;
     
     /* check whether the subranges have the same values, using the result of the constant folding agorithm.
--- a/absyntax_utils/search_fb_instance_decl.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/search_fb_instance_decl.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -95,7 +95,7 @@
 void *search_fb_instance_decl_c::visit(fb_name_list_c *symbol) {
   list_c *list = symbol;
   for(int i = 0; i < list->n; i++) {
-    if (compare_identifiers(list->elements[i], search_name) == 0)
+    if (compare_identifiers(list->get_element(i), search_name) == 0)
   /* by now, current_fb_declaration should be != NULL */
       return current_fb_type_name;
   }
--- a/absyntax_utils/search_var_instance_decl.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/search_var_instance_decl.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -313,7 +313,7 @@
 void *search_var_instance_decl_c::visit(var1_list_c *symbol) {
   list_c *list = symbol;
   for(int i = 0; i < list->n; i++) {
-    if (compare_identifiers(list->elements[i], search_name) == 0)
+    if (compare_identifiers(list->get_element(i), search_name) == 0)
    /* by now, current_type_decl should be != NULL */
       return current_type_decl;
   }
@@ -335,7 +335,7 @@
 void *search_var_instance_decl_c::visit(fb_name_list_c *symbol) {
   list_c *list = symbol;
   for(int i = 0; i < list->n; i++) {
-    if (compare_identifiers(list->elements[i], search_name) == 0)
+    if (compare_identifiers(list->get_element(i), search_name) == 0)
     /* by now, current_fb_declaration should be != NULL */
       return current_type_decl;
   }
@@ -409,7 +409,7 @@
 void *search_var_instance_decl_c::visit(global_var_list_c *symbol) {
   list_c *list = symbol;
   for(int i = 0; i < list->n; i++) {
-    if (compare_identifiers(list->elements[i], search_name) == 0)
+    if (compare_identifiers(list->get_element(i), search_name) == 0)
       /* by now, current_type_decl should be != NULL */
       return current_type_decl;
   }
--- a/absyntax_utils/search_varfb_instance_type.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/search_varfb_instance_type.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -244,7 +244,7 @@
 
   /* now search the structure declaration */
   for(int i = 0; i < symbol->n; i++) {
-    symbol->elements[i]->accept(*this);
+    symbol->get_element(i)->accept(*this);
   }
 
   return NULL;
--- a/absyntax_utils/type_initial_value.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/absyntax_utils/type_initial_value.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -224,7 +224,7 @@
   /* stage1_2 never creates an enumerated_value_list_c with no entries. If this occurs, then something must have changed! */
   if (symbol->n <= 0) ERROR;
  /* if no initial value explicitly given, then use the lowest value of the subrange */
-  return (void *)symbol->elements[0];
+  return (void *)symbol->get_element(0);
 }
 /* enumerated_type_name '#' identifier */
 // SYM_REF2(enumerated_value_c, type, value)
--- a/stage1_2/create_enumtype_conversion_functions.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage1_2/create_enumtype_conversion_functions.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -119,7 +119,7 @@
     currentTokenList.clear();
     list = (list_c *)symbol;
     for (int i = 0; i < list->n; i++) {
-        list->elements[i]->accept(*this);
+        list->get_element(i)->accept(*this);
         currentTokenList.push_back(currentToken);
     }
 
--- a/stage1_2/iec_bison.yy	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage1_2/iec_bison.yy	Mon Apr 03 22:18:22 2017 +0100
@@ -119,7 +119,7 @@
 #define FOR_EACH_ELEMENT(elem, list, code) {		\
   symbol_c *elem;					\
   for(int i = 0; i < list->n; i++) {			\
-    elem = list->elements[i];				\
+    elem = list->get_element(i);			\
     code;						\
   }							\
 }
--- a/stage3/array_range_check.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/array_range_check.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -133,38 +133,38 @@
       return;
 
     /* Check lower limit */
-    if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE( int64, dimension->lower_limit))
-      if ( GET_CVALUE( int64, l->elements[i]) < GET_CVALUE( int64, dimension->lower_limit) )
-      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRId64", should be >= %"PRId64").", GET_CVALUE( int64, l->elements[i]), GET_CVALUE( int64, dimension->lower_limit)); continue;}
-
-    if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE(uint64, dimension->lower_limit))
-      if ( cmp_unsigned_signed( GET_CVALUE(uint64, dimension->lower_limit), GET_CVALUE( int64, l->elements[i])) > 0 )
-      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRId64", should be >= %"PRIu64").", GET_CVALUE( int64, l->elements[i]), GET_CVALUE(uint64, dimension->lower_limit)); continue;}
-
-    if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE(uint64, dimension->lower_limit))
-      if ( GET_CVALUE(uint64, l->elements[i])   <  GET_CVALUE(uint64, dimension->lower_limit))
-      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRIu64", should be >= %"PRIu64").", GET_CVALUE(uint64, l->elements[i]), GET_CVALUE(uint64, dimension->lower_limit)); continue;}
-
-    if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE( int64, dimension->lower_limit))
-      if ( cmp_unsigned_signed(GET_CVALUE(uint64, l->elements[i]), GET_CVALUE( int64, dimension->lower_limit)) < 0 )
-      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRIu64", should be >= %"PRId64").", GET_CVALUE(uint64, l->elements[i]), GET_CVALUE( int64, dimension->lower_limit)); continue;}
+    if ( VALID_CVALUE( int64, l->get_element(i)) && VALID_CVALUE( int64, dimension->lower_limit))
+      if ( GET_CVALUE( int64, l->get_element(i)) < GET_CVALUE( int64, dimension->lower_limit) )
+      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRId64", should be >= %"PRId64").", GET_CVALUE( int64, l->get_element(i)), GET_CVALUE( int64, dimension->lower_limit)); continue;}
+
+    if ( VALID_CVALUE( int64, l->get_element(i)) && VALID_CVALUE(uint64, dimension->lower_limit))
+      if ( cmp_unsigned_signed( GET_CVALUE(uint64, dimension->lower_limit), GET_CVALUE( int64, l->get_element(i))) > 0 )
+      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRId64", should be >= %"PRIu64").", GET_CVALUE( int64, l->get_element(i)), GET_CVALUE(uint64, dimension->lower_limit)); continue;}
+
+    if ( VALID_CVALUE(uint64, l->get_element(i)) && VALID_CVALUE(uint64, dimension->lower_limit))
+      if ( GET_CVALUE(uint64, l->get_element(i))   <  GET_CVALUE(uint64, dimension->lower_limit))
+      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRIu64", should be >= %"PRIu64").", GET_CVALUE(uint64, l->get_element(i)), GET_CVALUE(uint64, dimension->lower_limit)); continue;}
+
+    if ( VALID_CVALUE(uint64, l->get_element(i)) && VALID_CVALUE( int64, dimension->lower_limit))
+      if ( cmp_unsigned_signed(GET_CVALUE(uint64, l->get_element(i)), GET_CVALUE( int64, dimension->lower_limit)) < 0 )
+      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRIu64", should be >= %"PRId64").", GET_CVALUE(uint64, l->get_element(i)), GET_CVALUE( int64, dimension->lower_limit)); continue;}
 
     /* Repeat the same check, now for upper limit */
-    if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE( int64, dimension->upper_limit))
-      if ( GET_CVALUE( int64, l->elements[i])   >  GET_CVALUE( int64, dimension->upper_limit))
-      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRId64", should be <= %"PRId64").", GET_CVALUE( int64, l->elements[i]), GET_CVALUE( int64, dimension->upper_limit)); continue;}
-
-    if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE(uint64, dimension->upper_limit))
-      if ( cmp_unsigned_signed( GET_CVALUE(uint64, dimension->upper_limit), GET_CVALUE( int64, l->elements[i])) < 0 )
-      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRId64", should be <= %"PRIu64").", GET_CVALUE( int64, l->elements[i]), GET_CVALUE(uint64, dimension->upper_limit)); continue;}
-
-    if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE(uint64, dimension->upper_limit))
-      if ( GET_CVALUE(uint64, l->elements[i])   >  GET_CVALUE(uint64, dimension->upper_limit))
-      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRIu64", should be <= %"PRIu64").", GET_CVALUE(uint64, l->elements[i]), GET_CVALUE(uint64, dimension->upper_limit)); continue;}
+    if ( VALID_CVALUE( int64, l->get_element(i)) && VALID_CVALUE( int64, dimension->upper_limit))
+      if ( GET_CVALUE( int64, l->get_element(i))   >  GET_CVALUE( int64, dimension->upper_limit))
+      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRId64", should be <= %"PRId64").", GET_CVALUE( int64, l->get_element(i)), GET_CVALUE( int64, dimension->upper_limit)); continue;}
+
+    if ( VALID_CVALUE( int64, l->get_element(i)) && VALID_CVALUE(uint64, dimension->upper_limit))
+      if ( cmp_unsigned_signed( GET_CVALUE(uint64, dimension->upper_limit), GET_CVALUE( int64, l->get_element(i))) < 0 )
+      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRId64", should be <= %"PRIu64").", GET_CVALUE( int64, l->get_element(i)), GET_CVALUE(uint64, dimension->upper_limit)); continue;}
+
+    if ( VALID_CVALUE(uint64, l->get_element(i)) && VALID_CVALUE(uint64, dimension->upper_limit))
+      if ( GET_CVALUE(uint64, l->get_element(i))   >  GET_CVALUE(uint64, dimension->upper_limit))
+      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRIu64", should be <= %"PRIu64").", GET_CVALUE(uint64, l->get_element(i)), GET_CVALUE(uint64, dimension->upper_limit)); continue;}
       
-    if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE( int64, dimension->upper_limit))
-      if ( cmp_unsigned_signed(GET_CVALUE(uint64, l->elements[i]), GET_CVALUE( int64, dimension->upper_limit)) > 0 )
-      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRIu64", should be <= %"PRId64").", GET_CVALUE(uint64, l->elements[i]), GET_CVALUE( int64, dimension->upper_limit)); continue;}
+    if ( VALID_CVALUE(uint64, l->get_element(i)) && VALID_CVALUE( int64, dimension->upper_limit))
+      if ( cmp_unsigned_signed(GET_CVALUE(uint64, l->get_element(i)), GET_CVALUE( int64, dimension->upper_limit)) > 0 )
+      {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (using constant value of %"PRIu64", should be <= %"PRId64").", GET_CVALUE(uint64, l->get_element(i)), GET_CVALUE( int64, dimension->upper_limit)); continue;}
       
   }
 }
--- a/stage3/case_elements_check.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/case_elements_check.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -242,7 +242,7 @@
 // SYM_LIST(case_list_c)
 void *case_elements_check_c::visit(case_list_c *symbol) {
   for (int i = 0; i < symbol->n; i++)
-    case_elements_list.push_back(symbol->elements[i]);
+    case_elements_list.push_back(symbol->get_element(i));
   return NULL;
 }
 
--- a/stage3/constant_folding.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/constant_folding.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -1038,7 +1038,7 @@
    */
   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!
   if  (NULL != symbol->il_operand)
-    symbol->il_operand->const_value = ((list_c *)symbol->simple_instr_list)->elements[0]->const_value;
+    symbol->il_operand->const_value = ((list_c *)symbol->simple_instr_list)->get_element(0)->const_value;
 
   return NULL;
 }
@@ -1089,10 +1089,10 @@
     return NULL;  /* List is empty! Nothing to do. */
     
   for(int i = 0; i < symbol->n; i++)
-    symbol->elements[i]->accept(*this);
+    symbol->get_element(i)->accept(*this);
 
   /* This object has (inherits) the same cvalues as the il_jump_operator */
-  symbol->const_value = symbol->elements[symbol->n-1]->const_value;
+  symbol->const_value = symbol->get_element(symbol->n-1)->const_value;
   return NULL;
 }
 
@@ -1367,8 +1367,8 @@
   
   for (i = 0; i < symbol->n; i++) {
     // first analyse the configurations
-    if (NULL != dynamic_cast<configuration_declaration_c *>(symbol->elements[i]))
-      symbol->elements[i]->accept(*this);
+    if (NULL != dynamic_cast<configuration_declaration_c *>(symbol->get_element(i)))
+      symbol->get_element(i)->accept(*this);
   }
 
   for (i = 0; i < symbol->n; i++) {
@@ -1377,8 +1377,8 @@
      *       loop. However, this is OK as the only difference would be how the VAR_EXTERN are handled,
      *       and that is taken care of in the visit(external_declaration_c) visitor!
      */
-    if (NULL == dynamic_cast<configuration_declaration_c *>(symbol->elements[i]))
-      symbol->elements[i]->accept(*this);
+    if (NULL == dynamic_cast<configuration_declaration_c *>(symbol->get_element(i)))
+      symbol->get_element(i)->accept(*this);
   }
   
   return NULL;
@@ -1465,14 +1465,14 @@
   list_c *list = dynamic_cast<list_c *>(var_list);
   if (NULL == list) ERROR;
   for (int i = 0; i < list->n; i++) {
-    token_c *var_name = dynamic_cast<token_c *>(list->elements[i]);
+    token_c *var_name = dynamic_cast<token_c *>(list->get_element(i));
     if (NULL == var_name) {
-      if (NULL != dynamic_cast<extensible_input_parameter_c *>(list->elements[i]))
+      if (NULL != dynamic_cast<extensible_input_parameter_c *>(list->get_element(i)))
         continue; // this is an extensible standard function. Ignore this variable, and continue!
-      // debug_c::print(list->elements[i]);
+      // debug_c::print(list->get_element(i));
       ERROR;
     }
-    list->elements[i]->const_value = init_value->const_value;
+    list->get_element(i)->const_value = init_value->const_value;
     if (fixed_init_value_) {
       (*values)[var_name->value] = init_value->const_value;
       if (is_global_var)
--- a/stage3/fill_candidate_datatypes.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/fill_candidate_datatypes.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -1044,7 +1044,7 @@
   
   /* 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! */
   for(int i = 0; i < symbol->n; i++)
-    add_datatype_to_candidate_list(symbol->elements[i], current_enumerated_spec_type); // top->down algorithm!!
+    add_datatype_to_candidate_list(symbol->get_element(i), current_enumerated_spec_type); // top->down algorithm!!
 
   return NULL;  
 }
@@ -1182,7 +1182,7 @@
 		int flag_all_elem_ok = 1; // assume all found
 		for (int k = 0; k < symbol->n; k++) {
 			// assume symbol->parent->candidate_datatypes[i] is a FB type...
-			structure_element_initialization_c *struct_elem = (structure_element_initialization_c *)symbol->elements[k];
+			structure_element_initialization_c *struct_elem = (structure_element_initialization_c *)symbol->get_element(k);
 			symbol_c *type = search_varfb_instance_type.get_basetype_decl(struct_elem->structure_element_name);
 			if (!get_datatype_info_c::is_type_valid(type)) {
 				// either get_datatype_info_c::is_type_valid(type) is not a FB type, or the element is not declared in that FB
@@ -1419,7 +1419,7 @@
 
 // NOTE: this method is not required since fill_candidate_datatypes_c inherits from iterator_visitor_c. TODO: delete this method!
 void *fill_candidate_datatypes_c::visit(var1_list_c *symbol) {
-  for(int i = 0; i < symbol->n; i++) {symbol->elements[i]->accept(*this);}
+  for(int i = 0; i < symbol->n; i++) {symbol->get_element(i)->accept(*this);}
   return NULL;
 }  
 
@@ -1698,7 +1698,7 @@
 	 */
 	for(int j = 0; j < 2; j++) {
 		for(int i = 0; i < symbol->n; i++) {
-			symbol->elements[i]->accept(*this);
+			symbol->get_element(i)->accept(*this);
 		}
 	}
 	return NULL;
@@ -1813,7 +1813,7 @@
    */
   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!
   if  (NULL != symbol->il_operand)
-    symbol->il_operand->candidate_datatypes = ((list_c *)symbol->simple_instr_list)->elements[0]->candidate_datatypes;
+    symbol->il_operand->candidate_datatypes = ((list_c *)symbol->simple_instr_list)->get_element(0)->candidate_datatypes;
   
   /* Now check the if the data type semantics of operation are correct,  */
   il_operand = symbol->simple_instr_list;
@@ -1910,10 +1910,10 @@
     return NULL;  /* List is empty! Nothing to do. */
     
   for(int i = 0; i < symbol->n; i++)
-    symbol->elements[i]->accept(*this);
+    symbol->get_element(i)->accept(*this);
 
   /* This object has (inherits) the same candidate datatypes as the last il_instruction */
-  symbol->candidate_datatypes = symbol->elements[symbol->n-1]->candidate_datatypes;
+  symbol->candidate_datatypes = symbol->get_element(symbol->n-1)->candidate_datatypes;
   
   if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n";
   return NULL;
--- a/stage3/flow_control_analysis.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/flow_control_analysis.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -218,8 +218,8 @@
 	prev_il_instruction_is_JMP_or_RET = false;
 	for(int i = 0; i < symbol->n; i++) {
 		prev_il_instruction = NULL;
-		if (i > 0) prev_il_instruction = symbol->elements[i-1];
-		curr_il_instruction = symbol->elements[i];
+		if (i > 0) prev_il_instruction = symbol->get_element(i-1);
+		curr_il_instruction = symbol->get_element(i);
 		curr_il_instruction->accept(*this);
 		curr_il_instruction = NULL;
 	}
@@ -310,8 +310,8 @@
 void *flow_control_analysis_c::visit(simple_instr_list_c *symbol) {
 	for(int i = 0; i < symbol->n; i++) {
 		/* The prev_il_instruction for element[0] was set in visit(il_expression_c *) */
-		if (i>0) prev_il_instruction = symbol->elements[i-1];
-		symbol->elements[i]->accept(*this);
+		if (i>0) prev_il_instruction = symbol->get_element(i-1);
+		symbol->get_element(i)->accept(*this);
 	}
 	return NULL;
 }
--- a/stage3/forced_narrow_candidate_datatypes.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/forced_narrow_candidate_datatypes.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -161,7 +161,7 @@
 void *forced_narrow_candidate_datatypes_c::visit(instruction_list_c *symbol) {
   for(int j = 0; j < 2; j++) {
     for(int i = symbol->n-1; i >= 0; i--) {
-      symbol->elements[i]->accept(*this);
+      symbol->get_element(i)->accept(*this);
     }
   }
 
@@ -171,7 +171,7 @@
    */
   /*
   for(int i = symbol->n-1; i >= 0; i--) {
-    if (NULL == symbol->elements[i]->datatype)
+    if (NULL == symbol->get_element(i)->datatype)
       ERROR;
   }
   */
--- a/stage3/narrow_candidate_datatypes.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/narrow_candidate_datatypes.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -609,8 +609,8 @@
 // SYM_LIST(enumerated_value_list_c)
 void *narrow_candidate_datatypes_c::visit(enumerated_value_list_c *symbol) {
 //if (NULL == symbol->datatype) ERROR;  // Comented out-> Reserve this check for the print_datatypes_error_c ???  
-  for(int i = 0; i < symbol->n; i++) set_datatype(symbol->datatype, symbol->elements[i]);
-//for(int i = 0; i < symbol->n; i++) if (NULL == symbol->elements[i]->datatype) ERROR; // Comented out-> Reserve this check for the print_datatypes_error_c ???  
+  for(int i = 0; i < symbol->n; i++) set_datatype(symbol->datatype, symbol->get_element(i));
+//for(int i = 0; i < symbol->n; i++) if (NULL == symbol->get_element(i)->datatype) ERROR; // Comented out-> Reserve this check for the print_datatypes_error_c ???  
   return NULL;  
 }
 
@@ -682,7 +682,7 @@
 		// 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];
+			structure_element_initialization_c *struct_elem = (structure_element_initialization_c *)symbol->get_element(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);
@@ -772,11 +772,11 @@
 // SYM_LIST(subscript_list_c)
 void *narrow_candidate_datatypes_c::visit(subscript_list_c *symbol) {
 	for (int i = 0; i < symbol->n; i++) {
-		for (unsigned int k = 0; k < symbol->elements[i]->candidate_datatypes.size(); k++) {
-			if (get_datatype_info_c::is_ANY_INT(symbol->elements[i]->candidate_datatypes[k]))
-				symbol->elements[i]->datatype = symbol->elements[i]->candidate_datatypes[k];
+		for (unsigned int k = 0; k < symbol->get_element(i)->candidate_datatypes.size(); k++) {
+			if (get_datatype_info_c::is_ANY_INT(symbol->get_element(i)->candidate_datatypes[k]))
+				symbol->get_element(i)->datatype = symbol->get_element(i)->candidate_datatypes[k];
 		}
-		symbol->elements[i]->accept(*this);
+		symbol->get_element(i)->accept(*this);
 	}
 	return NULL;  
 }
@@ -846,8 +846,8 @@
 void *narrow_candidate_datatypes_c::visit(var1_list_c *symbol) {
 #if 0   /* We don't really need to set the datatype of each variable. We just check the declaration itself! */
   for(int i = 0; i < symbol->n; i++) {
-    if (symbol->elements[i]->candidate_datatypes.size() == 1)
-      symbol->elements[i]->datatype = symbol->elements[i]->candidate_datatypes[0];
+    if (symbol->get_element(i)->candidate_datatypes.size() == 1)
+      symbol->get_element(i)->datatype = symbol->get_element(i)->candidate_datatypes[0];
   }
 #endif
   return NULL;
@@ -1026,7 +1026,7 @@
 	 */
 	for(int j = 0; j < 2; j++) {
 		for(int i = symbol->n-1; i >= 0; i--) {
-			symbol->elements[i]->accept(*this);
+			symbol->get_element(i)->accept(*this);
 		}
 	}
 	return NULL;
@@ -1141,7 +1141,7 @@
    */
   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!
   if  (NULL != symbol->il_operand)
-    symbol->il_operand->datatype = ((list_c *)symbol->simple_instr_list)->elements[0]->datatype;
+    symbol->il_operand->datatype = ((list_c *)symbol->simple_instr_list)->get_element(0)->datatype;
   
   return NULL;
 }
@@ -1213,10 +1213,10 @@
 /* This object is referenced by il_expression_c objects */
 void *narrow_candidate_datatypes_c::visit(simple_instr_list_c *symbol) {
 	if (symbol->n > 0)
-		symbol->elements[symbol->n - 1]->datatype = symbol->datatype;
+		symbol->get_element(symbol->n - 1)->datatype = symbol->datatype;
 
 	for(int i = symbol->n-1; i >= 0; i--) {
-		symbol->elements[i]->accept(*this);
+		symbol->get_element(i)->accept(*this);
 	}
 	return NULL;
 }
@@ -1748,8 +1748,8 @@
 // SYM_LIST(case_element_list_c)
 void *narrow_candidate_datatypes_c::visit(case_element_list_c *symbol) {
 	for (int i = 0; i < symbol->n; i++) {
-		symbol->elements[i]->datatype = symbol->datatype;
-		symbol->elements[i]->accept(*this);
+		symbol->get_element(i)->datatype = symbol->datatype;
+		symbol->get_element(i)->accept(*this);
 	}
 	return NULL;
 }
@@ -1766,12 +1766,12 @@
 // SYM_LIST(case_list_c)
 void *narrow_candidate_datatypes_c::visit(case_list_c *symbol) {
 	for (int i = 0; i < symbol->n; i++) {
-		for (unsigned int k = 0; k < symbol->elements[i]->candidate_datatypes.size(); k++) {
-			if (get_datatype_info_c::is_type_equal(symbol->datatype, symbol->elements[i]->candidate_datatypes[k]))
-				symbol->elements[i]->datatype = symbol->elements[i]->candidate_datatypes[k];
+		for (unsigned int k = 0; k < symbol->get_element(i)->candidate_datatypes.size(); k++) {
+			if (get_datatype_info_c::is_type_equal(symbol->datatype, symbol->get_element(i)->candidate_datatypes[k]))
+				symbol->get_element(i)->datatype = symbol->get_element(i)->candidate_datatypes[k];
 		}
 		/* NOTE: this may be an integer, a subrange_c, or a enumerated value! */
-		symbol->elements[i]->accept(*this);
+		symbol->get_element(i)->accept(*this);
 	}
 	return NULL;
 }
--- a/stage3/print_datatypes_error.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/print_datatypes_error.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -587,9 +587,9 @@
 void *print_datatypes_error_c::visit(subscript_list_c *symbol) {
 	for (int i = 0; i < symbol->n; i++) {
 		int start_error_count = error_count;
-		symbol->elements[i]->accept(*this);
+		symbol->get_element(i)->accept(*this);
 		/* The following error message will only get printed if the current_display_error_level is set higher than 0! */
-		if ((start_error_count == error_count) && (!get_datatype_info_c::is_type_valid(symbol->elements[i]->datatype)))
+		if ((start_error_count == error_count) && (!get_datatype_info_c::is_type_valid(symbol->get_element(i)->datatype)))
 			STAGE3_ERROR(0, symbol, symbol, "Invalid data type for array subscript field.");
 	}
 	return NULL;
--- a/stage3/remove_forward_dependencies.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage3/remove_forward_dependencies.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -209,10 +209,10 @@
   /* Note too that circular references in derived datatypes is also not possible due to sytax!                                        */
   int initial_error_count = error_count;
   for (int i = 0; i < symbol->n; i++) 
-    if (   (inserted_symbols.find(symbol->elements[i]) == inserted_symbols.end())            // if not copied to new AST
-        &&(  (NULL != dynamic_cast <function_block_declaration_c *>(symbol->elements[i]))    // and (is a FB  
-           ||(NULL != dynamic_cast <      function_declaration_c *>(symbol->elements[i]))))  //      or a Function)
-      STAGE3_ERROR(0, symbol->elements[i], symbol->elements[i], "POU (%s) contains a self-reference and/or belongs in a circular referencing loop", get_datatype_info_c::get_id_str(symbol->elements[i]));
+    if (   (inserted_symbols.find(symbol->get_element(i)) == inserted_symbols.end())            // if not copied to new AST
+        &&(  (NULL != dynamic_cast <function_block_declaration_c *>(symbol->get_element(i)))    // and (is a FB  
+           ||(NULL != dynamic_cast <      function_declaration_c *>(symbol->get_element(i)))))  //      or a Function)
+      STAGE3_ERROR(0, symbol->get_element(i), symbol->get_element(i), "POU (%s) contains a self-reference and/or belongs in a circular referencing loop", get_datatype_info_c::get_id_str(symbol->get_element(i)));
   if (error_count == initial_error_count) ERROR; // We were unable to determine which POUs contain the circular references!!
 }
 
@@ -228,8 +228,8 @@
   /* first insert all the derived datatype declarations, in the same order by which they are delcared in the original AST */
   /* Since IEC 61131-3 does not allow FBs in arrays or structures, it is actually safe to place all the datatypes before all the POUs! */
   for (int i = 0; i < symbol->n; i++) 
-    if (NULL != dynamic_cast <data_type_declaration_c *>(symbol->elements[i]))
-      new_tree->add_element(symbol->elements[i]);  
+    if (NULL != dynamic_cast <data_type_declaration_c *>(symbol->get_element(i)))
+      new_tree->add_element(symbol->get_element(i));  
 
   /* now do the POUs, in whatever order is necessary to guarantee no forward references. */    
   long long int old_tree_pou_count = pou_count_c::get_count(symbol);
@@ -241,7 +241,7 @@
     cycle_count++;
     prev_n = new_tree->n;
     current_code_generation_pragma = default_code_generation_pragma;
-    for (int i = 0; i < symbol->n; i++)  symbol->elements[i]->accept(*this);
+    for (int i = 0; i < symbol->n; i++)  symbol->get_element(i)->accept(*this);
   } while (prev_n != new_tree->n); // repeat while new elementns are still being added to the new AST
   
   if (old_tree_pou_count != pou_count_c::get_count(new_tree)) 
--- a/stage4/generate_c/generate_c.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_c.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -2191,7 +2191,7 @@
       pous_incl_s4o.print("#include \"accessor.h\"\n#include \"iec_std_lib.h\"\n\n");
 
       for(int i = 0; i < symbol->n; i++) {
-        symbol->elements[i]->accept(*this);
+        symbol->get_element(i)->accept(*this);
       }
 
       pous_incl_s4o.print("#endif //__POUS_H\n");
@@ -2229,8 +2229,8 @@
     /* helper symbol for data_type_declaration */
     void *visit(type_declaration_list_c *symbol) {
       for(int i = 0; i < symbol->n; i++) {
-        symbol->elements[i]->accept(generate_c_implicit_typedecl);
-        symbol->elements[i]->accept(generate_c_typedecl);
+        symbol->get_element(i)->accept(generate_c_implicit_typedecl);
+        symbol->get_element(i)->accept(generate_c_typedecl);
       }
       return NULL;
     }
--- a/stage4/generate_c/generate_c_base.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_c_base.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -201,13 +201,13 @@
       if (list->n > 0) {
 //std::cout << "generate_c_base_c::print_list(n = " << list->n << ")   000\n";
         s4o.print(pre_elem_str);
-        list->elements[0]->accept(*visitor);
+        list->get_element(0)->accept(*visitor);
       }
 
       for(int i = 1; i < list->n; i++) {
 //std::cout << "generate_c_base_c::print_list   " << i << "\n";
         s4o.print(inter_elem_str);
-        list->elements[i]->accept(*visitor);
+        list->get_element(i)->accept(*visitor);
       }
 
       if (list->n > 0)
--- a/stage4/generate_c/generate_c_il.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_c_il.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -661,7 +661,7 @@
     if (dimension == NULL) ERROR;
 
     s4o.print("[(");
-    symbol->elements[i]->accept(*this);
+    symbol->get_element(i)->accept(*this);
     s4o.print(") - (");
     dimension->accept(*this);
     s4o.print(")]");
@@ -711,9 +711,9 @@
   declare_implicit_variable_back();
   
   for(int i = 0; i < symbol->n; i++) {
-    print_line_directive(symbol->elements[i]);
+    print_line_directive(symbol->get_element(i));
     s4o.print(s4o.indent_spaces);
-    symbol->elements[i]->accept(*this);
+    symbol->get_element(i)->accept(*this);
     s4o.print(";\n");
   }
   return NULL;
--- a/stage4/generate_c/generate_c_sfc.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_c_sfc.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -443,7 +443,7 @@
           for(int i = 0; i < symbol->n; i++) {
             s4o.print(GET_VAR);
             s4o.print("(");
-            print_step_argument(symbol->elements[i], "X");
+            print_step_argument(symbol->get_element(i), "X");
             s4o.print(")");
             if (i < symbol->n - 1) {
               s4o.print(" && ");
@@ -452,12 +452,12 @@
           break;
         case stepset_sg:
           for(int i = 0; i < symbol->n; i++) {
-            print_set_step(symbol->elements[i]);
+            print_set_step(symbol->get_element(i));
           }
           break;
         case stepreset_sg:
           for(int i = 0; i < symbol->n; i++) {
-            print_reset_step(symbol->elements[i]);
+            print_reset_step(symbol->get_element(i));
           }
           break;
         default:
@@ -710,8 +710,8 @@
       
       generate_c_sfc_elements->reset_transition_number();
       for(i = 0; i < symbol->n; i++) {
-        symbol->elements[i]->accept(*this);
-        generate_c_sfc_elements->generate(symbol->elements[i], generate_c_sfc_elements_c::transitionlist_sg);
+        symbol->get_element(i)->accept(*this);
+        generate_c_sfc_elements->generate(symbol->get_element(i), generate_c_sfc_elements_c::transitionlist_sg);
       }
       
       s4o.print(s4o.indent_spaces +"INT i;\n");
@@ -853,7 +853,7 @@
       s4o.print(s4o.indent_spaces + "// Transitions reset steps\n");
       generate_c_sfc_elements->reset_transition_number();
       for(i = 0; i < symbol->n; i++) {
-        generate_c_sfc_elements->generate(symbol->elements[i], generate_c_sfc_elements_c::stepreset_sg);
+        generate_c_sfc_elements->generate(symbol->get_element(i), generate_c_sfc_elements_c::stepreset_sg);
       }
       s4o.print("\n");
       
@@ -861,14 +861,14 @@
       s4o.print(s4o.indent_spaces + "// Transitions set steps\n");
       generate_c_sfc_elements->reset_transition_number();
       for(i = 0; i < symbol->n; i++) {
-        generate_c_sfc_elements->generate(symbol->elements[i], generate_c_sfc_elements_c::stepset_sg);
+        generate_c_sfc_elements->generate(symbol->get_element(i), generate_c_sfc_elements_c::stepset_sg);
       }
       s4o.print("\n");
       
       /* generate step association */
       s4o.print(s4o.indent_spaces + "// Steps association\n");
       for(i = 0; i < symbol->n; i++) {
-        generate_c_sfc_elements->generate(symbol->elements[i], generate_c_sfc_elements_c::actionassociation_sg);
+        generate_c_sfc_elements->generate(symbol->get_element(i), generate_c_sfc_elements_c::actionassociation_sg);
       }
       s4o.print("\n");
       
@@ -967,7 +967,7 @@
         }
       }
       for(i = 0; i < symbol->n; i++) {
-        generate_c_sfc_elements->generate(symbol->elements[i], generate_c_sfc_elements_c::actionbody_sg);
+        generate_c_sfc_elements->generate(symbol->get_element(i), generate_c_sfc_elements_c::actionbody_sg);
       }
       s4o.print("\n");
       
--- a/stage4/generate_c/generate_c_sfcdecl.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_c_sfcdecl.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -85,7 +85,7 @@
       switch (wanted_sfcdeclaration) {
         case sfcdecl_sd:
           for(int i = 0; i < symbol->n; i++)
-            symbol->elements[i]->accept(*this);
+            symbol->get_element(i)->accept(*this);
           
           /* steps table declaration */
           s4o.print(s4o.indent_spaces + "STEP __step_list[");
@@ -120,7 +120,7 @@
           /* steps table count */
           wanted_sfcdeclaration = stepcount_sd;
           for(int i = 0; i < symbol->n; i++)
-            symbol->elements[i]->accept(*this);
+            symbol->get_element(i)->accept(*this);
           s4o.print(s4o.indent_spaces);
           print_variable_prefix();
           s4o.print("__nb_steps = ");
@@ -141,12 +141,12 @@
           s4o.indent_left();
           s4o.print(s4o.indent_spaces + "}\n");
           for(int i = 0; i < symbol->n; i++)
-            symbol->elements[i]->accept(*this);
+            symbol->get_element(i)->accept(*this);
           
           /* actions table count */
           wanted_sfcdeclaration = actioncount_sd;
           for(int i = 0; i < symbol->n; i++)
-            symbol->elements[i]->accept(*this);
+            symbol->get_element(i)->accept(*this);
           s4o.print(s4o.indent_spaces);
           print_variable_prefix();
           s4o.print("__nb_actions = ");
@@ -170,7 +170,7 @@
           /* transitions table count */
           wanted_sfcdeclaration = transitioncount_sd;
           for(int i = 0; i < symbol->n; i++)
-            symbol->elements[i]->accept(*this);
+            symbol->get_element(i)->accept(*this);
           s4o.print(s4o.indent_spaces);
           print_variable_prefix();
           s4o.print("__nb_transitions = ");
@@ -187,7 +187,7 @@
         case stepdef_sd:
           s4o.print("// Steps definitions\n");
           for(int i = 0; i < symbol->n; i++)
-            symbol->elements[i]->accept(*this);
+            symbol->get_element(i)->accept(*this);
           s4o.print("\n");
           break;
         case actiondef_sd:
@@ -196,12 +196,12 @@
             // first fill up the this->variable_list variable!
             wanted_sfcdeclaration = actioncount_sd;
             for(int i = 0; i < symbol->n; i++)
-               symbol->elements[i]->accept(*this);
+               symbol->get_element(i)->accept(*this);
             action_number = 0; // reset the counter!
             wanted_sfcdeclaration = actiondef_sd;
             // Now do the defines for actions!
             for(int i = 0; i < symbol->n; i++)
-              symbol->elements[i]->accept(*this);
+              symbol->get_element(i)->accept(*this);
             // Now do the defines for actions that reference a variable instead of an action block!
             std::list<VARIABLE>::iterator pt;
             for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
@@ -219,18 +219,18 @@
         case stepundef_sd:
           s4o.print("// Steps undefinitions\n");
           for(int i = 0; i < symbol->n; i++)
-            symbol->elements[i]->accept(*this);
+            symbol->get_element(i)->accept(*this);
           s4o.print("\n");
           break;
         case actionundef_sd:
           s4o.print("// Actions undefinitions\n");
           for(int i = 0; i < symbol->n; i++)
-            symbol->elements[i]->accept(*this);
+            symbol->get_element(i)->accept(*this);
           {
             // first fill up the this->variable_list variable!
             wanted_sfcdeclaration = actioncount_sd;
             for(int i = 0; i < symbol->n; i++)
-               symbol->elements[i]->accept(*this);
+               symbol->get_element(i)->accept(*this);
             wanted_sfcdeclaration = actionundef_sd;
             std::list<VARIABLE>::iterator pt;
             for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
--- a/stage4/generate_c/generate_c_st.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_c_st.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -422,7 +422,7 @@
     if (dimension == NULL) ERROR;
 
     s4o.print("[(");
-    symbol->elements[i]->accept(*this);
+    symbol->get_element(i)->accept(*this);
     s4o.print(") - (");
     dimension->accept(*this);
     s4o.print(")]");
@@ -925,9 +925,9 @@
 /********************/
 void *visit(statement_list_c *symbol) {
   for(int i = 0; i < symbol->n; i++) {
-    print_line_directive(symbol->elements[i]);
+    print_line_directive(symbol->get_element(i));
     s4o.print(s4o.indent_spaces);
-    symbol->elements[i]->accept(*this);
+    symbol->get_element(i)->accept(*this);
     s4o.print(";\n");
   }
   return NULL;
@@ -1213,10 +1213,10 @@
      */
     if (0 != i)  s4o.print(" ||\n" + s4o.indent_spaces + "         ");
     s4o.print("(");
-    subrange_c *subrange = dynamic_cast<subrange_c *>(symbol->elements[i]);
+    subrange_c *subrange = dynamic_cast<subrange_c *>(symbol->get_element(i));
     if (NULL == subrange) {
       s4o.print("__case_expression == ");
-      symbol->elements[i]->accept(*this);
+      symbol->get_element(i)->accept(*this);
     } else {
       s4o.print("__case_expression >= ");
       subrange->lower_limit->accept(*this);
--- a/stage4/generate_c/generate_c_typedecl.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_c_typedecl.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -178,7 +178,7 @@
     /* helper symbol for array_specification */
     /* array_subrange_list ',' subrange */
     void *visit(array_subrange_list_c *symbol) {
-      for(int i = 0; i < symbol->n; i++) {symbol->elements[i]->accept(*this);}
+      for(int i = 0; i < symbol->n; i++) {symbol->get_element(i)->accept(*this);}
       return NULL;
     }
 
@@ -295,12 +295,12 @@
 
       if (list->n > 0) {
         s4o_incl.print(pre_elem_str);
-        list->elements[0]->accept(*this);
+        list->get_element(0)->accept(*this);
       }
 
       for(int i = 1; i < list->n; i++) {
         s4o_incl.print(inter_elem_str);
-        list->elements[i]->accept(*this);
+        list->get_element(i)->accept(*this);
       }
 
       if (list->n > 0)
--- a/stage4/generate_c/generate_c_vardecl.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_c_vardecl.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -168,7 +168,7 @@
         s4o.print("(");
         print_variable_prefix();
         s4o.print(",");
-        symbol->elements[i]->accept(*this);
+        symbol->get_element(i)->accept(*this);
         s4o.print(",,temp);\n");
       }
       return NULL;
@@ -249,14 +249,14 @@
                 ERROR;
               if (defined_values_count > 0)
                 s4o.print(",");
-              symbol->elements[i]->accept(*this);
+              symbol->get_element(i)->accept(*this);
               defined_values_count++;
             }
             else {
-              array_initial_elements_c *array_initial_element = dynamic_cast<array_initial_elements_c *>(symbol->elements[i]);
+              array_initial_elements_c *array_initial_element = dynamic_cast<array_initial_elements_c *>(symbol->get_element(i));
             
               if (array_initial_element != NULL) {
-                symbol->elements[i]->accept(*this);
+                symbol->get_element(i)->accept(*this);
               }
             }
             current_initialization_count++;
@@ -414,7 +414,7 @@
     void *visit(structure_element_declaration_list_c *symbol) {
       void *res;
       for (int i = 0; i < symbol->n; i++) {
-        res = symbol->elements[i]->accept(*this);
+        res = symbol->get_element(i)->accept(*this);
         if (res != NULL)
           return res;
       }
@@ -472,7 +472,7 @@
     void *visit(structure_element_initialization_list_c *symbol) {
       void *res;
       for (int i = 0; i < symbol->n; i++) {
-        res = symbol->elements[i]->accept(*this);
+        res = symbol->get_element(i)->accept(*this);
         if (res != NULL)
           return res;
       }
@@ -599,7 +599,7 @@
         s4o.print("(");
         print_variable_prefix();
         s4o.print(",");
-        symbol->elements[i]->accept(*this);
+        symbol->get_element(i)->accept(*this);
         s4o.print(",,temp);\n");
       }
       return NULL;
@@ -974,7 +974,7 @@
       if (NULL == init_list) ERROR;
       
       for (int i = 0; i < init_list->n; i++) {
-        structure_element_initialization_c *init_list_elem = dynamic_cast<structure_element_initialization_c *>(init_list->elements[i]);
+        structure_element_initialization_c *init_list_elem = dynamic_cast<structure_element_initialization_c *>(init_list->get_element(i));
         if (NULL == init_list_elem) ERROR;
         s4o.print("\n");
         s4o.print(s4o.indent_spaces);
@@ -1030,20 +1030,20 @@
             print_variable_prefix();
             s4o.print(",");
           }
-          list->elements[i]->accept(*this);
+          list->get_element(i)->accept(*this);
           if (wanted_varformat != local_vf) {
             if (wanted_varformat == localinit_vf &&
                 (current_vartype & inoutput_vt) != 0) {
               s4o.print(";\n");
               s4o.print(s4o.indent_spaces);
               s4o.print("if (__");
-              list->elements[i]->accept(*this);
+              list->get_element(i)->accept(*this);
               s4o.print(" != NULL) {\n");
               s4o.indent_right();
               s4o.print(s4o.indent_spaces);
-              list->elements[i]->accept(*this);
+              list->get_element(i)->accept(*this);
               s4o.print(" = *__");
-              list->elements[i]->accept(*this);
+              list->get_element(i)->accept(*this);
               s4o.print(";\n");
               s4o.indent_left();
               s4o.print(s4o.indent_spaces);
@@ -1058,7 +1058,7 @@
               this->current_var_init_symbol->accept(*this);
               s4o.print(";\n");
               s4o.print(s4o.indent_spaces);
-              list->elements[i]->accept(*this);
+              list->get_element(i)->accept(*this);
               s4o.print(" = temp;\n");
               s4o.indent_left();
               s4o.print(s4o.indent_spaces);
@@ -1094,7 +1094,7 @@
             s4o.print(" *__");
           else
             s4o.print(" ");
-          list->elements[i]->accept(*this);
+          list->get_element(i)->accept(*this);
           /* We do not print the initial value at function declaration!
            * It is up to the caller to pass the correct default value
            * if none is specified in the ST source code
@@ -1109,13 +1109,13 @@
         for(int i = 0; i < list->n; i++) {
           if ((current_vartype & (output_vt | inoutput_vt)) != 0) {
             s4o.print(s4o.indent_spaces + "if (__");
-            list->elements[i]->accept(*this);
+            list->get_element(i)->accept(*this);
             s4o.print(" != NULL) {\n");
             s4o.indent_right();
             s4o.print(s4o.indent_spaces + "*__");
-            list->elements[i]->accept(*this);
+            list->get_element(i)->accept(*this);
             s4o.print(" = ");
-            list->elements[i]->accept(*this);
+            list->get_element(i)->accept(*this);
             s4o.print(";\n");
             s4o.indent_left();
             s4o.print(s4o.indent_spaces + "}\n");
@@ -1139,7 +1139,7 @@
             s4o.print(FB_INIT_SUFFIX);
             s4o.print("(&");
             this->print_variable_prefix();
-            list->elements[i]->accept(*this);
+            list->get_element(i)->accept(*this);
             print_retain();
             s4o.print(");");
             if (this->current_var_init_symbol != NULL) {
@@ -1152,7 +1152,7 @@
                * __INIT_VAR(data__->my_fb.var1, __INT_LITERAL(42), retain);
                * __INIT_VAR(data__->my_fb.var1, __STRING_LITERAL("hello"), retain);
                */  
-              print_fb_explicit_initial_values(list->elements[i], this->current_var_init_symbol);
+              print_fb_explicit_initial_values(list->get_element(i), this->current_var_init_symbol);
             }
           }
           else if (this->current_var_init_symbol != NULL) {
@@ -1160,7 +1160,7 @@
             s4o.print(INIT_VAR);
             s4o.print("(");
             this->print_variable_prefix();
-            list->elements[i]->accept(*this);
+            list->get_element(i)->accept(*this);
             s4o.print(",");
             this->current_var_init_symbol->accept(*this);
             print_retain();
@@ -2157,7 +2157,7 @@
         if(this->resource_name != NULL)
             this->resource_name->accept(*this);
         s4o.print(",");
-        list->elements[i]->accept(*this);
+        list->get_element(i)->accept(*this);
         s4o.print(")\n");
       }
       break;
@@ -2174,7 +2174,7 @@
           s4o.print("(");
           this->current_var_type_symbol->accept(*this);
           s4o.print(",");
-          list->elements[i]->accept(*this);
+          list->get_element(i)->accept(*this);
           if (this->current_var_init_symbol != NULL) {
             s4o.print(",");
             s4o.print(INITIAL_VALUE);
@@ -2196,7 +2196,7 @@
             this->globalnamespace->accept(*this);
             s4o.print("::");
           }
-          list->elements[i]->accept(*this);
+          list->get_element(i)->accept(*this);
 
           if (this->current_var_init_symbol != NULL) {
             s4o.print(" = ");
@@ -2219,7 +2219,7 @@
         s4o.print("(");
         this->current_var_type_symbol->accept(*this);
         s4o.print(",");
-        list->elements[i]->accept(*this);
+        list->get_element(i)->accept(*this);
         s4o.print(")\n");
       }
       break;
--- a/stage4/generate_c/generate_var_list.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_c/generate_var_list.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -289,7 +289,7 @@
       if (list == NULL) ERROR;
 
       for(int i = 0; i < list->n; i++) {
-        declare_variable(list->elements[i]);
+        declare_variable(list->get_element(i));
       }
     }
     
@@ -793,7 +793,7 @@
 
     void *visit(structure_element_declaration_list_c *symbol) {
       for(int i = 0; i < symbol->n; i++) {
-        symbol->elements[i]->accept(*this);
+        symbol->get_element(i)->accept(*this);
       }
       return NULL;
     }
@@ -860,7 +860,7 @@
       transition_number = 0;
       action_number = 0;
       for(int i = 0; i < symbol->n; i++) {
-        symbol->elements[i]->accept(*this);
+        symbol->get_element(i)->accept(*this);
       }
       return NULL;
     }
@@ -937,7 +937,7 @@
     //SYM_LIST(step_name_list_c)
     void *visit(step_name_list_c *symbol) {
       for(int i = 0; i < symbol->n; i++) {
-        symbol->elements[i]->accept(*this);
+        symbol->get_element(i)->accept(*this);
         if (i < symbol->n - 1)
           s4o.print(",");
       }
--- a/stage4/generate_iec/generate_iec.cc	Mon Apr 03 22:06:40 2017 +0100
+++ b/stage4/generate_iec/generate_iec.cc	Mon Apr 03 22:18:22 2017 +0100
@@ -164,12 +164,12 @@
 			       std::string post_elem_str = "") {
   if (list->n > 0) {
     s4o.print(pre_elem_str);
-    list->elements[0]->accept(*this);
+    list->get_element(0)->accept(*this);
   }
 
   for(int i = 1; i < list->n; i++) {
     s4o.print(inter_elem_str);
-    list->elements[i]->accept(*this);
+    list->get_element(i)->accept(*this);
   }
 
   if (list->n > 0)