diff options
author | Christian <c@ethdev.com> | 2014-11-13 08:12:57 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-14 21:08:14 +0800 |
commit | c560a62352b8ba1a106ec06aedf779df06af3a22 (patch) | |
tree | 325f19538a1239529e68d0126341e0f6aa655ef7 /AST.cpp | |
parent | 46dd62982084dfe5712292b88047d2a58e0a420e (diff) | |
download | dexon-solidity-c560a62352b8ba1a106ec06aedf779df06af3a22.tar.gz dexon-solidity-c560a62352b8ba1a106ec06aedf779df06af3a22.tar.zst dexon-solidity-c560a62352b8ba1a106ec06aedf779df06af3a22.zip |
Struct types.
Diffstat (limited to 'AST.cpp')
-rw-r--r-- | AST.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -460,8 +460,17 @@ bool FunctionCall::isTypeConversion() const void MemberAccess::checkTypeRequirements() { - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Member access not yet implemented.")); - // m_type = ; + m_expression->checkTypeRequirements(); + m_expression->requireLValue(); + if (m_expression->getType()->getCategory() != Type::Category::STRUCT) + BOOST_THROW_EXCEPTION(createTypeError("Member access to a non-struct (is " + + m_expression->getType()->toString() + ")")); + StructType const& type = dynamic_cast<StructType const&>(*m_expression->getType()); + unsigned memberIndex = type.memberNameToIndex(*m_memberName); + if (memberIndex >= type.getMemberCount()) + BOOST_THROW_EXCEPTION(createTypeError("Member \"" + *m_memberName + "\" not found in " + type.toString())); + m_type = type.getMemberByIndex(memberIndex).getType(); + m_isLvalue = true; } void IndexAccess::checkTypeRequirements() |