aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-14 06:03:32 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-14 06:16:14 +0800
commitfbd39323afbe78a8693bfc2c8c3ffa0f071a2f2a (patch)
treeab7ab61cba779a4422166958d2519337913f6790 /Types.cpp
parent1e4c93d5d3677c60bd82b9f5592158dc0ad5607a (diff)
downloaddexon-solidity-fbd39323afbe78a8693bfc2c8c3ffa0f071a2f2a.tar.gz
dexon-solidity-fbd39323afbe78a8693bfc2c8c3ffa0f071a2f2a.tar.zst
dexon-solidity-fbd39323afbe78a8693bfc2c8c3ffa0f071a2f2a.zip
Moving getMemberValue from EnumDefinition to EnumType
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Types.cpp b/Types.cpp
index 06c0af32..c4a808f8 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -687,6 +687,18 @@ bool EnumType::isExplicitlyConvertibleTo(Type const& _convertTo) const
return _convertTo.getCategory() == getCategory() || _convertTo.getCategory() == Category::Integer;
}
+unsigned int EnumType::getMemberValue(ASTString const& _member) const
+{
+ unsigned int index = 0;
+ for (ASTPointer<EnumValue> const& decl: m_enum.getMembers())
+ {
+ if (decl->getName() == _member)
+ return index;
+ ++index;
+ }
+ BOOST_THROW_EXCEPTION(m_enum.createTypeError("Requested unknown enum value ." + _member));
+}
+
FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal):
m_location(_isInternal ? Location::Internal : Location::External),
m_isConstant(_function.isDeclaredConst()),