stage3/constant_folding.hh
changeset 969 706a152731ab
parent 967 544ff4dff04f
child 973 f86d5d6bb04e
equal deleted inserted replaced
968:649e03abbfc1 969:706a152731ab
    59     /* Pointer to the previous IL instruction, which contains the current cvalue of the data stored in the IL stack, i.e. the default variable, a.k.a. accumulator */
    59     /* Pointer to the previous IL instruction, which contains the current cvalue of the data stored in the IL stack, i.e. the default variable, a.k.a. accumulator */
    60     symbol_c *prev_il_instruction;
    60     symbol_c *prev_il_instruction;
    61     /* the current IL operand being analyzed */
    61     /* the current IL operand being analyzed */
    62     symbol_c *il_operand;
    62     symbol_c *il_operand;
    63 
    63 
       
    64 
       
    65 
    64   public:
    66   public:
    65 	constant_folding_c(symbol_c *symbol = NULL);
    67     constant_folding_c(symbol_c *symbol = NULL);
    66 	virtual ~constant_folding_c(void);
    68     virtual ~constant_folding_c(void);
    67 	int get_error_count();
    69     int get_error_count();
    68 	int handle_var_extern_global_pair(symbol_c *extern_var_name, symbol_c *extern_var_decl, symbol_c *global_var_name, symbol_c *global_var_decl);
    70     int handle_var_extern_global_pair(symbol_c *extern_var_name, symbol_c *extern_var_decl, symbol_c *global_var_name, symbol_c *global_var_decl);
       
    71     typedef std::map <std::string, const_value_c> map_values_t;
    69   private:
    72   private:
    70 	void *handle_var_list_decl(symbol_c *var_list, symbol_c *type_decl);
    73     map_values_t values;
    71 	void *handle_var_decl     (symbol_c *var_list, bool fixed_init_value);
    74     void *handle_var_list_decl(symbol_c *var_list, symbol_c *type_decl);
    72 	// Flag to indicate whether the variables in the variable declaration list will always have a fixed value when the POU is executed!
    75     void *handle_var_decl     (symbol_c *var_list, bool fixed_init_value);
    73 	// VAR CONSTANT ... END_VAR will always be true
    76     // Flag to indicate whether the variables in the variable declaration list will always have a fixed value when the POU is executed!
    74 	// VAR          ... END_VAR will always be true for functions (who initialise local variables every time they are called), but false for FBs and PROGRAMS
    77     // VAR CONSTANT ... END_VAR will always be true
    75 	bool fixed_init_value_; 
    78     // VAR          ... END_VAR will always be true for functions (who initialise local variables every time they are called), but false for FBs and PROGRAMS
    76 	bool function_pou_;
    79     bool fixed_init_value_; 
    77 	bool is_constant(symbol_c *option);
    80     bool function_pou_;
    78 	bool is_retain  (symbol_c *option);
    81     bool is_constant(symbol_c *option);
       
    82     bool is_retain  (symbol_c *option);
    79 
    83 
    80 
    84 
    81   public:
    85   public:
    82 	#if 0
    86 	#if 0
    83 	// not currently needed, so comment it out!...
    87 	// not currently needed, so comment it out!...
   122     void *visit(symbolic_constant_c *symbol);
   126     void *visit(symbolic_constant_c *symbol);
   123                              
   127                              
   124     /******************************************/
   128     /******************************************/
   125     /* B 1.4.3 - Declaration & Initialisation */
   129     /* B 1.4.3 - Declaration & Initialisation */
   126     /******************************************/
   130     /******************************************/
   127     void *visit(var1_init_decl_c             *symbol);
       
   128     void *visit(        input_declarations_c *symbol);
   131     void *visit(        input_declarations_c *symbol);
   129     void *visit(       output_declarations_c *symbol);
   132     void *visit(       output_declarations_c *symbol);
   130     void *visit( input_output_declarations_c *symbol);
   133     void *visit( input_output_declarations_c *symbol);
   131     void *visit(          var_declarations_c *symbol);
   134     void *visit(          var_declarations_c *symbol);
   132     void *visit(retentive_var_declarations_c *symbol);
   135     void *visit(retentive_var_declarations_c *symbol);
   133     void *visit( external_var_declarations_c *symbol);
   136     void *visit( external_var_declarations_c *symbol);
   134     void *visit(external_declaration_c       *symbol);
   137     void *visit(   global_var_declarations_c *symbol);
       
   138     void *visit(  external_declaration_c     *symbol);
       
   139     void *visit(global_var_decl_c            *symbol);
       
   140     void *visit( var1_init_decl_c            *symbol);
   135 
   141 
   136     /**************************************/
   142     /**************************************/
   137     /* B.1.5 - Program organization units */
   143     /* B.1.5 - Program organization units */
   138     /**************************************/
   144     /**************************************/
   139     /***********************/
   145     /***********************/
   150     void *visit(   non_retentive_var_decls_c *symbol);
   156     void *visit(   non_retentive_var_decls_c *symbol);
   151 
   157 
   152     /**********************/
   158     /**********************/
   153     /* B 1.5.3 - Programs */
   159     /* B 1.5.3 - Programs */
   154     /**********************/
   160     /**********************/
   155     void *visit(program_declaration_c *symbol);
   161     void *visit(       program_declaration_c *symbol);
       
   162 
       
   163     /********************************/
       
   164     /* B 1.7 Configuration elements */
       
   165     /********************************/
       
   166     void *visit( configuration_declaration_c *symbol);
       
   167     void *visit(      resource_declaration_c *symbol);
   156 
   168 
   157 
   169 
   158     /****************************************/
   170     /****************************************/
   159     /* B.2 - Language IL (Instruction List) */
   171     /* B.2 - Language IL (Instruction List) */
   160     /****************************************/
   172     /****************************************/