diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-13 20:32:18 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 06:16:14 +0800 |
commit | 91943e736854d764811d8633f9e0f0187fe927e2 (patch) | |
tree | 8738aa5bdfdbabc9a1d3fbb4d40c95f2a35ff62a /ExpressionCompiler.cpp | |
parent | 012e32942df6ef7e48ebf0735eca2cd8fe062af0 (diff) | |
download | dexon-solidity-91943e736854d764811d8633f9e0f0187fe927e2.tar.gz dexon-solidity-91943e736854d764811d8633f9e0f0187fe927e2.tar.zst dexon-solidity-91943e736854d764811d8633f9e0f0187fe927e2.zip |
Enum Value member access should now work properly
- Also detection of duplicate enum values and tests for them have been
added
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index dd41b485..4e72aca5 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -494,20 +494,31 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) EnumType const& type = dynamic_cast<EnumType const&>(*_memberAccess.getExpression().getType()); EnumDefinition const& enumDef = type.getEnumDefinition(); m_context << enumDef.getMemberValue(_memberAccess.getMemberName()); + break; } case Type::Category::TypeType: { TypeType const& type = dynamic_cast<TypeType const&>(*_memberAccess.getExpression().getType()); + ContractType const* contractType; + EnumType const* enumType; if (type.getMembers().getMemberType(member)) { - ContractDefinition const& contract = dynamic_cast<ContractType const&>(*type.getActualType()) - .getContractDefinition(); - for (ASTPointer<FunctionDefinition> const& function: contract.getDefinedFunctions()) - if (function->getName() == member) - { - m_context << m_context.getFunctionEntryLabel(*function).pushTag(); - return; - } + if ((contractType = dynamic_cast<ContractType const*>(type.getActualType().get()))) + { + ContractDefinition const& contract = contractType->getContractDefinition(); + for (ASTPointer<FunctionDefinition> const& function: contract.getDefinedFunctions()) + if (function->getName() == member) + { + m_context << m_context.getFunctionEntryLabel(*function).pushTag(); + return; + } + } + else if ((enumType = dynamic_cast<EnumType const*>(type.getActualType().get()))) + { + EnumDefinition const &enumDef = enumType->getEnumDefinition(); + m_context << enumDef.getMemberValue(_memberAccess.getMemberName()); + return; + } } BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid member access to " + type.toString())); } |