Use simple_spec_init_c inside en_param_declaration_c (will reduce need to handle it as a special case in the future).
authorMario de Sousa <msousa@fe.up.pt>
Tue, 22 Jan 2013 16:07:49 +0000
changeset 805 b737cfc92614
parent 798 d21e598b0b75
child 806 f218434eeaf8
Use simple_spec_init_c inside en_param_declaration_c (will reduce need to handle it as a special case in the future).
absyntax/absyntax.def
absyntax_utils/add_en_eno_param_decl.cc
absyntax_utils/function_param_iterator.cc
stage1_2/iec_bison.yy
stage4/generate_c/generate_c_vardecl.cc
stage4/generate_c/generate_var_list.cc
stage4/generate_iec/generate_iec.cc
--- a/absyntax/absyntax.def	Sun Jan 13 16:06:00 2013 +0000
+++ b/absyntax/absyntax.def	Tue Jan 22 16:07:49 2013 +0000
@@ -515,7 +515,8 @@
  */
 SYM_REF0(implicit_definition_c)
 SYM_REF0(explicit_definition_c)
-SYM_REF4(en_param_declaration_c, name, type, value, method)
+/* type_decl is a simple_spec_init_c */
+SYM_REF3(en_param_declaration_c, name, type_decl, method)
 SYM_REF3(eno_param_declaration_c, name, type, method)
 
 /* edge -> The F_EDGE or R_EDGE directive */
--- a/absyntax_utils/add_en_eno_param_decl.cc	Sun Jan 13 16:06:00 2013 +0000
+++ b/absyntax_utils/add_en_eno_param_decl.cc	Tue Jan 22 16:07:49 2013 +0000
@@ -91,12 +91,11 @@
 
 
 input_declarations_c *add_en_eno_param_decl_c::build_en_param(void) {
-  boolean_literal_c *boolean_literal = 
-    new boolean_literal_c(new bool_type_name_c(), new boolean_true_c());
-  identifier_c *identifier =
-    new identifier_c("EN");
+  boolean_literal_c  *boolean_literal = new boolean_literal_c(new bool_type_name_c(), new boolean_true_c());
+  identifier_c       *identifier      = new identifier_c("EN");
+  simple_spec_init_c *type_spec_init  = new simple_spec_init_c(new bool_type_name_c(), boolean_literal);
   en_param_declaration_c *en_param_declaration = 
-    new en_param_declaration_c(identifier, new bool_type_name_c(), boolean_literal, new implicit_definition_c());
+    new en_param_declaration_c(identifier, type_spec_init, new implicit_definition_c());
     /* the last paramater is to flag that this
      * declaration was inserted automatically, i.e. an implicit declaration 
      */
@@ -109,8 +108,7 @@
 
 
 output_declarations_c *add_en_eno_param_decl_c::build_eno_param(void) {
-  identifier_c *identifier =
-    new identifier_c("ENO");
+  identifier_c *identifier = new identifier_c("ENO");
   eno_param_declaration_c *eno_param_declaration =
     new eno_param_declaration_c(identifier, new bool_type_name_c(), new implicit_definition_c()); 
     /* the last paramater is to flag that this
--- a/absyntax_utils/function_param_iterator.cc	Sun Jan 13 16:06:00 2013 +0000
+++ b/absyntax_utils/function_param_iterator.cc	Tue Jan 22 16:07:49 2013 +0000
@@ -427,9 +427,9 @@
    * variables will get overwritten when we visit the next
    * var1_init_decl_c list!
    */
-  current_param_default_value = symbol->value;
-  current_param_type = symbol->type;
-
+  current_param_default_value = spec_init_sperator_c::get_init(symbol->type_decl);
+  current_param_type = spec_init_sperator_c::get_spec(symbol->type_decl);
+  
   void *res = handle_single_param(symbol->name);
   
     /* If we have found the parameter we will be returning, we set the en_eno_param_implicit to TRUE if implicitly defined */
--- a/stage1_2/iec_bison.yy	Sun Jan 13 16:06:00 2013 +0000
+++ b/stage1_2/iec_bison.yy	Tue Jan 22 16:07:49 2013 +0000
@@ -3458,9 +3458,9 @@
  */
 en_param_declaration:
   en_identifier ':' BOOL ASSIGN boolean_literal
-  {$$ = new en_param_declaration_c($1, new bool_type_name_c(locloc(@$)), $5, new explicit_definition_c(), locloc(@$));}
+  {$$ = new en_param_declaration_c($1, new simple_spec_init_c(new bool_type_name_c(locloc(@3)), $5, locf(@3), locl(@5)), new explicit_definition_c(), locloc(@$));}
 | en_identifier ':' BOOL ASSIGN integer
-  {$$ = new en_param_declaration_c($1, new bool_type_name_c(locloc(@$)), $5, new explicit_definition_c(), locloc(@$));}
+  {$$ = new en_param_declaration_c($1, new simple_spec_init_c(new bool_type_name_c(locloc(@3)), $5, locf(@3), locl(@5)), new explicit_definition_c(), locloc(@$));}
 /* ERROR_CHECK_BEGIN */
 | en_identifier BOOL ASSIGN boolean_literal
 	{$$ = NULL; print_err_msg(locl(@1), locf(@2), "':' missing between variable list and specification in EN declaration."); yynerrs++;}
--- a/stage4/generate_c/generate_c_vardecl.cc	Sun Jan 13 16:06:00 2013 +0000
+++ b/stage4/generate_c/generate_c_vardecl.cc	Tue Jan 22 16:07:49 2013 +0000
@@ -1258,8 +1258,10 @@
   return NULL;
 }
 
+
 void *visit(en_param_declaration_c *symbol) {
   TRACE("en_declaration_c");
+  update_type_init(symbol->type_decl);
   if (wanted_varformat == finterface_vf) {
     finterface_var_count++;
   }  
@@ -1267,7 +1269,7 @@
     if (wanted_varformat == finterface_vf) {
       s4o.print(nv->get());
       s4o.print("\n" + s4o.indent_spaces);
-      symbol->type->accept(*this);
+      this->current_var_type_symbol->accept(*this);
       s4o.print(" ");
       symbol->name->accept(*this);
     }
@@ -1279,11 +1281,11 @@
       if (wanted_varformat == local_vf) {
         s4o.print(DECLARE_VAR);
         s4o.print("(");
-        symbol->type->accept(*this);
+        this->current_var_type_symbol->accept(*this);
         s4o.print(",");
       }
       else if (wanted_varformat == localinit_vf) {
-        symbol->type->accept(*this);
+        this->current_var_type_symbol->accept(*this);
         s4o.print(" ");
       }
       print_variable_prefix();
@@ -1292,7 +1294,7 @@
         s4o.print(")\n");
       else {
         s4o.print(" = ");
-        symbol->value->accept(*this);
+        this->current_var_init_symbol->accept(*this);
         s4o.print(";\n");
       }
     }
@@ -1306,11 +1308,12 @@
       // s4o.print("EN = __BOOL_LITERAL(TRUE);");
       symbol->name->accept(*this);
       s4o.print(",");
-      symbol->value->accept(*this);
+      this->current_var_init_symbol->accept(*this);
       print_retain();
       s4o.print(")");
     }
   }
+  void_type_init();
   return NULL;
 }
 
--- a/stage4/generate_c/generate_var_list.cc	Sun Jan 13 16:06:00 2013 +0000
+++ b/stage4/generate_c/generate_var_list.cc	Tue Jan 22 16:07:49 2013 +0000
@@ -731,7 +731,7 @@
       /* Start off by setting the current_var_type_symbol and
        * current_var_init_symbol private variables...
        */
-      update_var_type_symbol(symbol->type);
+      update_var_type_symbol(symbol->type_decl);
 
       /* now to produce the c equivalent... */
       declare_variable(symbol->name);
--- a/stage4/generate_iec/generate_iec.cc	Sun Jan 13 16:06:00 2013 +0000
+++ b/stage4/generate_iec/generate_iec.cc	Tue Jan 22 16:07:49 2013 +0000
@@ -722,9 +722,7 @@
   if (typeid(*(symbol->method)) == typeid(explicit_definition_c)) {
     symbol->name->accept(*this);
     s4o.print(" : ");
-    symbol->type->accept(*this);
-    s4o.print(" := ");
-    symbol->value->accept(*this);
+    symbol->type_decl->accept(*this);
   }
   return NULL;
 }