mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add swarm hash to the end of the bytecode.
This commit is contained in:
@@ -432,7 +432,7 @@ LinkerObject const& Assembly::assemble() const
|
||||
unsigned bytesPerTag = dev::bytesRequired(bytesRequiredForCode);
|
||||
byte tagPush = (byte)Instruction::PUSH1 - 1 + bytesPerTag;
|
||||
|
||||
unsigned bytesRequiredIncludingData = bytesRequiredForCode + 1;
|
||||
unsigned bytesRequiredIncludingData = bytesRequiredForCode + 1 + m_auxiliaryData.size();
|
||||
for (auto const& sub: m_subs)
|
||||
bytesRequiredIncludingData += sub->assemble().bytecode.size();
|
||||
|
||||
@@ -525,8 +525,9 @@ LinkerObject const& Assembly::assemble() const
|
||||
}
|
||||
}
|
||||
|
||||
if (!dataRef.empty() && !subRef.empty())
|
||||
ret.bytecode.push_back(0);
|
||||
// Append a STOP just to be sure.
|
||||
ret.bytecode.push_back(0);
|
||||
|
||||
for (size_t i = 0; i < m_subs.size(); ++i)
|
||||
{
|
||||
auto references = subRef.equal_range(i);
|
||||
@@ -568,6 +569,9 @@ LinkerObject const& Assembly::assemble() const
|
||||
}
|
||||
ret.bytecode += dataItem.second;
|
||||
}
|
||||
|
||||
ret.bytecode += m_auxiliaryData;
|
||||
|
||||
for (unsigned pos: sizeRef)
|
||||
{
|
||||
bytesRef r(ret.bytecode.data() + pos, bytesPerDataRef);
|
||||
|
||||
@@ -71,6 +71,9 @@ public:
|
||||
AssemblyItem appendJumpI(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(solidity::Instruction::JUMPI); return ret; }
|
||||
AssemblyItem errorTag() { return AssemblyItem(PushTag, 0); }
|
||||
|
||||
/// Appends @a _data literally to the very end of the bytecode.
|
||||
void appendAuxiliaryDataToEnd(bytes const& _data) { m_auxiliaryData += _data; }
|
||||
|
||||
template <class T> Assembly& operator<<(T const& _d) { append(_d); return *this; }
|
||||
AssemblyItems const& items() const { return m_items; }
|
||||
AssemblyItem const& back() const { return m_items.back(); }
|
||||
@@ -125,10 +128,12 @@ private:
|
||||
Json::Value createJsonValue(std::string _name, int _begin, int _end, std::string _value = std::string(), std::string _jumpType = std::string()) const;
|
||||
|
||||
protected:
|
||||
// 0 is reserved for exception
|
||||
/// 0 is reserved for exception
|
||||
unsigned m_usedTags = 1;
|
||||
AssemblyItems m_items;
|
||||
std::map<h256, bytes> m_data;
|
||||
/// Data that is appended to the very end of the contract.
|
||||
bytes m_auxiliaryData;
|
||||
std::vector<std::shared_ptr<Assembly>> m_subs;
|
||||
std::map<h256, std::string> m_strings;
|
||||
std::map<h256, std::string> m_libraries; ///< Identifiers of libraries to be linked.
|
||||
|
||||
Reference in New Issue
Block a user