From 0bcfad54f0464c157bbbadafb522a2d4863a0976 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 24 Jun 2015 20:15:29 +0200 Subject: [PATCH] Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop --- Compiler.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Compiler.cpp b/Compiler.cpp index 68052e279..f5570b98f 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -165,10 +165,26 @@ void Compiler::appendConstructor(FunctionDefinition const& _constructor) // copy constructor arguments from code to memory and then to stack, they are supplied after the actual program if (!_constructor.getParameters().empty()) { + unsigned argumentSize = 0; + for (ASTPointer const& var: _constructor.getParameters()) + if (var->getType()->isDynamicallySized()) + { + argumentSize = 0; + break; + } + else + argumentSize += var->getType()->getCalldataEncodedSize(); + CompilerUtils(m_context).fetchFreeMemoryPointer(); - m_context.appendProgramSize(); // program itself - // CODESIZE is program plus manually added arguments - m_context << eth::Instruction::CODESIZE << eth::Instruction::SUB; + if (argumentSize == 0) + { + // argument size is dynamic, use CODESIZE to determine it + m_context.appendProgramSize(); // program itself + // CODESIZE is program plus manually added arguments + m_context << eth::Instruction::CODESIZE << eth::Instruction::SUB; + } + else + m_context << u256(argumentSize); // stack: m_context << eth::Instruction::DUP1; m_context.appendProgramSize();