diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-13 00:59:52 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 06:16:14 +0800 |
commit | 012e32942df6ef7e48ebf0735eca2cd8fe062af0 (patch) | |
tree | 28052abd11444c3200308d411cc751b93588d020 /ExpressionCompiler.cpp | |
parent | e7f40863ef223c47dffe69c812d363b7553151d1 (diff) | |
download | dexon-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 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 90f860a1..dd41b485 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -489,6 +489,12 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) m_currentLValue.retrieveValueIfLValueNotRequested(_memberAccess); break; } + case Type::Category::Enum: + { + EnumType const& type = dynamic_cast<EnumType const&>(*_memberAccess.getExpression().getType()); + EnumDefinition const& enumDef = type.getEnumDefinition(); + m_context << enumDef.getMemberValue(_memberAccess.getMemberName()); + } case Type::Category::TypeType: { TypeType const& type = dynamic_cast<TypeType const&>(*_memberAccess.getExpression().getType()); @@ -562,6 +568,10 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier) { // no-op } + else if (dynamic_cast<EnumDefinition const*>(declaration)) + { + // no-op + } else { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Identifier type not expected in expression context.")); @@ -746,7 +756,7 @@ void ExpressionCompiler::appendTypeConversion(Type const& _typeOnStack, Type con } } else if (stackTypeCategory == Type::Category::Integer || stackTypeCategory == Type::Category::Contract || - stackTypeCategory == Type::Category::IntegerConstant) + stackTypeCategory == Type::Category::IntegerConstant || stackTypeCategory == Type::Category::Enum) { if (targetTypeCategory == Type::Category::String && stackTypeCategory == Type::Category::Integer) { |