aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-11-13 08:12:57 +0800
committerChristian <c@ethdev.com>2014-11-14 21:08:14 +0800
commitc560a62352b8ba1a106ec06aedf779df06af3a22 (patch)
tree325f19538a1239529e68d0126341e0f6aa655ef7 /AST.cpp
parent46dd62982084dfe5712292b88047d2a58e0a420e (diff)
downloaddexon-solidity-c560a62352b8ba1a106ec06aedf779df06af3a22.tar.gz
dexon-solidity-c560a62352b8ba1a106ec06aedf779df06af3a22.tar.zst
dexon-solidity-c560a62352b8ba1a106ec06aedf779df06af3a22.zip
Struct types.
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/AST.cpp b/AST.cpp
index d5f856df..e8bdecf3 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -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()