From 4d715e9055f4c7ba7ef86a540dc2e3fbe0fca3a0 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 11 Apr 2017 19:53:55 +0200 Subject: Implement missing assembly output functions and do not use PushString for assembly. --- Changelog.md | 1 + libevmasm/Assembly.cpp | 3 ++- libevmasm/AssemblyItem.cpp | 17 ++++++++++++----- libsolidity/inlineasm/AsmCodeGen.cpp | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index 5c991032..7142655b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ Features: Bugfixes: * Type system: Contract inheriting from base with unimplemented constructor should be abstract. + * Assembly output: Implement missing AssemblyItem types. ### 0.4.10 (2017-03-15) diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index f12e8aa8..ea061a30 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -205,7 +205,8 @@ ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap con { _out << _prefix << "stop" << endl; for (auto const& i: m_data) - assertThrow(u256(i.first) < m_subs.size(), AssemblyException, "Data not yet implemented."); + if (u256(i.first) >= m_subs.size()) + _out << _prefix << "data_" << toHex(u256(i.first)) << " " << toHex(i.second) << endl; for (size_t i = 0; i < m_subs.size(); ++i) { diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 26d9fded..55130f28 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -159,18 +159,25 @@ string AssemblyItem::toAssemblyText() const text = toHex(toCompactBigEndian(data(), 1), 1, HexPrefix::Add); break; case PushString: - assertThrow(false, AssemblyException, "Push string assembly output not implemented."); + text = string("data_") + toHex(data()); break; case PushTag: - assertThrow(data() < 0x10000, AssemblyException, "Sub-assembly tags not yet implemented."); - text = string("tag_") + to_string(size_t(data())); + { + size_t sub; + size_t tag; + tie(sub, tag) = splitForeignPushTag(); + if (sub == size_t(-1)) + text = string("tag_") + to_string(tag); + else + text = string("tag_") + to_string(sub) + "_" + to_string(tag); break; + } case Tag: - assertThrow(data() < 0x10000, AssemblyException, "Sub-assembly tags not yet implemented."); + assertThrow(data() < 0x10000, AssemblyException, "Declaration of sub-assembly tag."); text = string("tag_") + to_string(size_t(data())) + ":"; break; case PushData: - assertThrow(false, AssemblyException, "Push data not implemented."); + text = string("data_") + toHex(data()); break; case PushSub: text = string("dataOffset(sub_") + to_string(size_t(data())) + ")"; diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp index 78a9ee27..fdfd9abe 100644 --- a/libsolidity/inlineasm/AsmCodeGen.cpp +++ b/libsolidity/inlineasm/AsmCodeGen.cpp @@ -130,7 +130,7 @@ public: else { solAssert(_literal.value.size() <= 32, ""); - m_state.assembly.append(_literal.value); + m_state.assembly.append(u256(h256(_literal.value, h256::FromBinary, h256::AlignLeft))); } } void operator()(assembly::Identifier const& _identifier) -- cgit From 8ebea783f4b32c6ff4bb3771a28127676aeb9bad Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 12 Apr 2017 16:30:27 +0200 Subject: Initialize local variables. --- libevmasm/AssemblyItem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 55130f28..e69b5932 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -163,8 +163,8 @@ string AssemblyItem::toAssemblyText() const break; case PushTag: { - size_t sub; - size_t tag; + size_t sub{0}; + size_t tag{0}; tie(sub, tag) = splitForeignPushTag(); if (sub == size_t(-1)) text = string("tag_") + to_string(tag); -- cgit