Fix bug with InOut variable of structured type
authorLaurent Bessard
Tue, 14 Aug 2012 19:40:01 +0200
changeset 412 aad38592bdde
parent 411 3e21d98d0a71
child 625 c0bda77b37a0
Fix bug with InOut variable of structured type
absyntax_utils/search_base_type.cc
absyntax_utils/search_base_type.hh
absyntax_utils/search_var_instance_decl.cc
absyntax_utils/search_varfb_instance_type.cc
absyntax_utils/search_varfb_instance_type.hh
stage4/generate_c/generate_c.cc
--- a/absyntax_utils/search_base_type.cc	Sat Jul 28 17:38:57 2012 +0200
+++ b/absyntax_utils/search_base_type.cc	Tue Aug 14 19:40:01 2012 +0200
@@ -256,6 +256,11 @@
   return symbol->structure_specification->accept(*this);
 }
 
+/*  var1_list ':' structure_type_name */
+void *search_base_type_c::visit(structured_var_declaration_c *symbol) {
+	return symbol->structure_type_name->accept(*this);
+}
+
 /* structure_type_name ASSIGN structure_initialization */
 /* structure_initialization may be NULL ! */
 void *search_base_type_c::visit(initialized_structure_c *symbol)	{
--- a/absyntax_utils/search_base_type.hh	Sat Jul 28 17:38:57 2012 +0200
+++ b/absyntax_utils/search_base_type.hh	Tue Aug 14 19:40:01 2012 +0200
@@ -194,6 +194,8 @@
        *       structure_element_declaration_list_c
        */
     void *visit(structure_type_declaration_c *symbol);
+  /*  var1_list ':' structure_type_name */
+    void *visit(structured_var_declaration_c *symbol);
   /* structure_type_name ASSIGN structure_initialization */
   /* structure_initialization may be NULL ! */
     void *visit(initialized_structure_c *symbol);
--- a/absyntax_utils/search_var_instance_decl.cc	Sat Jul 28 17:38:57 2012 +0200
+++ b/absyntax_utils/search_var_instance_decl.cc	Tue Aug 14 19:40:01 2012 +0200
@@ -262,7 +262,7 @@
 /*  var1_list ':' structure_type_name */
 // SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name)
 void *search_var_instance_decl_c::visit(structured_var_declaration_c *symbol) {
-  current_type_decl = symbol->structure_type_name;
+  current_type_decl = symbol;
   return symbol->var1_list->accept(*this);
 }
 
--- a/absyntax_utils/search_varfb_instance_type.cc	Sat Jul 28 17:38:57 2012 +0200
+++ b/absyntax_utils/search_varfb_instance_type.cc	Tue Aug 14 19:40:01 2012 +0200
@@ -301,6 +301,34 @@
    */
 }
 
+/*  var1_list ':' structure_type_name */
+void *search_varfb_instance_type_c::visit(structured_var_declaration_c *symbol) {
+  this->is_complex = true;
+  if (NULL != current_structelement_name) ERROR;
+
+  /* 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);
+}
+
 /* structure_type_name ASSIGN structure_initialization */
 /* structure_initialization may be NULL ! */
 // SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
--- a/absyntax_utils/search_varfb_instance_type.hh	Sat Jul 28 17:38:57 2012 +0200
+++ b/absyntax_utils/search_varfb_instance_type.hh	Tue Aug 14 19:40:01 2012 +0200
@@ -149,6 +149,9 @@
     /*  structure_type_name ':' structure_specification */
     void *visit(structure_type_declaration_c *symbol);
 
+    /*  var1_list ':' structure_type_name */
+    void *visit(structured_var_declaration_c *symbol);
+
     /* structure_type_name ASSIGN structure_initialization */
     /* structure_initialization may be NULL ! */
     // SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
--- a/stage4/generate_c/generate_c.cc	Sat Jul 28 17:38:57 2012 +0200
+++ b/stage4/generate_c/generate_c.cc	Tue Aug 14 19:40:01 2012 +0200
@@ -809,6 +809,11 @@
       return NULL;
     }
 
+    /*  var1_list ':' structure_type_name */
+	void *visit(structured_var_declaration_c *symbol) {
+	  return NULL;
+	}
+
     /*  var1_list ':' initialized_structure */
     // SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure)
     void *visit(structured_var_init_decl_c *symbol) {