| 3940 | } |
| 3941 | |
| 3942 | void BfCompiler::VisitSourceExteriorNodes() |
| 3943 | { |
| 3944 | BP_ZONE("BfCompiler::VisitSourceExteriorNodes"); |
| 3945 | |
| 3946 | String str; |
| 3947 | Array<BfAtom*> namespaceParts; |
| 3948 | Array<BfAstNode*> srcNodes; |
| 3949 | std::function<bool(BfAstNode*, bool)> _AddName = [&](BfAstNode* node, bool wantErrors) |
| 3950 | { |
| 3951 | if (node == NULL) |
| 3952 | return false; |
| 3953 | if (auto qualifiedName = BfNodeDynCast<BfQualifiedNameNode>(node)) |
| 3954 | { |
| 3955 | if (!_AddName(qualifiedName->mLeft, wantErrors)) |
| 3956 | return false; |
| 3957 | if (!_AddName(qualifiedName->mRight, wantErrors)) |
| 3958 | return false; |
| 3959 | return true; |
| 3960 | } |
| 3961 | else if (auto qualifedTypeRef = BfNodeDynCast<BfQualifiedTypeReference>(node)) |
| 3962 | { |
| 3963 | if (!_AddName(qualifedTypeRef->mLeft, wantErrors)) |
| 3964 | return false; |
| 3965 | if (!_AddName(qualifedTypeRef->mRight, wantErrors)) |
| 3966 | return false; |
| 3967 | return true; |
| 3968 | } |
| 3969 | else if ((node->IsA<BfIdentifierNode>()) || (node->IsA<BfNamedTypeReference>())) |
| 3970 | { |
| 3971 | srcNodes.Add(node); |
| 3972 | str.Clear(); |
| 3973 | node->ToString(str); |
| 3974 | auto atom = mSystem->FindAtom(str); |
| 3975 | if (atom == NULL) |
| 3976 | { |
| 3977 | String prevNamespace; |
| 3978 | for (auto part : namespaceParts) |
| 3979 | { |
| 3980 | if (!prevNamespace.IsEmpty()) |
| 3981 | prevNamespace += "."; |
| 3982 | prevNamespace += part->mString; |
| 3983 | } |
| 3984 | if (wantErrors) |
| 3985 | { |
| 3986 | if (prevNamespace.IsEmpty()) |
| 3987 | mPassInstance->Fail(StrFormat("The namespace '%s' does not exist", str.c_str()), node); |
| 3988 | else |
| 3989 | mPassInstance->Fail(StrFormat("The namespace '%s' does not exist in the namespace '%s'", str.c_str(), prevNamespace.c_str()), node); |
| 3990 | } |
| 3991 | return false; |
| 3992 | } |
| 3993 | namespaceParts.Add(atom); |
| 3994 | return true; |
| 3995 | } |
| 3996 | return false; |
| 3997 | }; |
| 3998 | |
| 3999 | auto _CheckNamespace = [&](BfParser* parser, bool wantErrors, bool& failed) |
nothing calls this directly
no test coverage detected