mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove unintentional copy in assignment operation.
This commit is contained in:
parent
6948758156
commit
e14ab959f9
@ -65,14 +65,14 @@ void CodeTransform::operator()(Assignment const& _assignment)
|
|||||||
expectDeposit(_assignment.variableNames.size(), height);
|
expectDeposit(_assignment.variableNames.size(), height);
|
||||||
|
|
||||||
m_assembly.setSourceLocation(_assignment.location);
|
m_assembly.setSourceLocation(_assignment.location);
|
||||||
generateAssignment(_assignment.variableNames);
|
generateMultiAssignment(_assignment.variableNames);
|
||||||
checkStackHeight(&_assignment);
|
checkStackHeight(&_assignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeTransform::operator()(StackAssignment const& _assignment)
|
void CodeTransform::operator()(StackAssignment const& _assignment)
|
||||||
{
|
{
|
||||||
m_assembly.setSourceLocation(_assignment.location);
|
m_assembly.setSourceLocation(_assignment.location);
|
||||||
generateAssignment({_assignment.variableName});
|
generateAssignment(_assignment.variableName);
|
||||||
checkStackHeight(&_assignment);
|
checkStackHeight(&_assignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,27 +472,31 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight
|
|||||||
checkStackHeight(&_block);
|
checkStackHeight(&_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeTransform::generateAssignment(vector<Identifier> const& _variableNames)
|
void CodeTransform::generateMultiAssignment(vector<Identifier> const& _variableNames)
|
||||||
{
|
{
|
||||||
solAssert(m_scope, "");
|
solAssert(m_scope, "");
|
||||||
for (auto const& variableName: _variableNames | boost::adaptors::reversed)
|
for (auto const& variableName: _variableNames | boost::adaptors::reversed)
|
||||||
|
generateAssignment(variableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeTransform::generateAssignment(Identifier const& _variableName)
|
||||||
|
{
|
||||||
|
solAssert(m_scope, "");
|
||||||
|
auto var = m_scope->lookup(_variableName.name);
|
||||||
|
if (var)
|
||||||
{
|
{
|
||||||
auto var = m_scope->lookup(variableName.name);
|
Scope::Variable const& _var = boost::get<Scope::Variable>(*var);
|
||||||
if (var)
|
if (int heightDiff = variableHeightDiff(_var, true))
|
||||||
{
|
m_assembly.appendInstruction(solidity::swapInstruction(heightDiff - 1));
|
||||||
Scope::Variable const& _var = boost::get<Scope::Variable>(*var);
|
m_assembly.appendInstruction(solidity::Instruction::POP);
|
||||||
if (int heightDiff = variableHeightDiff(_var, true))
|
}
|
||||||
m_assembly.appendInstruction(solidity::swapInstruction(heightDiff - 1));
|
else
|
||||||
m_assembly.appendInstruction(solidity::Instruction::POP);
|
{
|
||||||
}
|
solAssert(
|
||||||
else
|
m_identifierAccess.generateCode,
|
||||||
{
|
"Identifier not found and no external access available."
|
||||||
solAssert(
|
);
|
||||||
m_identifierAccess.generateCode,
|
m_identifierAccess.generateCode(_variableName, IdentifierContext::LValue, m_assembly);
|
||||||
"Identifier not found and no external access available."
|
|
||||||
);
|
|
||||||
m_identifierAccess.generateCode(variableName, IdentifierContext::LValue, m_assembly);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,8 @@ private:
|
|||||||
/// to @a _blackStartStackHeight.
|
/// to @a _blackStartStackHeight.
|
||||||
void finalizeBlock(solidity::assembly::Block const& _block, int _blockStartStackHeight);
|
void finalizeBlock(solidity::assembly::Block const& _block, int _blockStartStackHeight);
|
||||||
|
|
||||||
void generateAssignment(std::vector<solidity::assembly::Identifier> const& _variableNames);
|
void generateMultiAssignment(std::vector<solidity::assembly::Identifier> const& _variableNames);
|
||||||
|
void generateAssignment(solidity::assembly::Identifier const& _variableName);
|
||||||
|
|
||||||
/// Determines the stack height difference to the given variables. Throws
|
/// Determines the stack height difference to the given variables. Throws
|
||||||
/// if it is not yet in scope or the height difference is too large. Returns
|
/// if it is not yet in scope or the height difference is too large. Returns
|
||||||
|
Loading…
Reference in New Issue
Block a user