Add more tests and assertions

This commit is contained in:
Leonardo Alt
2018-07-10 18:39:38 +02:00
parent 9d895e002d
commit b750ca9741
4 changed files with 157 additions and 1 deletions
+2
View File
@@ -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);
}
+1
View File
@@ -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);
+1
View File
@@ -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);