protected override void BindReferences(WhamCompilation compilation, DiagnosticBag diagnostics)
    {
        base.BindReferences(compilation, diagnostics);

        var binder = compilation.GetBinder(containingSymbol.Declaration, ContainingSymbol);

        lazyPublication = binder.BindPublicationSymbol(containingSymbol.Declaration, diagnostics);
    }
Exemplo n.º 2
0
    public SourceGlobalNamespaceSymbol(
        ImmutableArray <SourceNode> rootDataNodes,
        WhamCompilation declaringCompilation)
    {
        DeclaringCompilation   = declaringCompilation;
        DeclarationDiagnostics = DiagnosticBag.GetInstance();
        AllRootSymbols         = rootDataNodes.Select(CreateSymbol).Where(x => x is not null).ToImmutableArray() !;
        Rosters       = AllRootSymbols.OfType <RosterSymbol>().ToImmutableArray();
        Catalogues    = AllRootSymbols.OfType <CatalogueBaseSymbol>().ToImmutableArray();
        RootCatalogue = GetOrCreateGamesystemSymbol();
        // TODO more diagnostics, e.g. all catalogues are from the same game system?

        ICatalogueSymbol GetOrCreateGamesystemSymbol()
        {
            var rootCandidates = Catalogues.Where(x => x.IsGamesystem).ToImmutableArray();

            if (rootCandidates.Length > 1)
            {
                foreach (var candidate in rootCandidates)
                {
                    DeclarationDiagnostics.Add(ErrorCode.ERR_MultipleGamesystems, candidate.Declaration);
                }
            }
            return(rootCandidates.FirstOrDefault()
                   ?? DeclaringCompilation.CreateMissingGamesystemSymbol(DeclarationDiagnostics));
        }

        Symbol?CreateSymbol(SourceNode node)
        {
            if (node is CatalogueNode catalogueNode)
            {
                return(new CatalogueSymbol(this, catalogueNode, DeclarationDiagnostics));
            }
            else if (node is GamesystemNode gamesystemNode)
            {
                return(new GamesystemSymbol(this, gamesystemNode, DeclarationDiagnostics));
            }
            else if (node is RosterNode rosterNode)
            {
                return(new RosterSymbol(this, rosterNode, DeclarationDiagnostics));
            }
            else
            {
                DeclarationDiagnostics.Add(ErrorCode.ERR_UnknownCatalogueType, node);
                return(null);
            }
        }
    }
Exemplo n.º 3
0
 public BinderFactory(WhamCompilation compilation, SourceTree sourceTree)
 {
     Compilation         = compilation;
     SourceTree          = sourceTree;
     BuckStopsHereBinder = new(compilation);
 }
Exemplo n.º 4
0
    protected sealed override void BindReferences(WhamCompilation compilation, DiagnosticBag diagnostics)
    {
        base.BindReferences(compilation, diagnostics);

        BindReferencesCore(compilation.GetBinder(Declaration, ContainingSymbol), diagnostics);
    }