Make search_base_type_c a singleton!
authorMario de Sousa <msousa@fe.up.pt>
Wed, 07 Nov 2012 20:07:11 +0000
changeset 718 a9f8cc778444
parent 717 44f74fad2cc0
child 719 19595fce59f0
Make search_base_type_c a singleton!
absyntax_utils/get_datatype_info.cc
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
stage3/declaration_check.cc
stage3/declaration_check.hh
stage3/fill_candidate_datatypes.cc
stage3/fill_candidate_datatypes.hh
stage3/lvalue_check.cc
stage3/lvalue_check.hh
stage3/narrow_candidate_datatypes.cc
stage3/narrow_candidate_datatypes.hh
stage3/print_datatypes_error.cc
stage3/print_datatypes_error.hh
stage4/generate_c/generate_c_base.cc
stage4/generate_c/generate_c_inlinefcall.cc
stage4/generate_c/generate_c_st.cc
stage4/generate_c/generate_c_typedecl.cc
stage4/generate_c/generate_location_list.cc
stage4/generate_c/generate_var_list.cc
--- a/absyntax_utils/get_datatype_info.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/absyntax_utils/get_datatype_info.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -54,7 +54,6 @@
 
 
 
-static search_base_type_c search_base_type;
 
 
 
@@ -85,7 +84,7 @@
 
 
 bool get_datatype_info_c::is_sfc_initstep(symbol_c *type_symbol) {
-  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); 
+  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
   if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   return false;
 }
@@ -95,7 +94,7 @@
 
 
 bool get_datatype_info_c::is_sfc_step(symbol_c *type_symbol) {
-  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); 
+  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
   if (typeid(*type_decl) == typeid(initial_step_c))                  {return true;}   /* INITIAL_STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   if (typeid(*type_decl) == typeid(        step_c))                  {return true;}   /*         STEP step_name ':' action_association_list END_STEP */  /* A pseudo data type! */
   return false;
@@ -105,7 +104,7 @@
 
 
 bool get_datatype_info_c::is_function_block(symbol_c *type_symbol) {
-  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); 
+  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); 
   if (typeid(*type_decl) == typeid(function_block_declaration_c))    {return true;}   /*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
   return false;
 }
@@ -115,7 +114,7 @@
 
 
 bool get_datatype_info_c::is_subrange(symbol_c *type_symbol) {
-  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol); /* NOTE: will work correctly once we update the way search_base_type_c works, by adding a new search_effective_type:c */
+  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol); /* NOTE: will work correctly once we update the way search_base_type_c works, by adding a new search_effective_type:c */
   
   if (typeid(*type_decl) == typeid(subrange_type_declaration_c))     {return true;}   /*  subrange_type_name ':' subrange_spec_init */
   if (typeid(*type_decl) == typeid(subrange_spec_init_c))            {return true;}   /* subrange_specification ASSIGN signed_integer */
@@ -130,7 +129,7 @@
 
 
 bool get_datatype_info_c::is_enumerated(symbol_c *type_symbol) {
-  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol);
+  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
   
   if (typeid(*type_decl) == typeid(enumerated_type_declaration_c))   {return true;}   /*  enumerated_type_name ':' enumerated_spec_init */
   if (typeid(*type_decl) == typeid(enumerated_spec_init_c))          {return true;}   /* enumerated_specification ASSIGN enumerated_value */
@@ -145,7 +144,7 @@
 
 
 bool get_datatype_info_c::is_array(symbol_c *type_symbol) {
-  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol);
+  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
   
   if (typeid(*type_decl) == typeid(array_type_declaration_c))        {return true;}   /*  identifier ':' array_spec_init */
   if (typeid(*type_decl) == typeid(array_spec_init_c))               {return true;}   /* array_specification [ASSIGN array_initialization} */
@@ -162,7 +161,7 @@
 
 
 bool get_datatype_info_c::is_structure(symbol_c *type_symbol) {
-  symbol_c *type_decl = search_base_type.get_basetype_decl(type_symbol);
+  symbol_c *type_decl = search_base_type_c::get_basetype_decl(type_symbol);
   
   if (typeid(*type_decl) == typeid(structure_type_declaration_c))              {return true;}   /*  structure_type_name ':' structure_specification */
   if (typeid(*type_decl) == typeid(initialized_structure_c))                   {return true;}   /* structure_type_name ASSIGN structure_initialization */
--- a/absyntax_utils/search_base_type.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/absyntax_utils/search_base_type.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -49,43 +49,55 @@
 #include "../main.hh" // required for ERROR() and ERROR_MSG() macros.
 
 
+/* pointer to singleton instance */
+search_base_type_c *search_base_type_c::search_base_type_singleton = NULL;
+
+
 
 search_base_type_c::search_base_type_c(void) {current_type_name = NULL;}
 
-
-
-
+/* static method! */
+void search_base_type_c::create_singleton(void) {
+  if (NULL == search_base_type_singleton)   search_base_type_singleton = new search_base_type_c();
+  if (NULL == search_base_type_singleton)   ERROR;
+}
+
+/* static method! */
 symbol_c *search_base_type_c::get_basetype_decl(symbol_c *symbol) {
-  if (NULL == symbol)
-    return NULL;
+  create_singleton();
+  if (NULL == symbol)    return NULL; 
+  return (symbol_c *)symbol->accept(*search_base_type_singleton);
+}
+
+/* static method! */
+symbol_c *search_base_type_c::get_basetype_id  (symbol_c *symbol) {
+  create_singleton();
+  if (NULL == symbol)    return NULL;
   
-  return (symbol_c *)symbol->accept(*this);
-}
-
-symbol_c *search_base_type_c::get_basetype_id  (symbol_c *symbol) {
-  if (NULL == symbol)
-    return NULL;
-  
-  current_type_name = NULL; /* just to be on the safe side... */
-  symbol->accept(*this);
-  return (symbol_c *)current_type_name;
+  search_base_type_singleton->current_type_name = NULL;
+  symbol->accept(*search_base_type_singleton);
+  return (symbol_c *)search_base_type_singleton->current_type_name;
 }
 
 
 /* Note by MJS: The following two functions definately do not belong in this class!! Maybe create a new utility class?
  * I will need to clean this up when the opportunity arises!
  */
-
+/* static method! */
 bool search_base_type_c::type_is_subrange(symbol_c* type_decl) {
-  this->is_subrange = false;
-  type_decl->accept(*this);
-  return this->is_subrange;
-}
-
+  create_singleton();
+  search_base_type_singleton->is_subrange = false;
+  type_decl->accept(*search_base_type_singleton);
+  return search_base_type_singleton->is_subrange;
+}
+
+
+/* static method! */
 bool search_base_type_c::type_is_enumerated(symbol_c* type_decl) {
-  this->is_enumerated = false;
-  type_decl->accept(*this);
-  return this->is_enumerated;
+  create_singleton();
+  search_base_type_singleton->is_enumerated = false;
+  type_decl->accept(*search_base_type_singleton);
+  return search_base_type_singleton->is_enumerated;
 }
 
 
--- a/absyntax_utils/search_base_type.hh	Wed Nov 07 19:26:38 2012 +0000
+++ b/absyntax_utils/search_base_type.hh	Wed Nov 07 20:07:11 2012 +0000
@@ -55,15 +55,17 @@
     bool is_array;
     bool is_subrange;
     bool is_enumerated;
+    static search_base_type_c *search_base_type_singleton; // Make this a singleton class!
+    
+  private:  
+    static void create_singleton(void);
 
   public:
     search_base_type_c(void);
-
-  public:
-    symbol_c *get_basetype_decl(symbol_c *symbol);
-    symbol_c *get_basetype_id  (symbol_c *symbol);
-    bool type_is_subrange(symbol_c* type_decl);
-    bool type_is_enumerated(symbol_c* type_decl);
+    static symbol_c *get_basetype_decl (symbol_c *symbol);
+    static symbol_c *get_basetype_id   (symbol_c *symbol);
+    static bool      type_is_subrange  (symbol_c *type_decl);
+    static bool      type_is_enumerated(symbol_c *type_decl);
 
   public:
   /*************************/
--- a/absyntax_utils/search_var_instance_decl.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/absyntax_utils/search_var_instance_decl.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -132,11 +132,10 @@
 #include <typeinfo>  /* required for typeid() */
 bool search_var_instance_decl_c::type_is_complex(symbol_c *symbol) {
   symbol_c *decl;
-  search_base_type_c search_base_type;
   
   decl = this->get_decl(symbol);
   if (NULL == decl) ERROR;
-  decl = search_base_type.get_basetype_decl(decl);
+  decl = search_base_type_c::get_basetype_decl(decl);
   if (NULL == decl) ERROR;
   
   return ((typeid( *(decl) ) == typeid( array_specification_c                )) ||
--- a/absyntax_utils/search_varfb_instance_type.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/absyntax_utils/search_varfb_instance_type.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -136,8 +136,8 @@
   /* symbol should be a variable name!! */
   /* Note: although the method is called get_decl(), it is getting the declaration of the variable, which for us is the type_id of that variable! */
   current_type_id       = search_var_instance_decl.get_decl (variable_name);
-  current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
-  current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
+  current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
+  current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
     
   /* What if the variable has not been declared?  Then this should not be a compiler error! 
    * However, currently stage 2 of the compiler already detects when variables have not been delcared,
@@ -193,8 +193,8 @@
 void *search_varfb_instance_type_c::visit(array_specification_c *symbol) {
   /* found the type of the element we were looking for! */
   current_type_id       = symbol->non_generic_type_name;
-  current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
-  current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
+  current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
+  current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
     
   return NULL; 
 }
@@ -256,8 +256,8 @@
   if (compare_identifiers(symbol->structure_element_name, current_field_selector) == 0) {
     /* found the type of the element we were looking for! */
     current_type_id       = symbol->spec_init;
-    current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
-    current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
+    current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
+    current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
   }  
 
   /* Did not find the type of the element we were looking for! */
@@ -363,8 +363,8 @@
   /* If not found, these pointers will all be set to NULL!! */
   search_var_instance_decl_c search_decl(symbol);
   current_type_id       = search_decl.get_decl(current_field_selector);
-  current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
-  current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
+  current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
+  current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
   
   return NULL;
 }
@@ -389,8 +389,8 @@
   if (compare_identifiers(&X, current_field_selector) == 0)   
     current_type_id = &get_datatype_info_c::bool_type_name;
   
-  current_basetype_decl = search_base_type.get_basetype_decl(current_type_id);
-  current_basetype_id   = search_base_type.get_basetype_id  (current_type_id);
+  current_basetype_decl = search_base_type_c::get_basetype_decl(current_type_id);
+  current_basetype_id   = search_base_type_c::get_basetype_id  (current_type_id);
 
   return NULL;
 }
--- a/absyntax_utils/search_varfb_instance_type.hh	Wed Nov 07 19:26:38 2012 +0000
+++ b/absyntax_utils/search_varfb_instance_type.hh	Wed Nov 07 20:07:11 2012 +0000
@@ -89,7 +89,6 @@
 
   private:
     search_var_instance_decl_c search_var_instance_decl;
-    search_base_type_c         search_base_type;
 
 //  symbol_c *current_type_decl;
     symbol_c *current_type_id;
--- a/stage3/declaration_check.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/declaration_check.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -86,7 +86,6 @@
 
 void declaration_check_c::check_global_decl(symbol_c *p_decl) {
 	symbol_c *var_name;
-	search_base_type_c search_base_type;
 
 	search_var_instance_decl_c search_var_instance_glo_decl(current_pou_decl);
 	search_var_instance_decl_c search_var_instance_ext_decl(p_decl);
@@ -109,8 +108,8 @@
          *  symbol_c *ext_type = fpi.param_type();
 	 */
 	/* For the moment, we will just use search_base_type_c instead... */
-        symbol_c *glo_type = search_base_type.get_basetype_decl(glo_decl);
-        symbol_c *ext_type = search_base_type.get_basetype_decl(ext_decl);
+        symbol_c *glo_type = search_base_type_c::get_basetype_decl(glo_decl);
+        symbol_c *ext_type = search_base_type_c::get_basetype_decl(ext_decl);
         if (! get_datatype_info_c::is_type_equal(glo_type, ext_type))
           STAGE3_ERROR(0, ext_decl, ext_decl, "Declaration error an external redefinition data type.");
       }
--- a/stage3/declaration_check.hh	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/declaration_check.hh	Wed Nov 07 20:07:11 2012 +0000
@@ -38,7 +38,6 @@
 class declaration_check_c : public iterator_visitor_c {
     int error_count;
     int current_display_error_level;
-    search_base_type_c search_base_type;
     symbol_c *current_pou_decl;
 
 public:
--- a/stage3/fill_candidate_datatypes.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/fill_candidate_datatypes.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -533,11 +533,10 @@
  * This possibility os not expressed in the 'widening' tables, so we need to hard code it here
  */
 void *fill_candidate_datatypes_c::handle_equality_comparison(const struct widen_entry widen_table[], symbol_c *symbol, symbol_c *l_expr, symbol_c *r_expr) {
-	search_base_type_c search_base_type;
 	handle_binary_expression(widen_table, symbol, l_expr, r_expr);
 	for(unsigned int i = 0; i < l_expr->candidate_datatypes.size(); i++)
 		for(unsigned int j = 0; j < r_expr->candidate_datatypes.size(); j++) {
-			if ((l_expr->candidate_datatypes[i] == r_expr->candidate_datatypes[j]) && search_base_type.type_is_enumerated(l_expr->candidate_datatypes[i]))
+			if ((l_expr->candidate_datatypes[i] == r_expr->candidate_datatypes[j]) && search_base_type_c::type_is_enumerated(l_expr->candidate_datatypes[i]))
 				add_datatype_to_candidate_list(symbol, &get_datatype_info_c::bool_type_name);
 		}
 	return NULL;
@@ -547,11 +546,9 @@
 
 /* a helper function... */
 symbol_c *fill_candidate_datatypes_c::base_type(symbol_c *symbol) {
-	/* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used
-	 *       in the code.
-	 */
+	/* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used in the code. */
 	if (symbol == NULL) return NULL;
-	return (symbol_c *)symbol->accept(search_base_type);
+	return search_base_type_c::get_basetype_decl(symbol);
 }
 
 /*********************/
--- a/stage3/fill_candidate_datatypes.hh	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/fill_candidate_datatypes.hh	Wed Nov 07 20:07:11 2012 +0000
@@ -53,7 +53,6 @@
 
   private:
     search_varfb_instance_type_c *search_varfb_instance_type;
-    search_base_type_c search_base_type;
     /* When calling a function block, we must first find it's type,
      * by searching through the declarations of the variables currently
      * in scope.
--- a/stage3/lvalue_check.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/lvalue_check.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -107,7 +107,6 @@
  */
 void lvalue_check_c::check_assignment_to_output(symbol_c *lvalue) {
 	decompose_var_instance_name_c decompose_lvalue(lvalue);
-	search_base_type_c            search_base_type;
 
 	/* Get the first element/record of the potentially structured variable symbol */
 	/* Note that if symbol is pointing to an expression (or simply a literal value), it will return a NULL.
@@ -120,7 +119,7 @@
 	
 	symbol_c *type_decl   = search_var_instance_decl->get_decl(struct_elem);
 	// symbol_c *type_id  = spec_init_sperator_c::get_spec(type_decl); /* this is not required! search_base_type_c can handle spec_init symbols! */
-	symbol_c *basetype_id = search_base_type.get_basetype_id(/*type_id*/ type_decl);
+	symbol_c *basetype_id = search_base_type_c::get_basetype_id(/*type_id*/ type_decl);
 	/* If we can not determine the data type of the element, then the code must have a data type semantic error.
 	 * This will have been caught by the data type semantic verifier, so we do not bother with this anymore!
 	 */
@@ -145,7 +144,7 @@
 
 		/* prepare for any possible further record/structure elements */
 		type_decl   = fb_search_var_instance_decl.get_decl(struct_elem);
-		basetype_id = search_base_type.get_basetype_id(type_decl);
+		basetype_id = search_base_type_c::get_basetype_id(type_decl);
 		if (NULL == basetype_id) return; /* same comment as above... */
 		fb_decl = function_block_type_symtable.find_value(basetype_id);
 		if (function_block_type_symtable.end_value() == fb_decl) return; /* same comment as above... */
--- a/stage3/lvalue_check.hh	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/lvalue_check.hh	Wed Nov 07 20:07:11 2012 +0000
@@ -50,7 +50,6 @@
   private:
     search_varfb_instance_type_c *search_varfb_instance_type;
     search_var_instance_decl_c *search_var_instance_decl;
-    search_base_type_c search_base_type;
     int error_count;
     int current_display_error_level;
     std::vector <token_c *> control_variables;
--- a/stage3/narrow_candidate_datatypes.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/narrow_candidate_datatypes.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -409,11 +409,9 @@
 
 /* a helper function... */
 symbol_c *narrow_candidate_datatypes_c::base_type(symbol_c *symbol) {
-	/* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used
-	 *       in the code.
-	 */
+	/* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used in the code. */
 	if (symbol == NULL) return NULL;
-	return (symbol_c *)symbol->accept(search_base_type);	
+	return search_base_type_c::get_basetype_decl(symbol);
 }
 
 /*********************/
@@ -1082,7 +1080,6 @@
 void *narrow_candidate_datatypes_c::narrow_binary_expression(const struct widen_entry widen_table[], symbol_c *symbol, symbol_c *l_expr, symbol_c *r_expr, bool *deprecated_operation, bool allow_enums) {
 	symbol_c *l_type, *r_type;
 	int count = 0;
-	search_base_type_c search_base_type;
 
 	if (NULL != deprecated_operation)
 		*deprecated_operation = false;
@@ -1096,7 +1093,7 @@
 				l_expr->datatype = l_type;
 				r_expr->datatype = r_type;
 				count ++;
-			} else if ((l_type == r_type) && search_base_type.type_is_enumerated(l_type) && get_datatype_info_c::is_BOOL_compatible(symbol->datatype)) {
+			} else if ((l_type == r_type) && search_base_type_c::type_is_enumerated(l_type) && get_datatype_info_c::is_BOOL_compatible(symbol->datatype)) {
 				if (NULL != deprecated_operation)  *deprecated_operation = false;
 				l_expr->datatype = l_type;
 				r_expr->datatype = r_type;
@@ -1252,7 +1249,7 @@
 void *narrow_candidate_datatypes_c::visit(case_statement_c *symbol) {
 	for (unsigned int i = 0; i < symbol->expression->candidate_datatypes.size(); i++) {
 		if ((get_datatype_info_c::is_ANY_INT(symbol->expression->candidate_datatypes[i]))
-				 || (search_base_type.type_is_enumerated(symbol->expression->candidate_datatypes[i])))
+				 || (search_base_type_c::type_is_enumerated(symbol->expression->candidate_datatypes[i])))
 			symbol->expression->datatype = symbol->expression->candidate_datatypes[i];
 	}
 	symbol->expression->accept(*this);
--- a/stage3/narrow_candidate_datatypes.hh	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/narrow_candidate_datatypes.hh	Wed Nov 07 20:07:11 2012 +0000
@@ -65,7 +65,6 @@
 
   private:
     search_varfb_instance_type_c *search_varfb_instance_type;
-    search_base_type_c search_base_type;
     symbol_c *il_operand;
     il_instruction_c *fake_prev_il_instruction;
     il_instruction_c   *current_il_instruction;
--- a/stage3/print_datatypes_error.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/print_datatypes_error.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -116,16 +116,6 @@
 
 
 
-/* a helper function... */
-symbol_c *print_datatypes_error_c::base_type(symbol_c *symbol) {
-	/* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used
-	 *       in the code.
-	 */
-	if (symbol == NULL) return NULL;
-	return (symbol_c *)symbol->accept(search_base_type);
-}
-
-
 
 /*
 typedef struct {
--- a/stage3/print_datatypes_error.hh	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage3/print_datatypes_error.hh	Wed Nov 07 20:07:11 2012 +0000
@@ -58,7 +58,6 @@
     unsigned int current_display_error_level;
     
     search_varfb_instance_type_c *search_varfb_instance_type;
-    search_base_type_c search_base_type;
     /* When calling a function block, we must first find it's type,
      * by searching through the declarations of the variables currently
      * in scope.
@@ -98,7 +97,6 @@
     symbol_c *il_operand;
 
     /* some helper functions... */
-    symbol_c *base_type(symbol_c *symbol);
     void handle_function_invocation(symbol_c *fcall, generic_function_call_t fcall_data);
     void *handle_implicit_il_fb_invocation(const char *param_name, symbol_c *il_operator, symbol_c *called_fb_declaration);  
     void *handle_conditional_flow_control_IL_instruction(symbol_c *symbol, const char *oper);
--- a/stage4/generate_c/generate_c_base.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage4/generate_c/generate_c_base.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -227,8 +227,7 @@
           symbol_c *value,
           symbol_c *fb_name = NULL,
           bool temp = false) {
-      search_base_type_c search_base_type;
-      bool is_subrange = search_base_type.type_is_subrange(type);
+      bool is_subrange = search_base_type_c::type_is_subrange(type);
       if (is_subrange) {
 		s4o.print("__CHECK_");
 		type->accept(*this);
--- a/stage4/generate_c/generate_c_inlinefcall.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage4/generate_c/generate_c_inlinefcall.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -72,8 +72,6 @@
     search_varfb_instance_type_c *search_varfb_instance_type;
     search_var_instance_decl_c   *search_var_instance_decl;
 
-    search_base_type_c search_base_type;
-
     variablegeneration_t wanted_variablegeneration;
 
   public:
@@ -422,8 +420,7 @@
       if (f_decl == NULL) ERROR;
       
       /* determine the base data type returned by the function being called... */
-      search_base_type_c search_base_type;
-      function_type_prefix = (symbol_c *)f_decl->type_name->accept(search_base_type);
+      function_type_prefix = search_base_type_c::get_basetype_decl(f_decl->type_name);
       
       function_name = symbol->function_name;      
       
@@ -583,8 +580,7 @@
       if (f_decl == NULL) ERROR;
 
       /* determine the base data type returned by the function being called... */
-      search_base_type_c search_base_type;
-      function_type_prefix = (symbol_c *)f_decl->type_name->accept(search_base_type);
+      function_type_prefix = search_base_type_c::get_basetype_decl(f_decl->type_name);
       if (NULL == function_type_prefix) ERROR;
       
       function_name = symbol->function_name;
@@ -755,8 +751,7 @@
       function_name = symbol->function_name;
 
       /* determine the base data type returned by the function being called... */
-      search_base_type_c search_base_type;
-      function_type_prefix = (symbol_c *)f_decl->type_name->accept(search_base_type);
+      function_type_prefix = search_base_type_c::get_basetype_decl(f_decl->type_name);
       if (NULL == function_type_prefix) ERROR;
 
       /* loop through each function parameter, find the value we should pass
--- a/stage4/generate_c/generate_c_st.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage4/generate_c/generate_c_st.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -81,8 +81,6 @@
     search_varfb_instance_type_c *search_varfb_instance_type;
     search_var_instance_decl_c   *search_var_instance_decl;
 
-    search_base_type_c search_base_type;
-
     symbol_c* current_array_type;
     symbol_c* current_param_type;
 
--- a/stage4/generate_c/generate_c_typedecl.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage4/generate_c/generate_c_typedecl.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -31,7 +31,6 @@
   private:
     symbol_c* current_type_name;
     bool array_is_derived;
-    search_base_type_c search_base_type;
 
     generate_c_base_c *basedecl;
 
@@ -206,7 +205,7 @@
           s4o.print(" value) {\n");
           s4o.indent_right();
 
-          if (search_base_type.type_is_subrange(symbol->integer_type_name)) {
+          if (search_base_type_c::type_is_subrange(symbol->integer_type_name)) {
             s4o.print(s4o.indent_spaces + "value = __CHECK_");
             symbol->integer_type_name->accept(*this);
             s4o.print("(value);\n");
@@ -434,7 +433,7 @@
   symbol->simple_spec_init->accept(*this);
   s4o_incl.print(")\n");
 
-  if (search_base_type.type_is_subrange(symbol->simple_type_name)) {
+  if (search_base_type_c::type_is_subrange(symbol->simple_type_name)) {
 	s4o.print("#define __CHECK_");
 	current_type_name->accept(*this);
 	s4o.print(" __CHECK_");
--- a/stage4/generate_c/generate_location_list.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage4/generate_c/generate_location_list.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -30,7 +30,6 @@
   private:
     symbol_c *current_var_type_symbol;
     generate_c_base_c *generate_c_base;
-    search_base_type_c search_base_type;
     
   public:
     generate_location_list_c(stage4out_c *s4o_ptr): s4o(*s4o_ptr) {
@@ -114,7 +113,7 @@
         if (current_var_type_symbol == NULL)
           ERROR;
         
-        current_var_type_symbol = (symbol_c *)(current_var_type_symbol->accept(search_base_type));
+        current_var_type_symbol = search_base_type_c::get_basetype_decl(current_var_type_symbol);
         if (current_var_type_symbol == NULL)
           ERROR;
         
@@ -132,7 +131,7 @@
         if (current_var_type_symbol == NULL)
           ERROR;
         
-        current_var_type_symbol = (symbol_c *)(current_var_type_symbol->accept(search_base_type));
+        current_var_type_symbol = search_base_type_c::get_basetype_decl(current_var_type_symbol);
         if (current_var_type_symbol == NULL)
           ERROR;
         
--- a/stage4/generate_c/generate_var_list.cc	Wed Nov 07 19:26:38 2012 +0000
+++ b/stage4/generate_c/generate_var_list.cc	Wed Nov 07 20:07:11 2012 +0000
@@ -107,7 +107,6 @@
   private:
     symbol_c *current_var_type_symbol;
     symbol_c *current_var_type_name;
-    search_base_type_c search_base_type;
     search_fb_typedecl_c *search_fb_typedecl;
 
   public:
@@ -153,7 +152,7 @@
           this->current_var_type_category = function_block_vtc;
 
         else {
-          this->current_var_type_symbol = (symbol_c *)(this->current_var_type_name->accept(search_base_type));
+          this->current_var_type_symbol = search_base_type_c::get_basetype_decl(this->current_var_type_name);
           this->current_var_type_symbol->accept(*this);
         }
       }