stage3/constant_folding.hh
changeset 796 73e14a2ce5d1
parent 792 78083edf93d5
child 945 477393b00f95
equal deleted inserted replaced
795:9c1bca18d3fa 796:73e14a2ce5d1
    39  *       etc...
    39  *       etc...
    40  */
    40  */
    41 
    41 
    42 #include <vector>
    42 #include <vector>
    43 #include "../absyntax_utils/absyntax_utils.hh"
    43 #include "../absyntax_utils/absyntax_utils.hh"
       
    44 
       
    45 
       
    46 
       
    47 /* For the moment we disable constant propagation algorithm as it is not yet complete, 
       
    48  * and due to this is currently brocken and producing incorrect results!
       
    49  */
       
    50 #define DO_CONSTANT_PROPAGATION__ 0
       
    51 
    44 
    52 
    45 
    53 
    46 class constant_folding_c : public iterator_visitor_c {
    54 class constant_folding_c : public iterator_visitor_c {
    47     search_varfb_instance_type_c *search_varfb_instance_type;
    55     search_varfb_instance_type_c *search_varfb_instance_type;
    48     int error_count;
    56     int error_count;
    85     void *visit(fixed_point_c *symbol);
    93     void *visit(fixed_point_c *symbol);
    86 
    94 
    87     /*********************/
    95     /*********************/
    88     /* B 1.4 - Variables */
    96     /* B 1.4 - Variables */
    89     /*********************/
    97     /*********************/
       
    98     #if DO_CONSTANT_PROPAGATION__
    90     void *visit(symbolic_variable_c *symbol);
    99     void *visit(symbolic_variable_c *symbol);
       
   100     #endif
    91 
   101 
    92     /**********************/
   102     /**********************/
    93     /* B 1.5.3 - Programs */
   103     /* B 1.5.3 - Programs */
    94     /**********************/
   104     /**********************/
       
   105     #if DO_CONSTANT_PROPAGATION__
    95     void *visit(program_declaration_c *symbol);
   106     void *visit(program_declaration_c *symbol);
       
   107     #endif
    96 
   108 
    97     /****************************************/
   109     /****************************************/
    98     /* B.2 - Language IL (Instruction List) */
   110     /* B.2 - Language IL (Instruction List) */
    99     /****************************************/
   111     /****************************************/
   100     /***********************************/
   112     /***********************************/
   186     void *visit(   neg_expression_c *symbol);
   198     void *visit(   neg_expression_c *symbol);
   187     void *visit(   not_expression_c *symbol);
   199     void *visit(   not_expression_c *symbol);
   188     //void *visit(function_invocation_c *symbol); /* TODO */
   200     //void *visit(function_invocation_c *symbol); /* TODO */
   189 
   201 
   190     
   202     
       
   203     #if DO_CONSTANT_PROPAGATION__
   191     /*********************************/
   204     /*********************************/
   192     /* B 3.2.1 Assignment Statements */
   205     /* B 3.2.1 Assignment Statements */
   193     /*********************************/
   206     /*********************************/
   194     void *visit(assignment_statement_c *symbol);
   207     void *visit(assignment_statement_c *symbol);
   195 
   208 
   202     /* B 3.2.4 Iteration Statements */
   215     /* B 3.2.4 Iteration Statements */
   203     /********************************/
   216     /********************************/
   204     void *visit(for_statement_c *symbol);
   217     void *visit(for_statement_c *symbol);
   205     void *visit(while_statement_c *symbol);
   218     void *visit(while_statement_c *symbol);
   206     void *visit(repeat_statement_c *symbol);
   219     void *visit(repeat_statement_c *symbol);
       
   220     #endif // DO_CONSTANT_PROPAGATION__
   207 };
   221 };
   208 
   222