aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm/AsmCodeGen.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-03-22 20:21:58 +0800
committerchriseth <chris@ethereum.org>2017-04-25 22:49:03 +0800
commit580921b3294bc582c68db04f1ebf83b9bec206f5 (patch)
tree2ca11e27a3ce567377eea1d265628c2bdd31dc4a /libsolidity/inlineasm/AsmCodeGen.cpp
parentf13c8af3f9f3b0aec88809fbb609e183c9bba4be (diff)
downloaddexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.tar
dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.tar.gz
dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.tar.bz2
dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.tar.lz
dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.tar.xz
dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.tar.zst
dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.zip
Perform stack height checks in assembly analysis phase.
Diffstat (limited to 'libsolidity/inlineasm/AsmCodeGen.cpp')
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp
index c1efa292..a79c5a37 100644
--- a/libsolidity/inlineasm/AsmCodeGen.cpp
+++ b/libsolidity/inlineasm/AsmCodeGen.cpp
@@ -185,7 +185,7 @@ public:
{
int height = m_state.assembly.deposit();
boost::apply_visitor(*this, *it);
- expectDeposit(1, height, locationOf(*it));
+ expectDeposit(1, height);
}
(*this)(_instr.instruction);
}
@@ -210,7 +210,7 @@ public:
{
int height = m_state.assembly.deposit();
boost::apply_visitor(*this, *_assignment.value);
- expectDeposit(1, height, locationOf(*_assignment.value));
+ expectDeposit(1, height);
m_state.assembly.setSourceLocation(_assignment.location);
generateAssignment(_assignment.variableName, _assignment.location);
}
@@ -218,7 +218,7 @@ public:
{
int height = m_state.assembly.deposit();
boost::apply_visitor(*this, *_varDecl.value);
- expectDeposit(1, height, locationOf(*_varDecl.value));
+ expectDeposit(1, height);
auto& var = boost::get<Scope::Variable>(m_scope.identifiers.at(_varDecl.name));
var.stackHeight = height;
var.active = true;
@@ -279,17 +279,9 @@ private:
return heightDiff;
}
- void expectDeposit(int _deposit, int _oldHeight, SourceLocation const& _location)
+ void expectDeposit(int _deposit, int _oldHeight)
{
- if (m_state.assembly.deposit() != _oldHeight + 1)
- m_state.addError(Error::Type::TypeError,
- "Expected instruction(s) to deposit " +
- boost::lexical_cast<string>(_deposit) +
- " item(s) to the stack, but did deposit " +
- boost::lexical_cast<string>(m_state.assembly.deposit() - _oldHeight) +
- " item(s).",
- _location
- );
+ solAssert(m_state.assembly.deposit() == _oldHeight + _deposit, "Invalid stack deposit.");
}
/// Assigns the label's id to a value taken from eth::Assembly if it has not yet been set.