Fix PR comments

This commit is contained in:
Leonardo Alt 2018-02-28 18:00:13 +01:00
parent 21c6b80fc9
commit cff0836c03
6 changed files with 37 additions and 23 deletions

View File

@ -25,13 +25,15 @@ using namespace std;
using namespace dev; using namespace dev;
using namespace dev::solidity; using namespace dev::solidity;
SSAVariable::SSAVariable(Declaration const* _decl, SSAVariable::SSAVariable(
smt::SolverInterface& _interface) Declaration const* _decl,
smt::SolverInterface& _interface
)
{ {
resetIndex(); resetIndex();
if (dynamic_cast<IntegerType const*>(_decl->type().get())) if (dynamic_cast<IntegerType const*>(_decl->type().get()))
m_symbVar = make_shared<SymbolicIntVariable>(_decl, _interface); m_symbolicVar = make_shared<SymbolicIntVariable>(_decl, _interface);
else else
{ {
solAssert(false, ""); solAssert(false, "");
@ -62,10 +64,10 @@ int SSAVariable::next() const
void SSAVariable::setZeroValue() void SSAVariable::setZeroValue()
{ {
m_symbVar->setZeroValue(index()); m_symbolicVar->setZeroValue(index());
} }
void SSAVariable::setUnknownValue() void SSAVariable::setUnknownValue()
{ {
m_symbVar->setUnknownValue(index()); m_symbolicVar->setUnknownValue(index());
} }

View File

@ -36,8 +36,10 @@ class SSAVariable
public: public:
/// @param _decl Used to determine the type and forwarded to the symbolic var. /// @param _decl Used to determine the type and forwarded to the symbolic var.
/// @param _interface Forwarded to the symbolic var such that it can give constraints to the solver. /// @param _interface Forwarded to the symbolic var such that it can give constraints to the solver.
explicit SSAVariable(Declaration const* _decl, SSAVariable(
smt::SolverInterface& _interface); Declaration const* _decl,
smt::SolverInterface& _interface
);
SSAVariable(SSAVariable const&) = default; SSAVariable(SSAVariable const&) = default;
SSAVariable(SSAVariable&&) = default; SSAVariable(SSAVariable&&) = default;
SSAVariable& operator=(SSAVariable const&) = default; SSAVariable& operator=(SSAVariable const&) = default;
@ -45,7 +47,9 @@ public:
void resetIndex(); void resetIndex();
/// This function returns the current index of this SSA variable.
int index() const; int index() const;
/// This function returns the next free index of this SSA variable.
int next() const; int next() const;
int operator++() int operator++()
@ -74,10 +78,10 @@ public:
private: private:
smt::Expression valueAtSequence(int _seq) const smt::Expression valueAtSequence(int _seq) const
{ {
return (*m_symbVar)(_seq); return (*m_symbolicVar)(_seq);
} }
std::shared_ptr<SymbolicVariable> m_symbVar = nullptr; std::shared_ptr<SymbolicVariable> m_symbolicVar = nullptr;
int m_currentSequenceCounter; int m_currentSequenceCounter;
/// The next free sequence counter is a shared pointer because we want /// The next free sequence counter is a shared pointer because we want
/// the copy and the copied to share it. /// the copy and the copied to share it.

View File

@ -23,9 +23,11 @@ using namespace std;
using namespace dev; using namespace dev;
using namespace dev::solidity; using namespace dev::solidity;
SymbolicIntVariable::SymbolicIntVariable(Declaration const* _decl, SymbolicIntVariable::SymbolicIntVariable(
smt::SolverInterface&_interface) Declaration const* _decl,
: SymbolicVariable(_decl, _interface) smt::SolverInterface& _interface
):
SymbolicVariable(_decl, _interface)
{ {
solAssert(m_declaration->type()->category() == Type::Category::Integer, ""); solAssert(m_declaration->type()->category() == Type::Category::Integer, "");
m_expression = make_shared<smt::Expression>(m_interface.newFunction(uniqueSymbol(), smt::Sort::Int, smt::Sort::Int)); m_expression = make_shared<smt::Expression>(m_interface.newFunction(uniqueSymbol(), smt::Sort::Int, smt::Sort::Int));

View File

@ -29,11 +29,13 @@ namespace solidity
/** /**
* Specialization of SymbolicVariable for Integers * Specialization of SymbolicVariable for Integers
*/ */
class SymbolicIntVariable : public SymbolicVariable class SymbolicIntVariable: public SymbolicVariable
{ {
public: public:
explicit SymbolicIntVariable(Declaration const* _decl, SymbolicIntVariable(
smt::SolverInterface& _interface); Declaration const* _decl,
smt::SolverInterface& _interface
);
SymbolicIntVariable(SymbolicIntVariable const&) = default; SymbolicIntVariable(SymbolicIntVariable const&) = default;
SymbolicIntVariable(SymbolicIntVariable&&) = default; SymbolicIntVariable(SymbolicIntVariable&&) = default;
SymbolicIntVariable& operator=(SymbolicIntVariable const&) = default; SymbolicIntVariable& operator=(SymbolicIntVariable const&) = default;
@ -41,7 +43,7 @@ public:
/// Sets the var to 0. /// Sets the var to 0.
void setZeroValue(int _seq); void setZeroValue(int _seq);
/// Sets the valid interval for the var. /// Sets the variable to the full valid value range.
void setUnknownValue(int _seq); void setUnknownValue(int _seq);
static smt::Expression minValue(IntegerType const& _t); static smt::Expression minValue(IntegerType const& _t);

View File

@ -23,9 +23,11 @@ using namespace std;
using namespace dev; using namespace dev;
using namespace dev::solidity; using namespace dev::solidity;
SymbolicVariable::SymbolicVariable(Declaration const* _decl, SymbolicVariable::SymbolicVariable(
smt::SolverInterface& _interface) Declaration const* _decl,
: m_declaration(_decl), smt::SolverInterface& _interface
):
m_declaration(_decl),
m_interface(_interface) m_interface(_interface)
{ {
} }

View File

@ -36,8 +36,10 @@ class Declaration;
class SymbolicVariable class SymbolicVariable
{ {
public: public:
explicit SymbolicVariable(Declaration const* _decl, SymbolicVariable(
smt::SolverInterface& _interface); Declaration const* _decl,
smt::SolverInterface& _interface
);
SymbolicVariable(SymbolicVariable const&) = default; SymbolicVariable(SymbolicVariable const&) = default;
SymbolicVariable(SymbolicVariable&&) = default; SymbolicVariable(SymbolicVariable&&) = default;
SymbolicVariable& operator=(SymbolicVariable const&) = default; SymbolicVariable& operator=(SymbolicVariable const&) = default;
@ -52,8 +54,8 @@ public:
/// Sets the var to the default value of its type. /// Sets the var to the default value of its type.
virtual void setZeroValue(int _seq) = 0; virtual void setZeroValue(int _seq) = 0;
/// The unknown value depends on the type. For example, an interval is set for Integers. /// The unknown value is the full range of valid values,
/// This is decided by the subclasses. /// and that's sub-type dependent.
virtual void setUnknownValue(int _seq) = 0; virtual void setUnknownValue(int _seq) = 0;
protected: protected: