absyntax_utils/search_varfb_instance_type.cc
changeset 382 ac6dfec701c9
parent 377 60b012b7793f
child 412 aad38592bdde
child 417 d48f53715f77
--- a/absyntax_utils/search_varfb_instance_type.cc	Sun Oct 09 20:18:55 2011 +0200
+++ b/absyntax_utils/search_varfb_instance_type.cc	Tue Oct 11 12:30:49 2011 +0200
@@ -309,7 +309,72 @@
   this->is_complex = true;
   if (NULL != current_structelement_name) ERROR;
   
-  /* make sure that we have decomposed all strcuture elements of the variable name */
+  /* make sure that we have decomposed all structure elements of the variable name */
+  symbol_c *var_name = decompose_var_instance_name->next_part();
+  if (NULL == var_name) {
+    /* this is it... !
+     * No need to look any further...
+     * Note also that, unlike for the struct types, a function block may
+     * not be defined based on another (i.e. no inheritance is allowed),
+     * so this function block is already the most base type.
+     * We simply return it.
+     */
+    return (void *)symbol;
+  }
+
+  /* reset current_type_id because of new structure element part */
+  this->current_typeid = NULL;
+
+  /* look for the var_name in the structure declaration */
+  current_structelement_name = var_name;
+
+  /* recursively find out the data type of current_structelement_name... */
+  return symbol->structure_type_name->accept(*this);
+}
+
+/* helper symbol for structure_declaration */
+/* 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)	{
+  if (NULL == current_structelement_name) ERROR;
+  /* now search the structure declaration */
+  return visit_list(symbol);
+}
+
+/*  structure_element_name ':' spec_init */
+void *search_varfb_instance_type_c::visit(structure_element_declaration_c *symbol) {
+  if (NULL == current_structelement_name) ERROR;
+
+  if (compare_identifiers(symbol->structure_element_name, current_structelement_name) == 0) {
+    current_structelement_name = NULL;
+    /* found the type of the element we were looking for! */
+    return symbol->spec_init->accept(*this);
+  }  
+
+  /* Did not find the type of the element we were looking for! */
+  /* Will keep looking... */
+  return NULL;
+}
+
+/* helper symbol for structure_initialization */
+/* structure_initialization: '(' structure_element_initialization_list ')' */
+/* structure_element_initialization_list ',' structure_element_initialization */
+void *search_varfb_instance_type_c::visit(structure_element_initialization_list_c *symbol) {ERROR; return NULL;} /* should never get called... */
+/*  structure_element_name ASSIGN value */
+void *search_varfb_instance_type_c::visit(structure_element_initialization_c *symbol) {ERROR; return NULL;} /* should never get called... */
+
+
+
+/**************************************/
+/* B.1.5 - Program organization units */
+/**************************************/
+/*****************************/
+/* B 1.5.2 - Function Blocks */
+/*****************************/
+/*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
+// SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused)
+void *search_varfb_instance_type_c::visit(function_block_declaration_c *symbol) {
+  /* make sure that we have decomposed all structure elements of the variable name */
   symbol_c *var_name = decompose_var_instance_name->next_part();
   if (NULL == var_name) {
     /* this is it... !
@@ -322,67 +387,8 @@
     return (void *)symbol;
    }
 
-  /* look for the var_name in the structure declaration */
-  current_structelement_name = var_name;
-
-  /* recursively find out the data type of current_structelement_name... */
-  return symbol->structure_type_name->accept(*this);
-}
-
-/* helper symbol for structure_declaration */
-/* 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)	{
-  if (NULL == current_structelement_name) ERROR;
-  /* now search the structure declaration */
-  return visit_list(symbol);
-}
-
-/*  structure_element_name ':' spec_init */
-void *search_varfb_instance_type_c::visit(structure_element_declaration_c *symbol) {
-  if (NULL == current_structelement_name) ERROR;
-
-  if (compare_identifiers(symbol->structure_element_name, current_structelement_name) == 0) {
-    current_structelement_name = NULL;
-    /* found the type of the element we were looking for! */
-    return symbol->spec_init->accept(*this);
-  }  
-
-  /* Did not find the type of the element we were looking for! */
-  /* Will keep looking... */
-  return NULL;
-}
-
-/* helper symbol for structure_initialization */
-/* structure_initialization: '(' structure_element_initialization_list ')' */
-/* structure_element_initialization_list ',' structure_element_initialization */
-void *search_varfb_instance_type_c::visit(structure_element_initialization_list_c *symbol) {ERROR; return NULL;} /* should never get called... */
-/*  structure_element_name ASSIGN value */
-void *search_varfb_instance_type_c::visit(structure_element_initialization_c *symbol) {ERROR; return NULL;} /* should never get called... */
-
-
-
-/**************************************/
-/* B.1.5 - Program organization units */
-/**************************************/
-/*****************************/
-/* B 1.5.2 - Function Blocks */
-/*****************************/
-/*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
-// SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused)
-void *search_varfb_instance_type_c::visit(function_block_declaration_c *symbol) {
-  /* make sure that we have decomposed all strcuture elements of the variable name */
-  symbol_c *var_name = decompose_var_instance_name->next_part();
-  if (NULL == var_name) {
-    /* this is it... !
-     * No need to look any further...
-     * Note also that, unlike for the struct types, a function block may
-     * not be defined based on another (i.e. no inheritance is allowed),
-     * so this function block is already the most base type.
-     * We simply return it.
-     */
-    return (void *)symbol;
-   }
+   /* reset current_type_id because of new structure element part */
+   this->current_typeid = NULL;
 
    /* now search the function block declaration for the variable... */
    search_var_instance_decl_c search_decl(symbol);
@@ -404,7 +410,7 @@
   current_structelement_name = var_name;
   /* recursively find out the data type of var_name... */
   return symbol->var_declarations->accept(*this);
-#endif  
+#endif
   /* carry on recursively, in case the variable has more elements to be decomposed... */
   return var_decl->accept(*this);
 }