aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/formal/SymbolicIntVariable.cpp
diff options
context:
space:
mode:
authorLeonardo Alt <leo@ethereum.org>2018-10-12 21:44:46 +0800
committerLeonardo Alt <leo@ethereum.org>2018-10-15 20:20:54 +0800
commit4a4620ac955d3c61b4778dfab3a9e05a91e4fc33 (patch)
tree32ee6fc579e12562cca7fa66558514f42d4ceccd /libsolidity/formal/SymbolicIntVariable.cpp
parent0778fb2dfca49bd84d202f78e31730c4e930749f (diff)
downloaddexon-solidity-4a4620ac955d3c61b4778dfab3a9e05a91e4fc33.tar.gz
dexon-solidity-4a4620ac955d3c61b4778dfab3a9e05a91e4fc33.tar.zst
dexon-solidity-4a4620ac955d3c61b4778dfab3a9e05a91e4fc33.zip
Refactor SSAVariable such that it only uses Type and not Declaration
Diffstat (limited to 'libsolidity/formal/SymbolicIntVariable.cpp')
-rw-r--r--libsolidity/formal/SymbolicIntVariable.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/libsolidity/formal/SymbolicIntVariable.cpp b/libsolidity/formal/SymbolicIntVariable.cpp
index 4f65b1fd..0adb9d09 100644
--- a/libsolidity/formal/SymbolicIntVariable.cpp
+++ b/libsolidity/formal/SymbolicIntVariable.cpp
@@ -17,21 +17,20 @@
#include <libsolidity/formal/SymbolicIntVariable.h>
-#include <libsolidity/ast/AST.h>
-
using namespace std;
using namespace dev;
using namespace dev::solidity;
SymbolicIntVariable::SymbolicIntVariable(
- Declaration const& _decl,
+ Type const& _type,
+ string const& _uniqueName,
smt::SolverInterface& _interface
):
- SymbolicVariable(_decl, _interface)
+ SymbolicVariable(_type, _uniqueName, _interface)
{
solAssert(
- m_declaration.type()->category() == Type::Category::Integer ||
- m_declaration.type()->category() == Type::Category::Address,
+ _type.category() == Type::Category::Integer ||
+ _type.category() == Type::Category::Address,
""
);
}
@@ -48,11 +47,20 @@ void SymbolicIntVariable::setZeroValue(int _seq)
void SymbolicIntVariable::setUnknownValue(int _seq)
{
- auto intType = dynamic_pointer_cast<IntegerType const>(m_declaration.type());
- if (!intType)
- intType = make_shared<IntegerType>(160);
- m_interface.addAssertion(valueAtSequence(_seq) >= minValue(*intType));
- m_interface.addAssertion(valueAtSequence(_seq) <= maxValue(*intType));
+ if (m_type.category() == Type::Category::Integer)
+ {
+ auto intType = dynamic_cast<IntegerType const*>(&m_type);
+ solAssert(intType, "");
+ m_interface.addAssertion(valueAtSequence(_seq) >= minValue(*intType));
+ m_interface.addAssertion(valueAtSequence(_seq) <= maxValue(*intType));
+ }
+ else
+ {
+ solAssert(m_type.category() == Type::Category::Address, "");
+ IntegerType addrType{160};
+ m_interface.addAssertion(valueAtSequence(_seq) >= minValue(addrType));
+ m_interface.addAssertion(valueAtSequence(_seq) <= maxValue(addrType));
+ }
}
smt::Expression SymbolicIntVariable::minValue(IntegerType const& _t)