aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/formal/SymbolicIntVariable.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-10-15 22:49:47 +0800
committerGitHub <noreply@github.com>2018-10-15 22:49:47 +0800
commit238494752192a2c834eb8913b244671afb48d693 (patch)
treed3e60cd464a03b98df9141386df9877bf418d577 /libsolidity/formal/SymbolicIntVariable.cpp
parent771de0c5adfe284c3824265999c1b9c07d66d0a1 (diff)
parent4a4620ac955d3c61b4778dfab3a9e05a91e4fc33 (diff)
downloaddexon-solidity-238494752192a2c834eb8913b244671afb48d693.tar
dexon-solidity-238494752192a2c834eb8913b244671afb48d693.tar.gz
dexon-solidity-238494752192a2c834eb8913b244671afb48d693.tar.bz2
dexon-solidity-238494752192a2c834eb8913b244671afb48d693.tar.lz
dexon-solidity-238494752192a2c834eb8913b244671afb48d693.tar.xz
dexon-solidity-238494752192a2c834eb8913b244671afb48d693.tar.zst
dexon-solidity-238494752192a2c834eb8913b244671afb48d693.zip
Merge pull request #5209 from ethereum/smt_ssa_refactor
[SMTChecker] 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)