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-28 18:00:31 +02:00
parent 168f64f4cb
commit ef9a7b2144
+6 -4
View File
@@ -271,13 +271,15 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
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;
m_context.adjustStackOffset(
CompilerUtils(m_context).sizeOnStack(FunctionType(*fallback).returnParameterTypes()) - 1
);
appendReturnValuePacker(FunctionType(*fallback).returnParameterTypes(), _contract.isLibrary());
solAssert(FunctionType(*fallback).parameterTypes().empty(), "");
solAssert(FunctionType(*fallback).returnParameterTypes().empty(), "");
// Return tag gets consumed.
m_context.adjustStackOffset(-1);
m_context << Instruction::STOP;
}
else
m_context.appendRevert();