ast: add EnumType::numberOfMembers()

This commit is contained in:
Yoichi Hirai 2016-11-07 18:15:59 +01:00
parent 7820f80192
commit e6098f0039
No known key found for this signature in database
GPG Key ID: E7B75D080FCF7992
2 changed files with 7 additions and 1 deletions

View File

@ -1561,7 +1561,7 @@ bool EnumType::operator==(Type const& _other) const
unsigned EnumType::storageBytes() const unsigned EnumType::storageBytes() const
{ {
size_t elements = m_enum.members().size(); size_t elements = numberOfMembers();
if (elements <= 1) if (elements <= 1)
return 1; return 1;
else else
@ -1578,6 +1578,11 @@ string EnumType::canonicalName(bool) const
return m_enum.annotation().canonicalName; return m_enum.annotation().canonicalName;
} }
size_t EnumType::numberOfMembers() const
{
return m_enum.members().size();
};
bool EnumType::isExplicitlyConvertibleTo(Type const& _convertTo) const bool EnumType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{ {
return _convertTo.category() == category() || _convertTo.category() == Category::Integer; return _convertTo.category() == category() || _convertTo.category() == Category::Integer;

View File

@ -738,6 +738,7 @@ public:
EnumDefinition const& enumDefinition() const { return m_enum; } EnumDefinition const& enumDefinition() const { return m_enum; }
/// @returns the value that the string has in the Enum /// @returns the value that the string has in the Enum
unsigned int memberValue(ASTString const& _member) const; unsigned int memberValue(ASTString const& _member) const;
size_t numberOfMembers() const;
private: private:
EnumDefinition const& m_enum; EnumDefinition const& m_enum;