1 #ifndef VISITORS_SIMPLIFY_HH
2 # define VISITORS_SIMPLIFY_HH
6 # include <ozulis/ast/ast.hh>
7 # include <ozulis/visitors/visitor.hh>
14 * @brief transforms an AST to 3 address instructions.
16 class Simplify
: public Visitor
<Simplify
>
22 /** @brief initialize the table of the visitor */
23 static void initBase();
25 /** @brief when you simplify lvalue, you want the pointer and not the
26 * value to be able to do a StoreVar latter */
27 ast::ExpPtr
simplifyLValue(ast::ExpPtr exp
);
28 /** @brief replaces node by it's simplified expression */
29 ast::ExpPtr
simplify(ast::ExpPtr node
);
30 /** @brief create a temporary in a register which is the result of node */
31 void makeTmpResult(ast::Exp
& node
);
33 std::string
currentId() const;
36 /// @brief the new list of 3 address instructions
37 std::vector
<ast::NodePtr
> simplifications
;
38 /// @brief the child which replace the previously visited node
39 ast::ExpPtr replacement
;
40 /// @brief the current scope, to retype check some generated expressions
44 /// @brief the next id for register count
50 #endif /* !VISITORS_SIMPLIFY_HH */