aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ContractCompiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/codegen/ContractCompiler.cpp')
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 74b07d4d..fd0998d4 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -267,18 +267,13 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
m_context << notFound;
if (fallback)
{
- m_context.setStackOffset(0);
if (!fallback->isPayable())
appendCallValueCheck();
- // Return tag is used to jump out of the function.
- eth::AssemblyItem returnTag = m_context.pushNewTag();
- fallback->accept(*this);
- m_context << returnTag;
+ solAssert(fallback->isFallback(), "");
solAssert(FunctionType(*fallback).parameterTypes().empty(), "");
solAssert(FunctionType(*fallback).returnParameterTypes().empty(), "");
- // Return tag gets consumed.
- m_context.adjustStackOffset(-1);
+ fallback->accept(*this);
m_context << Instruction::STOP;
}
else
@@ -299,9 +294,12 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
// Return tag is used to jump out of the function.
eth::AssemblyItem returnTag = m_context.pushNewTag();
- // Parameter for calldataUnpacker
- m_context << CompilerUtils::dataStartOffset;
- appendCalldataUnpacker(functionType->parameterTypes());
+ if (!functionType->parameterTypes().empty())
+ {
+ // Parameter for calldataUnpacker
+ m_context << CompilerUtils::dataStartOffset;
+ appendCalldataUnpacker(functionType->parameterTypes());
+ }
m_context.appendJumpTo(m_context.functionEntryLabel(functionType->declaration()));
m_context << returnTag;
// Return tag and input parameters get consumed.
@@ -533,7 +531,8 @@ bool ContractCompiler::visit(FunctionDefinition const& _function)
m_context.adjustStackOffset(-(int)c_returnValuesSize);
- if (!_function.isConstructor())
+ /// The constructor and the fallback function doesn't to jump out.
+ if (!_function.isConstructor() && !_function.isFallback())
m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction);
return false;
}
@@ -925,7 +924,10 @@ void ContractCompiler::appendModifierOrFunctionCode()
);
}
for (VariableDeclaration const* localVariable: modifier.localVariables())
+ {
+ addedVariables.push_back(localVariable);
appendStackVariableInitialisation(*localVariable);
+ }
stackSurplus =
CompilerUtils::sizeOnStack(modifier.parameters()) +