Stack adjustment and code generation for fallback function.

This assumes that the fallback function does not have return parameters.
This commit is contained in:
chriseth 2017-06-27 14:29:04 +02:00
parent 168f64f4cb
commit ef9a7b2144

View File

@ -271,13 +271,15 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
if (!fallback->isPayable()) if (!fallback->isPayable())
appendCallValueCheck(); appendCallValueCheck();
// Return tag is used to jump out of the function.
eth::AssemblyItem returnTag = m_context.pushNewTag(); eth::AssemblyItem returnTag = m_context.pushNewTag();
fallback->accept(*this); fallback->accept(*this);
m_context << returnTag; m_context << returnTag;
m_context.adjustStackOffset( solAssert(FunctionType(*fallback).parameterTypes().empty(), "");
CompilerUtils(m_context).sizeOnStack(FunctionType(*fallback).returnParameterTypes()) - 1 solAssert(FunctionType(*fallback).returnParameterTypes().empty(), "");
); // Return tag gets consumed.
appendReturnValuePacker(FunctionType(*fallback).returnParameterTypes(), _contract.isLibrary()); m_context.adjustStackOffset(-1);
m_context << Instruction::STOP;
} }
else else
m_context.appendRevert(); m_context.appendRevert();