From 012e32942df6ef7e48ebf0735eca2cd8fe062af0 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 12 Feb 2015 17:59:52 +0100 Subject: Enum type conversion and member value access. - Added tests for the type conversion part. - Enum member value access still needs some work --- ExpressionCompiler.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ExpressionCompiler.cpp') 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(*_memberAccess.getExpression().getType()); + EnumDefinition const& enumDef = type.getEnumDefinition(); + m_context << enumDef.getMemberValue(_memberAccess.getMemberName()); + } case Type::Category::TypeType: { TypeType const& type = dynamic_cast(*_memberAccess.getExpression().getType()); @@ -562,6 +568,10 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier) { // no-op } + else if (dynamic_cast(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) { -- cgit