diff options
Diffstat (limited to 'libyul/backends/evm')
-rw-r--r-- | libyul/backends/evm/AbstractAssembly.h | 10 | ||||
-rw-r--r-- | libyul/backends/evm/EVMAssembly.cpp | 21 | ||||
-rw-r--r-- | libyul/backends/evm/EVMAssembly.h | 4 |
3 files changed, 35 insertions, 0 deletions
diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index 97b1d305..1f224ded 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -26,6 +26,7 @@ #include <libdevcore/CommonData.h> #include <functional> +#include <memory> namespace langutil { @@ -52,6 +53,7 @@ class AbstractAssembly { public: using LabelID = size_t; + using SubID = size_t; virtual ~AbstractAssembly() {} @@ -98,6 +100,14 @@ public: /// Append the assembled size as a constant. virtual void appendAssemblySize() = 0; + /// Creates a new sub-assembly, which can be referenced using dataSize and dataOffset. + virtual std::pair<std::shared_ptr<AbstractAssembly>, SubID> createSubAssembly() = 0; + /// Appends the offset of the given sub-assembly or data. + virtual void appendDataOffset(SubID _sub) = 0; + /// Appends the size of the given sub-assembly or data. + virtual void appendDataSize(SubID _sub) = 0; + /// Appends the given data to the assembly and returns its ID. + virtual SubID appendData(dev::bytes const& _data) = 0; }; enum class IdentifierContext { LValue, RValue }; diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp index 99506317..2cf9f001 100644 --- a/libyul/backends/evm/EVMAssembly.cpp +++ b/libyul/backends/evm/EVMAssembly.cpp @@ -194,6 +194,27 @@ void EVMAssembly::appendAssemblySize() m_bytecode += bytes(assemblySizeReferenceSize); } +pair<shared_ptr<AbstractAssembly>, AbstractAssembly::SubID> EVMAssembly::createSubAssembly() +{ + solAssert(false, "Sub assemblies not implemented."); + return {}; +} + +void EVMAssembly::appendDataOffset(AbstractAssembly::SubID) +{ + solAssert(false, "Data not implemented."); +} + +void EVMAssembly::appendDataSize(AbstractAssembly::SubID) +{ + solAssert(false, "Data not implemented."); +} + +AbstractAssembly::SubID EVMAssembly::appendData(bytes const&) +{ + solAssert(false, "Data not implemented."); +} + void EVMAssembly::updateReference(size_t pos, size_t size, u256 value) { solAssert(m_bytecode.size() >= size && pos <= m_bytecode.size() - size, ""); diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h index d0a437cc..cef9c19a 100644 --- a/libyul/backends/evm/EVMAssembly.h +++ b/libyul/backends/evm/EVMAssembly.h @@ -77,6 +77,10 @@ public: /// Append the assembled size as a constant. void appendAssemblySize() override; + std::pair<std::shared_ptr<AbstractAssembly>, SubID> createSubAssembly() override; + void appendDataOffset(SubID _sub) override; + void appendDataSize(SubID _sub) override; + SubID appendData(dev::bytes const& _data) override; /// Resolves references inside the bytecode and returns the linker object. dev::eth::LinkerObject finalize(); |