From 97350c88ed1c4e607691a7ec2afe7f17d226a0de Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 5 Mar 2015 15:51:26 +0100 Subject: [PATCH] Added JumpType indicator to AssemblyItem. --- libevmcore/Assembly.cpp | 16 +++++++++++++++- libevmcore/Assembly.h | 9 ++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index be35b62c2..c253ef68f 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -77,6 +77,20 @@ int AssemblyItem::deposit() const return 0; } +string AssemblyItem::getJumpTypeAsString() const +{ + switch (m_jumpType) + { + case JumpType::IntoFunction: + return "->"; + case JumpType::OutOfFunction: + return "<-"; + case JumpType::Ordinary: + default: + return "->"; + } +} + unsigned Assembly::bytesRequired() const { for (unsigned br = 1;; ++br) @@ -205,7 +219,7 @@ ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap con switch (i.m_type) { case Operation: - _out << " " << instructionInfo((Instruction)(byte)i.m_data).name; + _out << " " << instructionInfo((Instruction)(byte)i.m_data).name << " " << i.getJumpTypeAsString( ) << endl; break; case Push: _out << " PUSH " << i.m_data; diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index cd71db747..8952deffd 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -42,6 +42,8 @@ class AssemblyItem friend class Assembly; public: + enum class JumpType { Ordinary, IntoFunction, OutOfFunction }; + AssemblyItem(u256 _push): m_type(Push), m_data(_push) {} AssemblyItem(Instruction _i): m_type(Operation), m_data((byte)_i) {} AssemblyItem(AssemblyItemType _type, u256 _data = 0): m_type(_type), m_data(_data) {} @@ -58,13 +60,18 @@ public: int deposit() const; bool match(AssemblyItem const& _i) const { return _i.m_type == UndefinedItem || (m_type == _i.m_type && (m_type != Operation || m_data == _i.m_data)); } - void setLocation(SourceLocation const& _location) { m_location = _location;} + void setLocation(SourceLocation const& _location) { m_location = _location; } SourceLocation const& getLocation() const { return m_location; } + void setJumpType(JumpType _jumpType) { m_jumpType = _jumpType; } + JumpType getJumpType() const { return m_jumpType; } + std::string getJumpTypeAsString() const; + private: AssemblyItemType m_type; u256 m_data; SourceLocation m_location; + JumpType m_jumpType; }; using AssemblyItems = std::vector;