diff options
author | chriseth <chris@ethereum.org> | 2017-02-01 01:29:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-01 01:29:51 +0800 |
commit | 364da425d3116a4b85863df39a1864340861d71e (patch) | |
tree | 521a52c3f8182cd6a054f148bd649c8b6b0e2af9 /libevmasm/LinkerObject.cpp | |
parent | 60cc1668517f56ce6ca8225555472e7a27eab8b0 (diff) | |
parent | 7b18c9df1dfa0076566bfa1e4a3bc5e5ba9c8594 (diff) | |
download | dexon-solidity-364da425d3116a4b85863df39a1864340861d71e.tar dexon-solidity-364da425d3116a4b85863df39a1864340861d71e.tar.gz dexon-solidity-364da425d3116a4b85863df39a1864340861d71e.tar.bz2 dexon-solidity-364da425d3116a4b85863df39a1864340861d71e.tar.lz dexon-solidity-364da425d3116a4b85863df39a1864340861d71e.tar.xz dexon-solidity-364da425d3116a4b85863df39a1864340861d71e.tar.zst dexon-solidity-364da425d3116a4b85863df39a1864340861d71e.zip |
Merge pull request #1622 from ethereum/develop
Solidity version 0.4.9
Diffstat (limited to 'libevmasm/LinkerObject.cpp')
-rw-r--r-- | libevmasm/LinkerObject.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/libevmasm/LinkerObject.cpp b/libevmasm/LinkerObject.cpp index 93e4067c..06607089 100644 --- a/libevmasm/LinkerObject.cpp +++ b/libevmasm/LinkerObject.cpp @@ -37,13 +37,10 @@ void LinkerObject::link(map<string, h160> const& _libraryAddresses) { std::map<size_t, std::string> remainingRefs; for (auto const& linkRef: linkReferences) - { - auto it = _libraryAddresses.find(linkRef.second); - if (it == _libraryAddresses.end()) - remainingRefs.insert(linkRef); + if (h160 const* address = matchLibrary(linkRef.second, _libraryAddresses)) + address->ref().copyTo(ref(bytecode).cropped(linkRef.first, 20)); else - it->second.ref().copyTo(ref(bytecode).cropped(linkRef.first, 20)); - } + remainingRefs.insert(linkRef); linkReferences.swap(remainingRefs); } @@ -60,3 +57,23 @@ string LinkerObject::toHex() const } return hex; } + +h160 const* +LinkerObject::matchLibrary( + string const& _linkRefName, + map<string, h160> const& _libraryAddresses +) +{ + auto it = _libraryAddresses.find(_linkRefName); + if (it != _libraryAddresses.end()) + return &it->second; + // If the user did not supply a fully qualified library name, + // try to match only the simple libary name + size_t colon = _linkRefName.find(':'); + if (colon == string::npos) + return nullptr; + it = _libraryAddresses.find(_linkRefName.substr(colon + 1)); + if (it != _libraryAddresses.end()) + return &it->second; + return nullptr; +} |