void TypeDeduction::Visit(MemberExpression* node) { //TODO: Finish it. node->GetContainer()->Accept(this); StructType *structType = dynamic_cast<StructType *>(node->GetContainer()->GetTag<Type>("Type")); if (structType == NULL) { CompilationContext::GetInstance()->ReportError(node->SourceLocation, false, "Member expression requires struct type."); } std::vector<Declaration *> * fileds = structType->GetFieldList(); for (std::vector<Declaration *>::iterator it = fileds->begin(); it != fileds->end(); ++it) { Declaration *decl = *it; if (decl->GetName() == node->GetFieldName()) { Type *fieldType = decl->GetType(); node->SetTag<Type>("Type", fieldType); return; } } CompilationContext::GetInstance()->ReportError(node->SourceLocation, false, "%s is not a member of type %s", node->GetFieldName().c_str(), structType->ToString().c_str()); abort(); }