Add verbatim builtin.

This commit is contained in:
chriseth
2021-04-26 19:56:44 +02:00
parent 2969bc0f3e
commit e2d8005737
34 changed files with 371 additions and 13 deletions
+12 -2
View File
@@ -33,9 +33,11 @@
#include <liblangutil/Exceptions.h>
#include <fstream>
#include <json/json.h>
#include <fstream>
#include <range/v3/algorithm/any_of.hpp>
using namespace std;
using namespace solidity;
using namespace solidity::evmasm;
@@ -317,6 +319,9 @@ Json::Value Assembly::assemblyJSON(map<string, unsigned> const& _sourceIndices)
case PushData:
collection.append(createJsonValue("PUSH data", sourceIndex, i.location().start, i.location().end, toStringInHex(i.data())));
break;
case VerbatimBytecode:
collection.append(createJsonValue("VERBATIM", sourceIndex, i.location().start, i.location().end, toHex(i.verbatimData())));
break;
default:
assertThrow(false, InvalidOpcode, "");
}
@@ -482,7 +487,9 @@ map<u256, u256> Assembly::optimiseInternal(
// function types that can be stored in storage.
AssemblyItems optimisedItems;
bool usesMSize = (find(m_items.begin(), m_items.end(), AssemblyItem{Instruction::MSIZE}) != m_items.end());
bool usesMSize = ranges::any_of(m_items, [](AssemblyItem const& _i) {
return _i == AssemblyItem{Instruction::MSIZE} || _i.type() == VerbatimBytecode;
});
auto iter = m_items.begin();
while (iter != m_items.end())
@@ -682,6 +689,9 @@ LinkerObject const& Assembly::assemble() const
ret.immutableReferences[i.data()].second.emplace_back(ret.bytecode.size());
ret.bytecode.resize(ret.bytecode.size() + 32);
break;
case VerbatimBytecode:
ret.bytecode += i.verbatimData();
break;
case AssignImmutable:
{
auto const& offsets = immutableReferencesBySub[i.data()].second;