[moulette] switched to boost::signals2
[ozulis.git] / src / ozulis / visitors / simplify.hh
blobdd84b7f2605a097a278b5ca595cfbfe2150dbf8b
1 #ifndef VISITORS_SIMPLIFY_HH
2 # define VISITORS_SIMPLIFY_HH
4 # include <vector>
6 # include <ozulis/ast/ast.hh>
7 # include <ozulis/visitors/visitor.hh>
9 namespace ozulis
11 namespace visitors
13 /**
14 * @brief transforms an AST to 3 address instructions.
16 class Simplify : public Visitor<Simplify>
18 public:
19 Simplify();
20 virtual ~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;
34 std::string nextId();
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
41 ast::Scope * scope;
43 private:
44 /// @brief the next id for register count
45 int nextId_;
50 #endif /* !VISITORS_SIMPLIFY_HH */