aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-13 00:59:52 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-14 06:16:14 +0800
commit012e32942df6ef7e48ebf0735eca2cd8fe062af0 (patch)
tree28052abd11444c3200308d411cc751b93588d020 /AST.cpp
parente7f40863ef223c47dffe69c812d363b7553151d1 (diff)
downloaddexon-solidity-012e32942df6ef7e48ebf0735eca2cd8fe062af0.tar.gz
dexon-solidity-012e32942df6ef7e48ebf0735eca2cd8fe062af0.tar.zst
dexon-solidity-012e32942df6ef7e48ebf0735eca2cd8fe062af0.zip
Enum type conversion and member value access.
- Added tests for the type conversion part. - Enum member value access still needs some work
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/AST.cpp b/AST.cpp
index 488bd4cd..7653952f 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -277,6 +277,19 @@ TypePointer EnumDefinition::getType(ContractDefinition const*) const
return make_shared<TypeType>(make_shared<EnumType>(*this));
}
+
+unsigned int EnumDefinition::getMemberValue(ASTString const& _member) const
+{
+ unsigned int index = 0;
+ for (ASTPointer<EnumDeclaration> const& decl: m_members)
+ {
+ if (decl->getName() == _member)
+ return index;
+ ++index;
+ }
+ BOOST_THROW_EXCEPTION(createTypeError("Requested unknown enum value ." + _member));
+}
+
TypePointer FunctionDefinition::getType(ContractDefinition const*) const
{
return make_shared<FunctionType>(*this);