aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/ConstantEvaluator.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-11-22 19:54:23 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-12-12 17:44:18 +0800
commit48c7ba72f3616a037fe3fe8cf1a490b121c416e3 (patch)
tree9bdcea998fa7e34d564d38510a34fef70f2c053f /libsolidity/analysis/ConstantEvaluator.h
parent7ff9a85592cbb50b7a72654849582c780d7fc494 (diff)
downloaddexon-solidity-48c7ba72f3616a037fe3fe8cf1a490b121c416e3.tar.gz
dexon-solidity-48c7ba72f3616a037fe3fe8cf1a490b121c416e3.tar.zst
dexon-solidity-48c7ba72f3616a037fe3fe8cf1a490b121c416e3.zip
Simplify ConstantEvaluator.
Diffstat (limited to 'libsolidity/analysis/ConstantEvaluator.h')
-rw-r--r--libsolidity/analysis/ConstantEvaluator.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/libsolidity/analysis/ConstantEvaluator.h b/libsolidity/analysis/ConstantEvaluator.h
index 6725d610..77a357b6 100644
--- a/libsolidity/analysis/ConstantEvaluator.h
+++ b/libsolidity/analysis/ConstantEvaluator.h
@@ -38,22 +38,32 @@ class TypeChecker;
class ConstantEvaluator: private ASTConstVisitor
{
public:
- ConstantEvaluator(Expression const& _expr, ErrorReporter& _errorReporter, size_t _newDepth = 0):
+ ConstantEvaluator(
+ ErrorReporter& _errorReporter,
+ size_t _newDepth = 0,
+ std::shared_ptr<std::map<ASTNode const*, TypePointer>> _types = std::make_shared<std::map<ASTNode const*, TypePointer>>()
+ ):
m_errorReporter(_errorReporter),
- m_depth(_newDepth)
+ m_depth(_newDepth),
+ m_types(_types)
{
- _expr.accept(*this);
}
+ TypePointer evaluate(Expression const& _expr);
+
private:
virtual void endVisit(BinaryOperation const& _operation);
virtual void endVisit(UnaryOperation const& _operation);
virtual void endVisit(Literal const& _literal);
virtual void endVisit(Identifier const& _identifier);
+ void setType(ASTNode const& _node, TypePointer const& _type);
+ TypePointer type(ASTNode const& _node);
+
ErrorReporter& m_errorReporter;
/// Current recursion depth.
- size_t m_depth;
+ size_t m_depth = 0;
+ std::shared_ptr<std::map<ASTNode const*, TypePointer>> m_types;
};
}