Skip to content

Commit

Permalink
[SMTChecker_Bool] Fix PR review comments: method renaming and solAssert
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Alt committed Mar 12, 2018
1 parent c2d26eb commit 9b64dc5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
15 changes: 8 additions & 7 deletions libsolidity/formal/SMTChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void SMTChecker::endVisit(Assignment const& _assignment)
_assignment.location(),
"Assertion checker does not yet implement compound assignment."
);
else if (!SSAVariable::supportedType(_assignment.annotation().type->category()))
else if (!SSAVariable::isSupportedType(_assignment.annotation().type->category()))
m_errorReporter.warning(
_assignment.location(),
"Assertion checker does not yet implement type " + _assignment.annotation().type->toString()
Expand Down Expand Up @@ -266,15 +266,15 @@ void SMTChecker::endVisit(UnaryOperation const& _op)
{
case Token::Not: // !
{
solAssert(SSAVariable::typeBool(_op.annotation().type->category()), "");
solAssert(SSAVariable::isBool(_op.annotation().type->category()), "");
defineExpr(_op, !expr(_op.subExpression()));
break;
}
case Token::Inc: // ++ (pre- or postfix)
case Token::Dec: // -- (pre- or postfix)
{

solAssert(SSAVariable::typeInteger(_op.annotation().type->category()), "");
solAssert(SSAVariable::isInteger(_op.annotation().type->category()), "");
solAssert(_op.subExpression().annotation().lValueRequested, "");
if (Identifier const* identifier = dynamic_cast<Identifier const*>(&_op.subExpression()))
{
Expand Down Expand Up @@ -371,7 +371,7 @@ void SMTChecker::endVisit(Identifier const& _identifier)
{
// Will be translated as part of the node that requested the lvalue.
}
else if (SSAVariable::supportedType(_identifier.annotation().type->category()))
else if (SSAVariable::isSupportedType(_identifier.annotation().type->category()))
defineExpr(_identifier, currentValue(*decl));
else if (FunctionType const* fun = dynamic_cast<FunctionType const*>(_identifier.annotation().type.get()))
{
Expand Down Expand Up @@ -445,13 +445,13 @@ void SMTChecker::arithmeticOperation(BinaryOperation const& _op)
void SMTChecker::compareOperation(BinaryOperation const& _op)
{
solAssert(_op.annotation().commonType, "");
if (SSAVariable::supportedType(_op.annotation().commonType->category()))
if (SSAVariable::isSupportedType(_op.annotation().commonType->category()))
{
smt::Expression left(expr(_op.leftExpression()));
smt::Expression right(expr(_op.rightExpression()));
Token::Value op = _op.getOperator();
shared_ptr<smt::Expression> value;
if (SSAVariable::typeInteger(_op.annotation().commonType->category()))
if (SSAVariable::isInteger(_op.annotation().commonType->category()))
{
value = make_shared<smt::Expression>(
op == Token::Equal ? (left == right) :
Expand All @@ -464,6 +464,7 @@ void SMTChecker::compareOperation(BinaryOperation const& _op)
}
else // Bool
{
solAssert(SSAVariable::isBool(_op.annotation().commonType->category()), "");
value = make_shared<smt::Expression>(
op == Token::Equal ? (left == right) :
op == Token::NotEqual ? (left != right) :
Expand Down Expand Up @@ -744,7 +745,7 @@ void SMTChecker::mergeVariables(vector<Declaration const*> const& _variables, sm

bool SMTChecker::createVariable(VariableDeclaration const& _varDecl)
{
if (SSAVariable::supportedType(_varDecl.type()->category()))
if (SSAVariable::isSupportedType(_varDecl.type()->category()))
{
solAssert(m_variables.count(&_varDecl) == 0, "");
m_variables.emplace(&_varDecl, SSAVariable(_varDecl, *m_interface));
Expand Down
12 changes: 6 additions & 6 deletions libsolidity/formal/SSAVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ SSAVariable::SSAVariable(
{
resetIndex();

if (typeInteger(_decl.type()->category()))
if (isInteger(_decl.type()->category()))
m_symbolicVar = make_shared<SymbolicIntVariable>(_decl, _interface);
else if (typeBool(_decl.type()->category()))
else if (isBool(_decl.type()->category()))
m_symbolicVar = make_shared<SymbolicBoolVariable>(_decl, _interface);
else
{
solAssert(false, "");
}
}

bool SSAVariable::supportedType(Type::Category _category)
bool SSAVariable::isSupportedType(Type::Category _category)
{
return typeInteger(_category) || typeBool(_category);
return isInteger(_category) || isBool(_category);
}

bool SSAVariable::typeInteger(Type::Category _category)
bool SSAVariable::isInteger(Type::Category _category)
{
return _category == Type::Category::Integer;
}

bool SSAVariable::typeBool(Type::Category _category)
bool SSAVariable::isBool(Type::Category _category)
{
return _category == Type::Category::Bool;
}
Expand Down
6 changes: 3 additions & 3 deletions libsolidity/formal/SSAVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class SSAVariable
void setUnknownValue();

/// So far Int and Bool are supported.
static bool supportedType(Type::Category _category);
static bool typeInteger(Type::Category _category);
static bool typeBool(Type::Category _category);
static bool isSupportedType(Type::Category _category);
static bool isInteger(Type::Category _category);
static bool isBool(Type::Category _category);

private:
smt::Expression valueAtSequence(int _seq) const
Expand Down

0 comments on commit 9b64dc5

Please sign in to comment.