diff options
author | Christian <c@ethdev.com> | 2014-12-10 19:51:26 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-10 19:51:26 +0800 |
commit | 5edffeba19192c2fc8683e8e683cf5bbc261e28b (patch) | |
tree | 9b82cdb01fb38abf7a13fb7fe09b5af74b4b8012 /Compiler.cpp | |
parent | 35d5b28faeee5e19d0dbbeb3c75454249d636abd (diff) | |
download | dexon-solidity-5edffeba19192c2fc8683e8e683cf5bbc261e28b.tar.gz dexon-solidity-5edffeba19192c2fc8683e8e683cf5bbc261e28b.tar.zst dexon-solidity-5edffeba19192c2fc8683e8e683cf5bbc261e28b.zip |
Take variable stack size correctly into account for return value packer.
Diffstat (limited to 'Compiler.cpp')
-rw-r--r-- | Compiler.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Compiler.cpp b/Compiler.cpp index 73b3e324..a8a07403 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -155,6 +155,7 @@ void Compiler::appendReturnValuePacker(FunctionDefinition const& _function) //@todo this can be also done more efficiently unsigned dataOffset = 0; vector<ASTPointer<VariableDeclaration>> const& parameters = _function.getReturnParameters(); + unsigned stackDepth = CompilerUtils(m_context).getSizeOnStack(parameters); for (unsigned i = 0; i < parameters.size(); ++i) { Type const& paramType = *parameters[i]->getType(); @@ -163,10 +164,11 @@ void Compiler::appendReturnValuePacker(FunctionDefinition const& _function) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_sourceLocation(parameters[i]->getLocation()) << errinfo_comment("Type " + paramType.toString() + " not yet supported.")); - m_context << eth::dupInstruction(parameters.size() - i); + CompilerUtils(m_context).copyToStackTop(stackDepth, paramType); if (numBytes != 32) m_context << (u256(1) << ((32 - numBytes) * 8)) << eth::Instruction::MUL; m_context << u256(dataOffset) << eth::Instruction::MSTORE; + stackDepth -= paramType.getSizeOnStack(); dataOffset += numBytes; } // note that the stack is not cleaned up here |