diff options
author | Leonardo Alt <leo@ethereum.org> | 2018-10-17 17:32:01 +0800 |
---|---|---|
committer | Leonardo Alt <leo@ethereum.org> | 2018-10-17 21:58:13 +0800 |
commit | aa23326e06b00ecbaab032d333a15b28f5aa71d7 (patch) | |
tree | 96e3753d623689a5ca48afd83f2dc5a89467234f /libsolidity/formal/SMTChecker.cpp | |
parent | ec39fdcb3c6b3d5eb07ea6768fb3926fe54dc47e (diff) | |
download | dexon-solidity-aa23326e06b00ecbaab032d333a15b28f5aa71d7.tar dexon-solidity-aa23326e06b00ecbaab032d333a15b28f5aa71d7.tar.gz dexon-solidity-aa23326e06b00ecbaab032d333a15b28f5aa71d7.tar.bz2 dexon-solidity-aa23326e06b00ecbaab032d333a15b28f5aa71d7.tar.lz dexon-solidity-aa23326e06b00ecbaab032d333a15b28f5aa71d7.tar.xz dexon-solidity-aa23326e06b00ecbaab032d333a15b28f5aa71d7.tar.zst dexon-solidity-aa23326e06b00ecbaab032d333a15b28f5aa71d7.zip |
Consistent renaming of 'counters' and 'sequence' to 'index'
Diffstat (limited to 'libsolidity/formal/SMTChecker.cpp')
-rw-r--r-- | libsolidity/formal/SMTChecker.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index d84d6794..8787d25a 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -108,18 +108,18 @@ bool SMTChecker::visit(IfStatement const& _node) if (isRootFunction()) checkBooleanNotConstant(_node.condition(), "Condition is always $VALUE."); - auto countersEndTrue = visitBranch(_node.trueStatement(), expr(_node.condition())); + auto indicesEndTrue = visitBranch(_node.trueStatement(), expr(_node.condition())); vector<VariableDeclaration const*> touchedVariables = m_variableUsage->touchedVariables(_node.trueStatement()); - decltype(countersEndTrue) countersEndFalse; + decltype(indicesEndTrue) indicesEndFalse; if (_node.falseStatement()) { - countersEndFalse = visitBranch(*_node.falseStatement(), !expr(_node.condition())); + indicesEndFalse = visitBranch(*_node.falseStatement(), !expr(_node.condition())); touchedVariables += m_variableUsage->touchedVariables(*_node.falseStatement()); } else - countersEndFalse = copyVariableSequenceCounters(); + indicesEndFalse = copyVariableIndices(); - mergeVariables(touchedVariables, expr(_node.condition()), countersEndTrue, countersEndFalse); + mergeVariables(touchedVariables, expr(_node.condition()), indicesEndTrue, indicesEndFalse); return false; } @@ -646,22 +646,22 @@ void SMTChecker::assignment(VariableDeclaration const& _variable, smt::Expressio m_interface->addAssertion(newValue(_variable) == _value); } -SMTChecker::VariableSequenceCounters SMTChecker::visitBranch(Statement const& _statement, smt::Expression _condition) +SMTChecker::VariableIndices SMTChecker::visitBranch(Statement const& _statement, smt::Expression _condition) { return visitBranch(_statement, &_condition); } -SMTChecker::VariableSequenceCounters SMTChecker::visitBranch(Statement const& _statement, smt::Expression const* _condition) +SMTChecker::VariableIndices SMTChecker::visitBranch(Statement const& _statement, smt::Expression const* _condition) { - auto countersBeforeBranch = copyVariableSequenceCounters(); + auto indicesBeforeBranch = copyVariableIndices(); if (_condition) pushPathCondition(*_condition); _statement.accept(*this); if (_condition) popPathCondition(); - auto countersAfterBranch = copyVariableSequenceCounters(); - resetVariableCounters(countersBeforeBranch); - return countersAfterBranch; + auto indicesAfterBranch = copyVariableIndices(); + resetVariableIndices(indicesBeforeBranch); + return indicesAfterBranch; } void SMTChecker::checkCondition( @@ -894,19 +894,19 @@ void SMTChecker::resetVariables(vector<VariableDeclaration const*> _variables) } } -void SMTChecker::mergeVariables(vector<VariableDeclaration const*> const& _variables, smt::Expression const& _condition, VariableSequenceCounters const& _countersEndTrue, VariableSequenceCounters const& _countersEndFalse) +void SMTChecker::mergeVariables(vector<VariableDeclaration const*> const& _variables, smt::Expression const& _condition, VariableIndices const& _indicesEndTrue, VariableIndices const& _indicesEndFalse) { set<VariableDeclaration const*> uniqueVars(_variables.begin(), _variables.end()); for (auto const* decl: uniqueVars) { - solAssert(_countersEndTrue.count(decl) && _countersEndFalse.count(decl), ""); - int trueCounter = _countersEndTrue.at(decl); - int falseCounter = _countersEndFalse.at(decl); - solAssert(trueCounter != falseCounter, ""); + solAssert(_indicesEndTrue.count(decl) && _indicesEndFalse.count(decl), ""); + int trueIndex = _indicesEndTrue.at(decl); + int falseIndex = _indicesEndFalse.at(decl); + solAssert(trueIndex != falseIndex, ""); m_interface->addAssertion(newValue(*decl) == smt::Expression::ite( _condition, - valueAtSequence(*decl, trueCounter), - valueAtSequence(*decl, falseCounter)) + valueAtIndex(*decl, trueIndex), + valueAtIndex(*decl, falseIndex)) ); } } @@ -946,19 +946,19 @@ bool SMTChecker::knownVariable(VariableDeclaration const& _decl) smt::Expression SMTChecker::currentValue(VariableDeclaration const& _decl) { solAssert(knownVariable(_decl), ""); - return m_variables.at(&_decl)->current(); + return m_variables.at(&_decl)->currentValue(); } -smt::Expression SMTChecker::valueAtSequence(VariableDeclaration const& _decl, int _sequence) +smt::Expression SMTChecker::valueAtIndex(VariableDeclaration const& _decl, int _index) { solAssert(knownVariable(_decl), ""); - return m_variables.at(&_decl)->valueAtSequence(_sequence); + return m_variables.at(&_decl)->valueAtIndex(_index); } smt::Expression SMTChecker::newValue(VariableDeclaration const& _decl) { solAssert(knownVariable(_decl), ""); - return m_variables.at(&_decl)->increase(); + return m_variables.at(&_decl)->increaseIndex(); } void SMTChecker::setZeroValue(VariableDeclaration const& _decl) @@ -1070,16 +1070,16 @@ bool SMTChecker::visitedFunction(FunctionDefinition const* _funDef) return contains(m_functionPath, _funDef); } -SMTChecker::VariableSequenceCounters SMTChecker::copyVariableSequenceCounters() +SMTChecker::VariableIndices SMTChecker::copyVariableIndices() { - VariableSequenceCounters counters; - for (auto var: m_variables) - counters.emplace(var.first, var.second->index()); - return counters; + VariableIndices indices; + for (auto const& var: m_variables) + indices.emplace(var.first, var.second->index()); + return indices; } -void SMTChecker::resetVariableCounters(VariableSequenceCounters const& _counters) +void SMTChecker::resetVariableIndices(VariableIndices const& _indices) { - for (auto var: _counters) + for (auto const& var: _indices) m_variables.at(var.first)->index() = var.second; } |