diff options
author | chriseth <c@ethdev.com> | 2015-05-20 06:27:07 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-05-20 06:28:15 +0800 |
commit | 2be64c702609df67903fd89c42cf632d71aad6fd (patch) | |
tree | ceb573ff287d81f47d75acbf8481eab631aa8081 /ASTVisitor.h | |
parent | 70d9eb3f1d1e16757c8f9b66669cd0f38d7bfef7 (diff) | |
download | dexon-solidity-2be64c702609df67903fd89c42cf632d71aad6fd.tar.gz dexon-solidity-2be64c702609df67903fd89c42cf632d71aad6fd.tar.zst dexon-solidity-2be64c702609df67903fd89c42cf632d71aad6fd.zip |
Gas estimation taking known state into account.
Diffstat (limited to 'ASTVisitor.h')
-rw-r--r-- | ASTVisitor.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ASTVisitor.h b/ASTVisitor.h index fbda5079..f7847220 100644 --- a/ASTVisitor.h +++ b/ASTVisitor.h @@ -221,6 +221,26 @@ protected: }; /** + * Utility class that accepts std::functions and calls them for visitNode and endVisitNode. + */ +class SimpleASTVisitor: public ASTConstVisitor +{ +public: + SimpleASTVisitor( + std::function<bool(ASTNode const&)> _onVisit, + std::function<void(ASTNode const&)> _onEndVisit + ): m_onVisit(_onVisit), m_onEndVisit(_onEndVisit) {} + +protected: + virtual bool visitNode(ASTNode const& _n) override { return m_onVisit ? m_onVisit(_n) : true; } + virtual void endVisitNode(ASTNode const& _n) override { m_onEndVisit(_n); } + +private: + std::function<bool(ASTNode const&)> m_onVisit; + std::function<void(ASTNode const&)> m_onEndVisit; +}; + +/** * Utility class that visits the AST in depth-first order and calls a function on each node and each edge. * Child nodes are only visited if the node callback of the parent returns true. * The node callback of a parent is called before any edge or node callback involving the children. |