aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-15 14:41:14 +0800
committerGitHub <noreply@github.com>2017-06-15 14:41:14 +0800
commit3cb71ac51624377174029e244b3cef950dedbfe8 (patch)
treec562a2a0577edbe6cfcda9e10ee63e7643763b80 /libevmasm
parent71fea1e370dfb2d9cb812bcd40b2f8a63ed1d5e0 (diff)
parentc08c4b8b6f0e8c4ccc139e525218cb0cb1ac4ad4 (diff)
downloaddexon-solidity-3cb71ac51624377174029e244b3cef950dedbfe8.tar
dexon-solidity-3cb71ac51624377174029e244b3cef950dedbfe8.tar.gz
dexon-solidity-3cb71ac51624377174029e244b3cef950dedbfe8.tar.bz2
dexon-solidity-3cb71ac51624377174029e244b3cef950dedbfe8.tar.lz
dexon-solidity-3cb71ac51624377174029e244b3cef950dedbfe8.tar.xz
dexon-solidity-3cb71ac51624377174029e244b3cef950dedbfe8.tar.zst
dexon-solidity-3cb71ac51624377174029e244b3cef950dedbfe8.zip
Merge pull request #2398 from ethereum/assembly-cleanup
Remove obsolete features from libevmasm
Diffstat (limited to 'libevmasm')
-rw-r--r--libevmasm/Assembly.cpp9
-rw-r--r--libevmasm/Assembly.h11
2 files changed, 8 insertions, 12 deletions
diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp
index f2a292b0..92a4c2a4 100644
--- a/libevmasm/Assembly.cpp
+++ b/libevmasm/Assembly.cpp
@@ -40,7 +40,7 @@ void Assembly::append(Assembly const& _a)
auto newDeposit = m_deposit + _a.deposit();
for (AssemblyItem i: _a.m_items)
{
- if (i.type() == Tag || (i.type() == PushTag && i != errorTag()))
+ if (i.type() == Tag || i.type() == PushTag)
i.setData(i.data() + m_usedTags);
else if (i.type() == PushSub || i.type() == PushSubSize)
i.setData(i.data() + m_subs.size());
@@ -72,13 +72,6 @@ void Assembly::append(Assembly const& _a, int _deposit)
}
}
-string Assembly::out() const
-{
- stringstream ret;
- stream(ret);
- return ret.str();
-}
-
unsigned Assembly::bytesRequired(unsigned subTagSize) const
{
for (unsigned tagSize = subTagSize; true; ++tagSize)
diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h
index 528c9e74..13d82e1a 100644
--- a/libevmasm/Assembly.h
+++ b/libevmasm/Assembly.h
@@ -69,7 +69,13 @@ public:
AssemblyItem appendJumpI() { auto ret = append(newPushTag()); append(solidity::Instruction::JUMPI); return ret; }
AssemblyItem appendJump(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(solidity::Instruction::JUMP); return ret; }
AssemblyItem appendJumpI(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(solidity::Instruction::JUMPI); return ret; }
- AssemblyItem errorTag() { return AssemblyItem(PushTag, 0); }
+
+ /// Adds a subroutine to the code (in the data section) and pushes its size (via a tag)
+ /// on the stack. @returns the pushsub assembly item.
+ AssemblyItem appendSubroutine(AssemblyPointer const& _assembly) { auto sub = newSub(_assembly); append(newPushSubSize(size_t(sub.data()))); return sub; }
+ void pushSubroutineSize(size_t _subRoutine) { append(newPushSubSize(_subRoutine)); }
+ /// Pushes the offset of the subroutine.
+ void pushSubroutineOffset(size_t _subRoutine) { append(AssemblyItem(PushSub, _subRoutine)); }
/// Appends @a _data literally to the very end of the bytecode.
void appendAuxiliaryDataToEnd(bytes const& _data) { m_auxiliaryData += _data; }
@@ -85,10 +91,7 @@ public:
void ignored() { m_baseDeposit = m_deposit; }
void endIgnored() { m_deposit = m_baseDeposit; m_baseDeposit = 0; }
- void popTo(int _deposit) { while (m_deposit > _deposit) append(solidity::Instruction::POP); }
-
void injectStart(AssemblyItem const& _i);
- std::string out() const;
int deposit() const { return m_deposit; }
void adjustDeposit(int _adjustment) { m_deposit += _adjustment; if (asserts(m_deposit >= 0)) BOOST_THROW_EXCEPTION(InvalidDeposit()); }
void setDeposit(int _deposit) { m_deposit = _deposit; if (asserts(m_deposit >= 0)) BOOST_THROW_EXCEPTION(InvalidDeposit()); }