aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorLeonardo Alt <leo@ethereum.org>2018-07-06 15:56:27 +0800
committerLeonardo Alt <leo@ethereum.org>2018-07-11 00:39:38 +0800
commitb750ca9741aba47cc8ba650a04dd620725ed4610 (patch)
tree177c1c511009e86169d67554ab5c252f8e61de2a /libsolidity
parent9d895e002d0e5e1e3435d03ac82277caa397bbec (diff)
downloaddexon-solidity-b750ca9741aba47cc8ba650a04dd620725ed4610.tar
dexon-solidity-b750ca9741aba47cc8ba650a04dd620725ed4610.tar.gz
dexon-solidity-b750ca9741aba47cc8ba650a04dd620725ed4610.tar.bz2
dexon-solidity-b750ca9741aba47cc8ba650a04dd620725ed4610.tar.lz
dexon-solidity-b750ca9741aba47cc8ba650a04dd620725ed4610.tar.xz
dexon-solidity-b750ca9741aba47cc8ba650a04dd620725ed4610.tar.zst
dexon-solidity-b750ca9741aba47cc8ba650a04dd620725ed4610.zip
Add more tests and assertions
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/codegen/CompilerContext.cpp2
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp1
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp1
3 files changed, 4 insertions, 0 deletions
diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp
index 9c5dc89c..51f76399 100644
--- a/libsolidity/codegen/CompilerContext.cpp
+++ b/libsolidity/codegen/CompilerContext.cpp
@@ -127,6 +127,8 @@ void CompilerContext::addVariable(VariableDeclaration const& _declaration,
unsigned _offsetToCurrent)
{
solAssert(m_asm->deposit() >= 0 && unsigned(m_asm->deposit()) >= _offsetToCurrent, "");
+ unsigned sizeOnStack = _declaration.annotation().type->sizeOnStack();
+ solAssert(sizeOnStack == 1 || sizeOnStack == 2, "");
m_localVariables[&_declaration].push_back(unsigned(m_asm->deposit()) - _offsetToCurrent);
}
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 92c45227..5adce4a0 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -1172,6 +1172,7 @@ void CompilerUtils::popStackSlots(size_t _amount)
void CompilerUtils::popAndJump(unsigned _toHeight, eth::AssemblyItem const& _jumpTo)
{
+ solAssert(m_context.stackHeight() >= _toHeight, "");
unsigned amount = m_context.stackHeight() - _toHeight;
popStackSlots(amount);
m_context.appendJumpTo(_jumpTo);
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 474d2b68..207e0af7 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -999,6 +999,7 @@ eth::AssemblyPointer ContractCompiler::cloneRuntime() const
void ContractCompiler::popScopedVariables(ASTNode const* _node)
{
unsigned blockHeight = m_scopeStackHeight.at(m_modifierDepth).at(_node);
+ solAssert(m_context.stackHeight() >= blockHeight, "");
unsigned stackDiff = m_context.stackHeight() - blockHeight;
CompilerUtils(m_context).popStackSlots(stackDiff);
m_context.removeVariablesAboveStackHeight(blockHeight);