aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm/Assembly.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-09-16 10:46:29 +0800
committerGitHub <noreply@github.com>2017-09-16 10:46:29 +0800
commita0d171722a211720773aae0ded8a80991d44ba9d (patch)
treeae1376cd7d128573edb235f92191dd30118d07bf /libevmasm/Assembly.cpp
parent7dd372ce5c9ea1cacf2c70a16f0285bb74314db8 (diff)
parent80ce3ca66f063d8d87c2393e689f92d8608b4e0a (diff)
downloaddexon-solidity-a0d171722a211720773aae0ded8a80991d44ba9d.tar.gz
dexon-solidity-a0d171722a211720773aae0ded8a80991d44ba9d.tar.zst
dexon-solidity-a0d171722a211720773aae0ded8a80991d44ba9d.zip
Merge pull request #2823 from ethereum/iuliaCompressor
Combine all ABI functions into a single assembly.
Diffstat (limited to 'libevmasm/Assembly.cpp')
-rw-r--r--libevmasm/Assembly.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp
index 6b4bb52b..31857c09 100644
--- a/libevmasm/Assembly.cpp
+++ b/libevmasm/Assembly.cpp
@@ -49,6 +49,8 @@ void Assembly::append(Assembly const& _a)
}
m_deposit = newDeposit;
m_usedTags += _a.m_usedTags;
+ // This does not transfer the names of named tags on purpose. The tags themselves are
+ // transferred, but their names are only available inside the assembly.
for (auto const& i: _a.m_data)
m_data.insert(i);
for (auto const& i: _a.m_strings)
@@ -326,6 +328,14 @@ AssemblyItem const& Assembly::append(AssemblyItem const& _i)
return back();
}
+AssemblyItem Assembly::namedTag(string const& _name)
+{
+ assertThrow(!_name.empty(), AssemblyException, "");
+ if (!m_namedTags.count(_name))
+ m_namedTags[_name] = size_t(newTag().data());
+ return AssemblyItem(Tag, m_namedTags.at(_name));
+}
+
AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier)
{
h256 h(dev::keccak256(_identifier));
@@ -581,6 +591,7 @@ LinkerObject const& Assembly::assemble() const
assertThrow(i.data() != 0, AssemblyException, "");
assertThrow(i.splitForeignPushTag().first == size_t(-1), AssemblyException, "Foreign tag.");
assertThrow(ret.bytecode.size() < 0xffffffffL, AssemblyException, "Tag too large.");
+ assertThrow(m_tagPositionsInBytecode[size_t(i.data())] == size_t(-1), AssemblyException, "Duplicate tag position.");
m_tagPositionsInBytecode[size_t(i.data())] = ret.bytecode.size();
ret.bytecode.push_back((byte)Instruction::JUMPDEST);
break;