mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fix multi assignmnets
This commit is contained in:
parent
9da8d7f28c
commit
ecb90b69bd
@ -158,6 +158,15 @@ void ReasoningBasedSimplifier::operator()(FunctionDefinition& _fun)
|
||||
{
|
||||
ScopedSaveAndRestore counters(m_variableSequenceCounter, {});
|
||||
ScopedSaveAndRestore pathCond(m_pathCondition, true);
|
||||
for (auto const& param: _fun.parameters)
|
||||
encodeVariableUpdateUnknown(param.name);
|
||||
for (auto const& retVar: _fun.returnVariables)
|
||||
{
|
||||
encodeVariableUpdateUnknown(retVar.name);
|
||||
// TODO remove the redundant encoding above
|
||||
m_solver->addAssertion(currentVariableExpression(retVar.name) == 0);
|
||||
}
|
||||
|
||||
ASTModifier::operator()(_fun);
|
||||
}
|
||||
|
||||
|
@ -160,12 +160,19 @@ void SMTSolver::encodeVariableDeclaration(VariableDeclaration const& _varDecl)
|
||||
_varDecl.value
|
||||
)
|
||||
encodeVariableUpdate(_varDecl.variables.front().name, *_varDecl.value);
|
||||
else
|
||||
for (auto const& var: _varDecl.variables)
|
||||
encodeVariableUpdateUnknown(var.name);
|
||||
|
||||
}
|
||||
|
||||
void SMTSolver::encodeVariableAssignment(Assignment const& _assignment)
|
||||
{
|
||||
if (_assignment.variableNames.size() == 1)
|
||||
encodeVariableUpdate(_assignment.variableNames.front().name, *_assignment.value);
|
||||
else
|
||||
for (auto const& var: _assignment.variableNames)
|
||||
encodeVariableUpdateUnknown(var.name);
|
||||
}
|
||||
|
||||
void SMTSolver::encodeVariableUpdate(YulString const& _name, Expression const& _value)
|
||||
@ -179,3 +186,14 @@ void SMTSolver::encodeVariableUpdate(YulString const& _name, Expression const& _
|
||||
m_solver->newVariable(variableNameAtIndex(_name, m_variableSequenceCounter[_name]), defaultSort());
|
||||
m_solver->addAssertion(currentVariableExpression(_name) == value);
|
||||
}
|
||||
|
||||
void SMTSolver::encodeVariableUpdateUnknown(const YulString& _name)
|
||||
{
|
||||
if (m_variableSequenceCounter.count(_name))
|
||||
++m_variableSequenceCounter[_name];
|
||||
else
|
||||
m_variableSequenceCounter[_name] = 1;
|
||||
|
||||
m_solver->newVariable(variableNameAtIndex(_name, m_variableSequenceCounter[_name]), defaultSort());
|
||||
m_solver->addAssertion(0 <= currentVariableExpression(_name) && currentVariableExpression(_name) <= (bigint(1) << 256) - 1);
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ protected:
|
||||
void encodeVariableDeclaration(VariableDeclaration const& _varDecl);
|
||||
void encodeVariableAssignment(Assignment const& _assignment);
|
||||
void encodeVariableUpdate(YulString const& _name, Expression const& _value);
|
||||
void encodeVariableUpdateUnknown(YulString const& _name);
|
||||
|
||||
/// The encoding for a builtin. The type of encoding determines what we are
|
||||
/// solving for.
|
||||
|
Loading…
Reference in New Issue
Block a user