From e6fee257e68e7b145a47eee8c5937db7a7a99849 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 10 Jan 2019 16:44:31 +0100 Subject: Code generation for access to contract code. --- libsolidity/codegen/CompilerContext.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libsolidity/codegen/CompilerContext.h') diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index dedcd95f..43e1ea77 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -41,6 +41,7 @@ namespace dev { namespace solidity { +class Compiler; /** * Context to be shared by all units that compile the same contract. @@ -74,8 +75,9 @@ public: /// Returns the number of currently allocated local variables. unsigned numberOfLocalVariables() const; - void setCompiledContracts(std::map const& _contracts) { m_compiledContracts = _contracts; } + void setOtherCompilers(std::map> const& _otherCompilers) { m_otherCompilers = _otherCompilers; } eth::Assembly const& compiledContract(ContractDefinition const& _contract) const; + eth::Assembly const& compiledContractRuntime(ContractDefinition const& _contract) const; void setStackOffset(int _offset) { m_asm->setDeposit(_offset); } void adjustStackOffset(int _adjustment) { m_asm->adjustDeposit(_adjustment); } @@ -307,7 +309,7 @@ private: /// Activated experimental features. std::set m_experimentalFeatures; /// Other already compiled contracts to be used in contract creation calls. - std::map m_compiledContracts; + std::map> m_otherCompilers; /// Storage offsets of state variables std::map> m_stateVariables; /// Offsets of local variables on the stack (relative to stack base). -- cgit v1.2.3 From 29f6aa7d560a7d82a9088489e663a079a3b41f73 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 16 Jan 2019 11:44:11 +0100 Subject: Do not create a copy of the assembly. --- libsolidity/codegen/CompilerContext.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libsolidity/codegen/CompilerContext.h') diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index 43e1ea77..e5ddfbc5 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -76,8 +76,8 @@ public: unsigned numberOfLocalVariables() const; void setOtherCompilers(std::map> const& _otherCompilers) { m_otherCompilers = _otherCompilers; } - eth::Assembly const& compiledContract(ContractDefinition const& _contract) const; - eth::Assembly const& compiledContractRuntime(ContractDefinition const& _contract) const; + std::shared_ptr compiledContract(ContractDefinition const& _contract) const; + std::shared_ptr compiledContractRuntime(ContractDefinition const& _contract) const; void setStackOffset(int _offset) { m_asm->setDeposit(_offset); } void adjustStackOffset(int _adjustment) { m_asm->adjustDeposit(_adjustment); } @@ -224,15 +224,15 @@ public: void optimise(bool _fullOptimsation, unsigned _runs = 200) { m_asm->optimise(_fullOptimsation, m_evmVersion, true, _runs); } /// @returns the runtime context if in creation mode and runtime context is set, nullptr otherwise. - CompilerContext* runtimeContext() { return m_runtimeContext; } + CompilerContext* runtimeContext() const { return m_runtimeContext; } /// @returns the identifier of the runtime subroutine. size_t runtimeSub() const { return m_runtimeSub; } /// @returns a const reference to the underlying assembly. eth::Assembly const& assembly() const { return *m_asm; } - /// @returns non-const reference to the underlying assembly. Should be avoided in favour of - /// wrappers in this class. - eth::Assembly& nonConstAssembly() { return *m_asm; } + /// @returns a shared pointer to the assembly. + /// Should be avoided except when adding sub-assemblies. + std::shared_ptr assemblyPtr() const { return m_asm; } /// @arg _sourceCodes is the map of input files to source code strings std::string assemblyString(StringMap const& _sourceCodes = StringMap()) const -- cgit v1.2.3