aboutsummaryrefslogtreecommitdiffstats
path: root/libjulia
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-09-20 17:16:07 +0800
committerchriseth <chris@ethereum.org>2017-09-20 17:16:26 +0800
commite14ab959f928c0a058b7b46d6ba4ee30e7ec08b7 (patch)
tree76cfdaa435756490590c15e4085e637ca4a24964 /libjulia
parent6948758156ba31b22fb74a3cd3e7cec0b925208b (diff)
downloaddexon-solidity-e14ab959f928c0a058b7b46d6ba4ee30e7ec08b7.tar
dexon-solidity-e14ab959f928c0a058b7b46d6ba4ee30e7ec08b7.tar.gz
dexon-solidity-e14ab959f928c0a058b7b46d6ba4ee30e7ec08b7.tar.bz2
dexon-solidity-e14ab959f928c0a058b7b46d6ba4ee30e7ec08b7.tar.lz
dexon-solidity-e14ab959f928c0a058b7b46d6ba4ee30e7ec08b7.tar.xz
dexon-solidity-e14ab959f928c0a058b7b46d6ba4ee30e7ec08b7.tar.zst
dexon-solidity-e14ab959f928c0a058b7b46d6ba4ee30e7ec08b7.zip
Remove unintentional copy in assignment operation.
Diffstat (limited to 'libjulia')
-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