diff options
author | chriseth <c@ethdev.com> | 2015-09-14 20:56:01 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-09-14 20:56:01 +0800 |
commit | 9309b6aa82de6bbe7a93d34559b6cfca20c5978d (patch) | |
tree | 1457e0d1d8f5627c01c6082252f3050bc6a5dce3 /libsolidity | |
parent | 4360e0459622e7843ca9f8d7fb5113da0b8a044e (diff) | |
parent | 70c0ed41290f3de001fed5b4f0f28993486ba445 (diff) | |
download | dexon-solidity-9309b6aa82de6bbe7a93d34559b6cfca20c5978d.tar.gz dexon-solidity-9309b6aa82de6bbe7a93d34559b6cfca20c5978d.tar.zst dexon-solidity-9309b6aa82de6bbe7a93d34559b6cfca20c5978d.zip |
Merge pull request #70 from chriseth/sol_libraries2
Commandline interface for linker.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/CompilerStack.cpp | 10 | ||||
-rw-r--r-- | libsolidity/CompilerStack.h | 7 | ||||
-rw-r--r-- | libsolidity/Types.cpp | 7 |
3 files changed, 20 insertions, 4 deletions
diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index 3da982a4..70bb1b4c 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -181,6 +181,16 @@ eth::LinkerObject const& CompilerStack::compile(string const& _sourceCode, bool return object(); } +void CompilerStack::link(const std::map<string, h160>& _libraries) +{ + for (auto& contract: m_contracts) + { + contract.second.object.link(_libraries); + contract.second.runtimeObject.link(_libraries); + contract.second.cloneObject.link(_libraries); + } +} + eth::AssemblyItems const* CompilerStack::assemblyItems(string const& _contractName) const { Contract const& currentContract = contract(_contractName); diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index 8db8aff4..99e8af1a 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -96,9 +96,12 @@ public: /// @returns the compiled linker object eth::LinkerObject const& compile(std::string const& _sourceCode, bool _optimize = false); - /// @returns the assembled bytecode for a contract (empty if it has to be linked or lacks implementation). + /// Inserts the given addresses into the linker objects of all compiled contracts. + void link(std::map<std::string, h160> const& _libraries); + + /// @returns the assembled object for a contract. eth::LinkerObject const& object(std::string const& _contractName = "") const; - /// @returns the runtime bytecode for the contract (empty if it has to be linked or lacks implementation). + /// @returns the runtime object for the contract. eth::LinkerObject const& runtimeObject(std::string const& _contractName = "") const; /// @returns the bytecode of a contract that uses an already deployed contract via CALLCODE. /// The returned bytes will contain a sequence of 20 bytes of the format "XXX...XXX" which have to diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 5bc7cd43..beb5becd 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -925,7 +925,10 @@ bool ContractType::operator==(Type const& _other) const string ContractType::toString(bool) const { - return "contract " + string(m_super ? "super " : "") + m_contract.name(); + return + string(m_contract.isLibrary() ? "library " : "contract ") + + string(m_super ? "super " : "") + + m_contract.name(); } MemberList const& ContractType::members() const @@ -971,7 +974,7 @@ MemberList const& ContractType::members() const for (auto const& it: m_contract.interfaceFunctions()) members.push_back(MemberList::Member( it.second->declaration().name(), - it.second->asMemberFunction(false), + it.second->asMemberFunction(m_contract.isLibrary()), &it.second->declaration() )); m_members.reset(new MemberList(members)); |