mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Clarify some notes in LinkerObject and assert that linkReferences are always correct
This commit is contained in:
parent
3f67912cf4
commit
ae428dc2a0
@ -519,8 +519,11 @@ map<u256, u256> Assembly::optimiseInternal(
|
|||||||
|
|
||||||
LinkerObject const& Assembly::assemble() const
|
LinkerObject const& Assembly::assemble() const
|
||||||
{
|
{
|
||||||
|
// Return the already assembled object, if present.
|
||||||
if (!m_assembledObject.bytecode.empty())
|
if (!m_assembledObject.bytecode.empty())
|
||||||
return m_assembledObject;
|
return m_assembledObject;
|
||||||
|
// Otherwise ensure the object is actually clear.
|
||||||
|
assertThrow(m_assembledObject.linkReferences.empty(), AssemblyException, "Unexpected link references.");
|
||||||
|
|
||||||
size_t subTagSize = 1;
|
size_t subTagSize = 1;
|
||||||
for (auto const& sub: m_subs)
|
for (auto const& sub: m_subs)
|
||||||
|
@ -35,7 +35,9 @@ namespace eth
|
|||||||
*/
|
*/
|
||||||
struct LinkerObject
|
struct LinkerObject
|
||||||
{
|
{
|
||||||
|
/// The bytecode.
|
||||||
bytes bytecode;
|
bytes bytecode;
|
||||||
|
|
||||||
/// Map from offsets in bytecode to library identifiers. The addresses starting at those offsets
|
/// Map from offsets in bytecode to library identifiers. The addresses starting at those offsets
|
||||||
/// need to be replaced by the actual addresses by the linker.
|
/// need to be replaced by the actual addresses by the linker.
|
||||||
std::map<size_t, std::string> linkReferences;
|
std::map<size_t, std::string> linkReferences;
|
||||||
@ -47,7 +49,7 @@ struct LinkerObject
|
|||||||
void link(std::map<std::string, h160> const& _libraryAddresses);
|
void link(std::map<std::string, h160> const& _libraryAddresses);
|
||||||
|
|
||||||
/// @returns a hex representation of the bytecode of the given object, replacing unlinked
|
/// @returns a hex representation of the bytecode of the given object, replacing unlinked
|
||||||
/// addresses by placeholders.
|
/// addresses by placeholders. This output is lowercase.
|
||||||
std::string toHex() const;
|
std::string toHex() const;
|
||||||
|
|
||||||
/// @returns a 36 character string that is used as a placeholder for the library
|
/// @returns a 36 character string that is used as a placeholder for the library
|
||||||
|
Loading…
Reference in New Issue
Block a user