aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/AsmCodeGen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/codegen/AsmCodeGen.cpp')
-rw-r--r--libsolidity/codegen/AsmCodeGen.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/libsolidity/codegen/AsmCodeGen.cpp b/libsolidity/codegen/AsmCodeGen.cpp
index 4ca0c4e2..dfcc900b 100644
--- a/libsolidity/codegen/AsmCodeGen.cpp
+++ b/libsolidity/codegen/AsmCodeGen.cpp
@@ -27,10 +27,13 @@
#include <libyul/backends/evm/EVMCodeTransform.h>
#include <libevmasm/Assembly.h>
+#include <libevmasm/AssemblyItem.h>
#include <libevmasm/Instruction.h>
#include <liblangutil/SourceLocation.h>
+#include <libdevcore/FixedHash.h>
+
#include <memory>
#include <functional>
@@ -131,6 +134,39 @@ void EthAssemblyAdapter::appendAssemblySize()
m_assembly.appendProgramSize();
}
+pair<shared_ptr<AbstractAssembly>, AbstractAssembly::SubID> EthAssemblyAdapter::createSubAssembly()
+{
+ shared_ptr<eth::Assembly> assembly{make_shared<eth::Assembly>()};
+ auto sub = m_assembly.newSub(assembly);
+ return {make_shared<EthAssemblyAdapter>(*assembly), size_t(sub.data())};
+}
+
+void EthAssemblyAdapter::appendDataOffset(AbstractAssembly::SubID _sub)
+{
+ auto it = m_dataHashBySubId.find(_sub);
+ if (it == m_dataHashBySubId.end())
+ m_assembly.pushSubroutineOffset(size_t(_sub));
+ else
+ m_assembly << eth::AssemblyItem(eth::PushData, it->second);
+}
+
+void EthAssemblyAdapter::appendDataSize(AbstractAssembly::SubID _sub)
+{
+ auto it = m_dataHashBySubId.find(_sub);
+ if (it == m_dataHashBySubId.end())
+ m_assembly.pushSubroutineSize(size_t(_sub));
+ else
+ m_assembly << u256(m_assembly.data(h256(it->second)).size());
+}
+
+AbstractAssembly::SubID EthAssemblyAdapter::appendData(bytes const& _data)
+{
+ eth::AssemblyItem pushData = m_assembly.newData(_data);
+ SubID subID = m_nextDataCounter++;
+ m_dataHashBySubId[subID] = pushData.data();
+ return subID;
+}
+
EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(eth::AssemblyItem const& _tag)
{
u256 id = _tag.data();