aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm/AssemblyItem.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-20 01:06:13 +0800
committerGitHub <noreply@github.com>2018-12-20 01:06:13 +0800
commit1df8f40cd2fd7b47698d847907b8ca7b47eb488d (patch)
tree5ed5816fe2d1a8a207e750d39884aca7957c8289 /libevmasm/AssemblyItem.h
parentc8a2cb62832afb2dc09ccee6fd42c1516dfdb981 (diff)
parentddf54b21d1d002903624f61173ab4af197f50053 (diff)
downloaddexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.gz
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.bz2
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.lz
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.xz
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.zst
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.zip
Merge pull request #5697 from ethereum/develop
Merge develop into release for 0.5.2
Diffstat (limited to 'libevmasm/AssemblyItem.h')
-rw-r--r--libevmasm/AssemblyItem.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/libevmasm/AssemblyItem.h b/libevmasm/AssemblyItem.h
index a7875171..d21be199 100644
--- a/libevmasm/AssemblyItem.h
+++ b/libevmasm/AssemblyItem.h
@@ -57,22 +57,26 @@ class AssemblyItem
public:
enum class JumpType { Ordinary, IntoFunction, OutOfFunction };
- AssemblyItem(u256 _push, langutil::SourceLocation const& _location = langutil::SourceLocation()):
- AssemblyItem(Push, _push, _location) { }
- AssemblyItem(solidity::Instruction _i, langutil::SourceLocation const& _location = langutil::SourceLocation()):
+ AssemblyItem(u256 _push, langutil::SourceLocation _location = langutil::SourceLocation()):
+ AssemblyItem(Push, std::move(_push), std::move(_location)) { }
+ AssemblyItem(solidity::Instruction _i, langutil::SourceLocation _location = langutil::SourceLocation()):
m_type(Operation),
m_instruction(_i),
- m_location(_location)
+ m_location(std::move(_location))
{}
- AssemblyItem(AssemblyItemType _type, u256 _data = 0, langutil::SourceLocation const& _location = langutil::SourceLocation()):
+ AssemblyItem(AssemblyItemType _type, u256 _data = 0, langutil::SourceLocation _location = langutil::SourceLocation()):
m_type(_type),
- m_location(_location)
+ m_location(std::move(_location))
{
if (m_type == Operation)
m_instruction = Instruction(uint8_t(_data));
else
- m_data = std::make_shared<u256>(_data);
+ m_data = std::make_shared<u256>(std::move(_data));
}
+ AssemblyItem(AssemblyItem const&) = default;
+ AssemblyItem(AssemblyItem&&) = default;
+ AssemblyItem& operator=(AssemblyItem const&) = default;
+ AssemblyItem& operator=(AssemblyItem&&) = default;
AssemblyItem tag() const { assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); return AssemblyItem(Tag, data()); }
AssemblyItem pushTag() const { assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); return AssemblyItem(PushTag, data()); }
@@ -114,6 +118,13 @@ public:
return data() < _other.data();
}
+ /// Shortcut that avoids constructing an AssemblyItem just to perform the comparison.
+ bool operator==(Instruction _instr) const
+ {
+ return type() == Operation && instruction() == _instr;
+ }
+ bool operator!=(Instruction _instr) const { return !operator==(_instr); }
+
/// @returns an upper bound for the number of bytes required by this item, assuming that
/// the value of a jump tag takes @a _addressLength bytes.
unsigned bytesRequired(unsigned _addressLength) const;