ilasynth  1.0
ILASynth: Template-based ILA Synthesis Engine
rewriter.hpp
Go to the documentation of this file.
1 #ifndef __REWRITER_HPP_DEFINED__
2 #define __REWRITER_HPP_DEFINED__
3 
4 #include <ilasynth/ast.hpp>
5 #include <ilasynth/common.hpp>
6 #include <unordered_map>
7 
8 namespace ilasynth {
9 // A function object that rewrites the AST according to the result
10 // of the synthesis.
11 class Rewriter {
12 public:
13  // Define types.
14 protected:
15  // the map between old and new nodes.
17 
18  // find the rewritten args.
19  void getNewArgs(const Node* n, nptr_vec_t& args);
20 
21  // get the nodes' replacement.
22  nptr_t getRepl(const Node* n) const;
23 
24  // do the actual rewriting.
25  void doRewrite(const Node* n);
26 
27 public:
28  // Constructor.
29  Rewriter();
30 
31  // Destructor.
32  ~Rewriter();
33 
34  // This is used by depthFirstVisit.
35  void operator()(const Node* n);
36 
37  // do the rewrite.
38  nptr_t rewrite(const Node* n);
39 
40  // add a node to be rewritten.
41  void addRewrite(const Node* n, const nptr_t& nprime);
42 };
43 } // namespace ilasynth
44 #endif
nptr_t getRepl(const Node *n) const
void operator()(const Node *n)
void doRewrite(const Node *n)
nptr_t rewrite(const Node *n)
void getNewArgs(const Node *n, nptr_vec_t &args)
std::vector< nptr_t > nptr_vec_t
Definition: node.hpp:27
boost::shared_ptr< Node > nptr_t
Definition: node.hpp:24
Definition: abstraction.hpp:21
Definition: node.hpp:55
Definition: rewriter.hpp:11
rwmap_t rwmap
Definition: rewriter.hpp:16
void addRewrite(const Node *n, const nptr_t &nprime)
std::unordered_map< const Node *, nptr_t, decltype(&nodeHash), decltype(&nodeEqual)> rwmap_t
Definition: node.hpp:177