diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 05:52:04 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 06:16:14 +0800 |
commit | b2575b4bcbd15ec8353a01ae53133f6e71115cce (patch) | |
tree | ba14d6c97ca00ddc6d77876e6876c16eb7664803 /ExpressionCompiler.cpp | |
parent | b20ce4451bb4c2b64b112b8654b36502ae654a24 (diff) | |
download | dexon-solidity-b2575b4bcbd15ec8353a01ae53133f6e71115cce.tar.gz dexon-solidity-b2575b4bcbd15ec8353a01ae53133f6e71115cce.tar.zst dexon-solidity-b2575b4bcbd15ec8353a01ae53133f6e71115cce.zip |
Addressing issues with Enums in Solidity
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 4e72aca5..00c2dafd 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -501,26 +501,26 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) TypeType const& type = dynamic_cast<TypeType const&>(*_memberAccess.getExpression().getType()); ContractType const* contractType; EnumType const* enumType; - if (type.getMembers().getMemberType(member)) + if (!type.getMembers().getMemberType(member)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid member access to " + type.toString())); + + if ((contractType = dynamic_cast<ContractType const*>(type.getActualType().get()))) { - 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; - } + ContractDefinition const& contract = contractType->getContractDefinition(); + for (ASTPointer<FunctionDefinition> const& function: contract.getDefinedFunctions()) + if (function->getName() == member) + { + m_context << m_context.getFunctionEntryLabel(*function).pushTag(); + return; + } } - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid member access to " + type.toString())); + else if ((enumType = dynamic_cast<EnumType const*>(type.getActualType().get()))) + { + EnumDefinition const &enumDef = enumType->getEnumDefinition(); + m_context << enumDef.getMemberValue(_memberAccess.getMemberName()); + return; + } + } case Type::Category::ByteArray: { |