Determine the modifiers (CONST, REATAIN) used when declaring a variable.
authormanuele.conti@sirius-es.it
Sat, 14 Apr 2012 18:05:50 +0100
changeset 507 30b31d8f6d0f
parent 506 2b4e69c7ff8b
child 508 dc6906338042
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
absyntax_utils/search_var_instance_decl.cc
absyntax_utils/search_var_instance_decl.hh
--- a/absyntax_utils/search_var_instance_decl.cc	Sat Apr 14 16:53:35 2012 +0100
+++ b/absyntax_utils/search_var_instance_decl.cc	Sat Apr 14 18:05:50 2012 +0100
@@ -232,21 +232,31 @@
   this->search_scope = search_scope;
   this->search_name = NULL;
   this->current_type_decl = NULL;
+  this->current_option = none_opt;
 }
 
 symbol_c *search_var_instance_decl_c::get_decl(symbol_c *variable) {
   this->current_vartype = none_vt;
+  this->current_option  = none_opt;
   this->search_name = get_var_name_c::get_name(variable);
   return (symbol_c *)search_scope->accept(*this);
 }
 
 unsigned int search_var_instance_decl_c::get_vartype(symbol_c *variable) {
   this->current_vartype = none_vt;
+  this->current_option  = none_opt;
   this->search_name = get_var_name_c::get_name(variable);
   search_scope->accept(*this);
-  return current_vartype;
-}
-
+  return this->current_vartype;
+}
+
+unsigned int search_var_instance_decl_c::get_option(symbol_c *variable) {
+  this->current_vartype = none_vt;
+  this->current_option  = none_opt;
+  this->search_name = get_var_name_c::get_name(variable);
+  search_scope->accept(*this);
+  return this->current_option;
+}
 
 /***************************/
 /* B 0 - Programming Model */
@@ -267,12 +277,30 @@
 /* edge -> The F_EDGE or R_EDGE directive */
 // SYM_REF2(edge_declaration_c, edge, var1_list)
 // TODO
+void *search_var_instance_decl_c::visit(constant_option_c *symbol) {
+  current_option = constant_opt;
+  return NULL;
+}
+
+void *search_var_instance_decl_c::visit(retain_option_c *symbol) {
+  current_option = retain_opt;
+  return NULL;
+}
+
+void *search_var_instance_decl_c::visit(non_retain_option_c *symbol) {
+  current_option = non_retain_opt;
+  return NULL;
+}
 
 void *search_var_instance_decl_c::visit(input_declarations_c *symbol) {
   current_vartype = input_vt;
+  current_option  = none_opt; /* not really required. Just to make the code more readable */
+  if (NULL != symbol->option)  
+    symbol->option->accept(*this);
   void *res = symbol->input_declaration_list->accept(*this);
   if (res == NULL) {
     current_vartype = none_vt;
+    current_option  = none_opt;
   }
   return res;
 }
@@ -281,9 +309,13 @@
 /* option -> may be NULL ! */
 void *search_var_instance_decl_c::visit(output_declarations_c *symbol) {
   current_vartype = output_vt;
+  current_option  = none_opt; /* not really required. Just to make the code more readable */
+  if (NULL != symbol->option)
+    symbol->option->accept(*this);
   void *res = symbol->var_init_decl_list->accept(*this);
   if (res == NULL) {
     current_vartype = none_vt;
+    current_option  = none_opt;
   }
   return res;
 }
@@ -291,6 +323,7 @@
 /*  VAR_IN_OUT var_declaration_list END_VAR */
 void *search_var_instance_decl_c::visit(input_output_declarations_c *symbol) {
   current_vartype = inoutput_vt;
+  current_option  = none_opt; /* not really required. Just to make the code more readable */
   void *res = symbol->var_declaration_list->accept(*this);
   if (res == NULL) {
     current_vartype = none_vt;
@@ -311,9 +344,13 @@
 /* helper symbol for input_declarations */
 void *search_var_instance_decl_c::visit(var_declarations_c *symbol) {
   current_vartype = private_vt;
+  current_option  = none_opt; /* not really required. Just to make the code more readable */
+  if (NULL != symbol->option)
+    symbol->option->accept(*this);
   void *res = symbol->var_init_decl_list->accept(*this);
   if (res == NULL) {
     current_vartype = none_vt;
+    current_option = none_opt;
   }
   return res;
 }
@@ -321,9 +358,11 @@
 /*  VAR RETAIN var_init_decl_list END_VAR */
 void *search_var_instance_decl_c::visit(retentive_var_declarations_c *symbol) {
   current_vartype = private_vt;
+  current_option  = retain_opt;
   void *res = symbol->var_init_decl_list->accept(*this);
   if (res == NULL) {
     current_vartype = none_vt;
+    current_option = none_opt;
   }
   return res;
 }
@@ -333,9 +372,13 @@
 //SYM_REF2(located_var_declarations_c, option, located_var_decl_list)
 void *search_var_instance_decl_c::visit(located_var_declarations_c *symbol) {
   current_vartype = located_vt;
+  current_option  = none_opt; /* not really required. Just to make the code more readable */
+  if (NULL != symbol->option)
+    symbol->option->accept(*this);
   void *res = symbol->located_var_decl_list->accept(*this);
   if (res == NULL) {
     current_vartype = none_vt;
+    current_option  = none_opt;
   }
   return res;
 }
@@ -345,9 +388,13 @@
 //SYM_REF2(external_var_declarations_c, option, external_declaration_list)
 void *search_var_instance_decl_c::visit(external_var_declarations_c *symbol) {
   current_vartype = external_vt;
+  current_option  = none_opt; /* not really required. Just to make the code more readable */
+  if (NULL != symbol->option)
+    symbol->option->accept(*this);
   void *res = symbol->external_declaration_list->accept(*this);
   if (res == NULL) {
     current_vartype = none_vt;
+    current_option = none_opt;
   }
   return res;
 }
@@ -357,9 +404,13 @@
 //SYM_REF2(global_var_declarations_c, option, global_var_decl_list)
 void *search_var_instance_decl_c::visit(global_var_declarations_c *symbol) {
   current_vartype = global_vt;
+  current_option  = none_opt; /* not really required. Just to make the code more readable */
+  if (NULL != symbol->option)
+    symbol->option->accept(*this);
   void *res = symbol->global_var_decl_list->accept(*this);
   if (res == NULL) {
     current_vartype = none_vt;
+    current_option = none_opt;
   }
   return res;
 }
--- a/absyntax_utils/search_var_instance_decl.hh	Sat Apr 14 16:53:35 2012 +0100
+++ b/absyntax_utils/search_var_instance_decl.hh	Sat Apr 14 18:05:50 2012 +0100
@@ -98,12 +98,14 @@
     /* variable used to store the type of variable currently being processed... */
     /* Will contain a single value of generate_c_vardecl_c::XXXX_vt */
     unsigned int current_vartype;
+    unsigned int current_option;
 
   public:
     search_var_instance_decl_c(symbol_c *search_scope);
     symbol_c *get_decl(symbol_c *variable_instance_name);
     
     unsigned int get_vartype(symbol_c *variable_instance_name);
+    unsigned int get_option(symbol_c *variable_instance_name);
 
   public:
 
@@ -118,6 +120,11 @@
     static const unsigned int global_vt   = 0x0040;  // VAR_GLOBAL
     static const unsigned int located_vt  = 0x0080;  // VAR <var_name> AT <location>
 
+    static const unsigned int none_opt        = 0x0000;
+    static const unsigned int constant_opt    = 0x0001;
+    static const unsigned int retain_opt      = 0x0002;
+    static const unsigned int non_retain_opt  = 0x0003;
+
   private:
     /***************************/
     /* B 0 - Programming Model */
@@ -131,6 +138,11 @@
     /* edge -> The F_EDGE or R_EDGE directive */
     // SYM_REF2(edge_declaration_c, edge, var1_list)
     // TODO
+    void *visit(constant_option_c *symbol);
+    void *visit(retain_option_c *symbol);
+    void *visit(non_retain_option_c *symbol);
+
+
     void *visit(input_declarations_c *symbol);
     /* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */
     /* option -> may be NULL ! */