aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libjulia/backends/evm/EVMCodeTransform.cpp42
-rw-r--r--libjulia/backends/evm/EVMCodeTransform.h3
2 files changed, 25 insertions, 20 deletions
diff --git a/libjulia/backends/evm/EVMCodeTransform.cpp b/libjulia/backends/evm/EVMCodeTransform.cpp
index e80903d5..66f593e8 100644
--- a/libjulia/backends/evm/EVMCodeTransform.cpp
+++ b/libjulia/backends/evm/EVMCodeTransform.cpp
@@ -65,14 +65,14 @@ void CodeTransform::operator()(Assignment const& _assignment)
expectDeposit(_assignment.variableNames.size(), height);
m_assembly.setSourceLocation(_assignment.location);
- generateAssignment(_assignment.variableNames);
+ generateMultiAssignment(_assignment.variableNames);
checkStackHeight(&_assignment);
}
void CodeTransform::operator()(StackAssignment const& _assignment)
{
m_assembly.setSourceLocation(_assignment.location);
- generateAssignment({_assignment.variableName});
+ generateAssignment(_assignment.variableName);
checkStackHeight(&_assignment);
}
@@ -472,27 +472,31 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight
checkStackHeight(&_block);
}
-void CodeTransform::generateAssignment(vector<Identifier> const& _variableNames)
+void CodeTransform::generateMultiAssignment(vector<Identifier> const& _variableNames)
{
solAssert(m_scope, "");
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);
- if (var)
- {
- Scope::Variable const& _var = boost::get<Scope::Variable>(*var);
- if (int heightDiff = variableHeightDiff(_var, true))
- m_assembly.appendInstruction(solidity::swapInstruction(heightDiff - 1));
- m_assembly.appendInstruction(solidity::Instruction::POP);
- }
- else
- {
- solAssert(
- m_identifierAccess.generateCode,
- "Identifier not found and no external access available."
- );
- m_identifierAccess.generateCode(variableName, IdentifierContext::LValue, m_assembly);
- }
+ Scope::Variable const& _var = boost::get<Scope::Variable>(*var);
+ if (int heightDiff = variableHeightDiff(_var, true))
+ m_assembly.appendInstruction(solidity::swapInstruction(heightDiff - 1));
+ m_assembly.appendInstruction(solidity::Instruction::POP);
+ }
+ else
+ {
+ solAssert(
+ m_identifierAccess.generateCode,
+ "Identifier not found and no external access available."
+ );
+ m_identifierAccess.generateCode(_variableName, IdentifierContext::LValue, m_assembly);
}
}
diff --git a/libjulia/backends/evm/EVMCodeTransform.h b/libjulia/backends/evm/EVMCodeTransform.h
index bb2be786..951c8a50 100644
--- a/libjulia/backends/evm/EVMCodeTransform.h
+++ b/libjulia/backends/evm/EVMCodeTransform.h
@@ -124,7 +124,8 @@ private:
/// to @a _blackStartStackHeight.
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
/// if it is not yet in scope or the height difference is too large. Returns