From a36db1f2412d700cc8b32f8331be103c73ea90cb Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 30 Oct 2014 22:52:15 +0100 Subject: Actual contract creator and add solidity to AlethZero interface. --- Compiler.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Compiler.cpp') diff --git a/Compiler.cpp b/Compiler.cpp index 7e40db15..b1e3c3da 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -46,9 +46,22 @@ void Compiler::compileContract(ContractDefinition& _contract) for (ASTPointer const& function: _contract.getDefinedFunctions()) m_context.addFunction(*function); + appendFunctionSelector(_contract.getDefinedFunctions()); for (ASTPointer const& function: _contract.getDefinedFunctions()) function->accept(*this); + + packIntoContractCreator(); +} + +void Compiler::packIntoContractCreator() +{ + CompilerContext creatorContext; + eth::AssemblyItem sub = creatorContext.addSubroutine(m_context.getAssembly()); + // stack contains sub size + creatorContext << eth::Instruction::DUP1 << sub << u256(0) << eth::Instruction::CODECOPY; + creatorContext << u256(0) << eth::Instruction::RETURN; + swap(m_context, creatorContext); } void Compiler::appendFunctionSelector(vector> const& _functions) -- cgit