stage3/constant_folding.hh
changeset 990 4c235d65afdd
parent 988 3b12a6cf9fbd
equal deleted inserted replaced
989:d4f8931d80cd 990:4c235d65afdd
   199 
   199 
   200 
   200 
   201 
   201 
   202 
   202 
   203 
   203 
       
   204 #include <deque>
   204 
   205 
   205 class constant_propagation_c : public constant_folding_c {
   206 class constant_propagation_c : public constant_folding_c {
   206   public:
   207   public:
   207     constant_propagation_c(symbol_c *symbol = NULL);
   208     constant_propagation_c(symbol_c *symbol = NULL);
   208     virtual ~constant_propagation_c(void);
   209     virtual ~constant_propagation_c(void);
   210   private:
   211   private:
   211     symbol_c *current_resource;
   212     symbol_c *current_resource;
   212     symbol_c *current_configuration;
   213     symbol_c *current_configuration;
   213     map_values_t *values;
   214     map_values_t *values;
   214     map_values_t var_global_values;
   215     map_values_t var_global_values;
       
   216     /* A stack of all the FB declarations currently being recursively constant propagated */
       
   217     std::deque<function_block_declaration_c *> fbs_currently_being_visited; // We use a deque instead of stack, so we can search in the stack using direct access to its elements!
       
   218 
   215     void *handle_var_list_decl(symbol_c *var_list, symbol_c *type_decl, bool is_global_var = false);
   219     void *handle_var_list_decl(symbol_c *var_list, symbol_c *type_decl, bool is_global_var = false);
   216     void *handle_var_decl     (symbol_c *var_list, bool fixed_init_value);
   220     void *handle_var_decl     (symbol_c *var_list, bool fixed_init_value);
   217     // Flag to indicate whether the variables in the variable declaration list will always have a fixed value when the POU is executed!
   221     // Flag to indicate whether the variables in the variable declaration list will always have a fixed value when the POU is executed!
   218     // VAR CONSTANT ... END_VAR will always be true
   222     // VAR CONSTANT ... END_VAR will always be true
   219     // VAR          ... END_VAR will always be true for functions (who initialise local variables every time they are called), but false for FBs and PROGRAMS
   223     // VAR          ... END_VAR will always be true for functions (who initialise local variables every time they are called), but false for FBs and PROGRAMS