diff options
author | Yoichi Hirai <i@yoichihirai.com> | 2016-11-08 01:15:59 +0800 |
---|---|---|
committer | Yoichi Hirai <i@yoichihirai.com> | 2016-11-12 00:47:48 +0800 |
commit | e6098f0039868222c758e4d10f23ace59d1a3195 (patch) | |
tree | e0f9e4b1aa12f4c98ff2621e7ce1efa5dbaf9459 /libsolidity/ast | |
parent | 7820f80192807b228e57ad9879d5ce2787a4d278 (diff) | |
download | dexon-solidity-e6098f0039868222c758e4d10f23ace59d1a3195.tar.gz dexon-solidity-e6098f0039868222c758e4d10f23ace59d1a3195.tar.zst dexon-solidity-e6098f0039868222c758e4d10f23ace59d1a3195.zip |
ast: add EnumType::numberOfMembers()
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/Types.cpp | 7 | ||||
-rw-r--r-- | libsolidity/ast/Types.h | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 0e077b32..a134a0bb 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -1561,7 +1561,7 @@ bool EnumType::operator==(Type const& _other) const unsigned EnumType::storageBytes() const { - size_t elements = m_enum.members().size(); + size_t elements = numberOfMembers(); if (elements <= 1) return 1; else @@ -1578,6 +1578,11 @@ string EnumType::canonicalName(bool) const return m_enum.annotation().canonicalName; } +size_t EnumType::numberOfMembers() const +{ + return m_enum.members().size(); +}; + bool EnumType::isExplicitlyConvertibleTo(Type const& _convertTo) const { return _convertTo.category() == category() || _convertTo.category() == Category::Integer; diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 3f94d11a..082e16a6 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -738,6 +738,7 @@ public: EnumDefinition const& enumDefinition() const { return m_enum; } /// @returns the value that the string has in the Enum unsigned int memberValue(ASTString const& _member) const; + size_t numberOfMembers() const; private: EnumDefinition const& m_enum; |