aboutsummaryrefslogtreecommitdiffstats
path: root/Compiler.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-12-10 19:51:26 +0800
committerChristian <c@ethdev.com>2014-12-10 19:51:26 +0800
commit5edffeba19192c2fc8683e8e683cf5bbc261e28b (patch)
tree9b82cdb01fb38abf7a13fb7fe09b5af74b4b8012 /Compiler.cpp
parent35d5b28faeee5e19d0dbbeb3c75454249d636abd (diff)
downloaddexon-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.cpp4
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