public IEnumerable <Symbol> Children(Symbol symbol) { if (!(symbol.Package is null)) { throw new ArgumentException("Symbol must be primitive", nameof(symbol)); } return(symbolChildren.TryGetValue(symbol, out var children) ? children : FixedSet <Symbol> .Empty); }
public IEnumerable <Symbol> Children(Symbol symbol) { if (symbol.Package != Package) { throw new ArgumentException("Symbol must be for the package of this tree", nameof(symbol)); } return(symbolChildren.TryGetValue(symbol, out var children) ? children : FixedSet <Symbol> .Empty); }
public IEnumerable <Symbol> Children(Symbol symbol) { if (symbol.Package is null) { return(PrimitiveSymbolTree.Children(symbol)); } if (!packageTrees.TryGetValue(symbol.Package, out var tree)) { throw new ArgumentException("Symbol must be for one of the packages in this tree", nameof(symbol)); } return(tree.Children(symbol)); }
public static void Transform( FixedList <MemberDeclarationSyntax> memberDeclarations, FixedDictionary <FunctionDeclarationSyntax, LiveVariables> liveness) { var inserter = new DeleteInserter(); foreach (var function in memberDeclarations.OfType <FunctionDeclarationSyntax>()) { if (liveness.TryGetValue(function, out var functionLiveness)) { inserter.Transform(function, functionLiveness); } } }
private LexicalScope BuildUsingDirectivesScope( FixedList <IUsingDirectiveSyntax> usingDirectives, LexicalScope containingScope) { if (!usingDirectives.Any()) { return(containingScope); } var importedSymbols = new Dictionary <TypeName, HashSet <IPromise <Symbol> > >(); foreach (var usingDirective in usingDirectives) { if (!namespaces.TryGetValue(usingDirective.Name, out var ns)) { // TODO diagnostics.Add(NameBindingError.UsingNonExistentNamespace(file, usingDirective.Span, usingDirective.Name)); continue; } foreach (var(name, additionalSymbols) in ns.Symbols) { if (importedSymbols.TryGetValue(name, out var symbols)) { symbols.AddRange(additionalSymbols); } else { importedSymbols.Add(name, additionalSymbols.ToHashSet()); } } } var symbolsInScope = importedSymbols.ToFixedDictionary(e => e.Key, e => e.Value.ToFixedSet()); return(NestedScope.Create(containingScope, symbolsInScope)); }
public override PackageSymbol?LookupPackage(Name name) { return(packageAliases.TryGetValue(name, out var package) ? package : null); }
public bool?this[BindingSymbol symbol] => symbolMap.TryGetValue(symbol, out var i) ? (bool?)flags[i] : null;