mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Include creation code only once.
This commit is contained in:
parent
8e5f1c0d50
commit
ead1a3b33f
@ -556,20 +556,24 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
arg->accept(*this);
|
arg->accept(*this);
|
||||||
argumentTypes.push_back(arg->annotation().type);
|
argumentTypes.push_back(arg->annotation().type);
|
||||||
}
|
}
|
||||||
ContractDefinition const& contract =
|
ContractDefinition const* contract =
|
||||||
dynamic_cast<ContractType const&>(*function.returnParameterTypes().front()).contractDefinition();
|
&dynamic_cast<ContractType const&>(*function.returnParameterTypes().front()).contractDefinition();
|
||||||
|
m_context.callLowLevelFunction(
|
||||||
|
"$copyContractCreationCodeToMemory_" + contract->type()->identifier(),
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
[contract](CompilerContext& _context)
|
||||||
|
{
|
||||||
// copy the contract's code into memory
|
// copy the contract's code into memory
|
||||||
eth::Assembly const& assembly = m_context.compiledContract(contract);
|
eth::Assembly const& assembly = _context.compiledContract(*contract);
|
||||||
utils().fetchFreeMemoryPointer();
|
CompilerUtils(_context).fetchFreeMemoryPointer();
|
||||||
// TODO we create a copy here, which is actually what we want.
|
|
||||||
// This should be revisited at the point where we fix
|
|
||||||
// https://github.com/ethereum/solidity/issues/1092
|
|
||||||
// pushes size
|
// pushes size
|
||||||
auto subroutine = m_context.addSubroutine(make_shared<eth::Assembly>(assembly));
|
auto subroutine = _context.addSubroutine(make_shared<eth::Assembly>(assembly));
|
||||||
m_context << Instruction::DUP1 << subroutine;
|
_context << Instruction::DUP1 << subroutine;
|
||||||
m_context << Instruction::DUP4 << Instruction::CODECOPY;
|
_context << Instruction::DUP4 << Instruction::CODECOPY;
|
||||||
|
_context << Instruction::ADD;
|
||||||
m_context << Instruction::ADD;
|
}
|
||||||
|
);
|
||||||
utils().encodeToMemory(argumentTypes, function.parameterTypes());
|
utils().encodeToMemory(argumentTypes, function.parameterTypes());
|
||||||
// now on stack: memory_end_ptr
|
// now on stack: memory_end_ptr
|
||||||
// need: size, offset, endowment
|
// need: size, offset, endowment
|
||||||
|
Loading…
Reference in New Issue
Block a user