[visitors] ported llvm asm generator
[ozulis.git] / src / ozulis / visitors / simplify.hh
blob07b8af08565e1c5ebdd8324a81694549be6ad81b
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 static void initBase();
24 void simplifyLValue(ast::Exp *& exp);
25 void simplify(ast::Exp *& node);
26 void makeTmpResult(ast::Exp & node);
28 std::string currentId() const;
29 std::string nextId();
31 /// @brief the new list of 3 address instructions
32 std::vector<ast::Node *> simplifications;
33 /// @brief the child which replace the previously visited node
34 ast::Exp * replacement;
35 /// @brief the next id for register count
36 int nextId_;
37 /// @brief the current scope, to retype check some generated expressions
38 ast::Scope * scope;
43 #endif /* !VISITORS_SIMPLIFY_HH */