private void Check(FixedSet <IEntityDeclarationSyntax> entities) { foreach (var entity in entities) { ResolveBodyTypes(entity); } }
/// <remarks> /// It wouldn't make sense to get all declarations including non-member because /// that includes namespace declarations. However, some namespaces come from /// the implicit namespace of a compilation unit or are implicitly declared, /// so it wouldn't give a full list of the namespaces. /// </remarks> private static IEnumerable <IEntityDeclarationSyntax> GetEntityDeclarations( FixedSet <ICompilationUnitSyntax> compilationUnits) { var declarations = new Queue <IDeclarationSyntax>(); declarations.EnqueueRange(compilationUnits.SelectMany(cu => cu.Declarations)); while (declarations.TryDequeue(out var declaration)) { switch (declaration) { default: throw ExhaustiveMatch.Failed(declaration); case IMemberDeclarationSyntax syn: yield return(syn); break; case IFunctionDeclarationSyntax syn: yield return(syn); break; case INamespaceDeclarationSyntax syn: declarations.EnqueueRange(syn.Declarations); break; case IClassDeclarationSyntax syn: yield return(syn); declarations.EnqueueRange(syn.Members); break; } } }
private void ResolveReachabilityAnnotation( CodeFile file, IParameterNameSyntax syntax, FixedSet <BindingSymbol> symbols) { switch (syntax) { default: throw ExhaustiveMatch.Failed(syntax); case INamedParameterNameSyntax syn: { var referencedSymbol = symbols.OfType <VariableSymbol>().SingleOrDefault(s => s.Name == syn.Name); syn.ReferencedSymbol.Fulfill(referencedSymbol); if (referencedSymbol is null) { diagnostics.Add(NameBindingError.CouldNotBindParameterName(file, syn.Span)); } } break; case ISelfParameterNameSyntax syn: { var referencedSymbol = symbols.OfType <SelfParameterSymbol>().SingleOrDefault(); syn.ReferencedSymbol.Fulfill(referencedSymbol); if (referencedSymbol is null) { diagnostics.Add(NameBindingError.CouldNotBindParameterName(file, syn.Span)); } } break; } }
protected ReachabilityChain(FixedSet <Reference> references) { if (references.Count == 0) { throw new ArgumentException("Must not be empty", nameof(references)); } References = references; }
public FunctionSymbol( Symbol containingSymbol, Name name, FixedList <DataType> parameterDataTypes, FixedSet <ReachabilityAnnotation>?reachabilityAnnotations = null) : this(containingSymbol, name, parameterDataTypes, DataType.Void, reachabilityAnnotations ?? FixedSet <ReachabilityAnnotation> .Empty) { }
protected FunctionOrMethodSymbol( Symbol containingSymbol, Name name, FixedList <DataType> parameterDataTypes, DataType returnDataType, FixedSet <ReachabilityAnnotation> reachabilityAnnotations) : base(containingSymbol, name, parameterDataTypes, returnDataType, reachabilityAnnotations) { Name = name; }
public static void Analyze( FixedSet <IExecutableDeclaration> declarations, ISymbolTree symbolTree, Diagnostics diagnostics) { foreach (var declaration in declarations) { new ReachabilityAnalyzer(declaration, symbolTree, diagnostics).Analyze(); } }
public FunctionSymbol( Symbol containingSymbol, Name name, FixedList <DataType> parameterDataTypes, DataType returnDataType, FixedSet <ReachabilityAnnotation>?reachabilityAnnotations = null) : base(containingSymbol, name, parameterDataTypes, returnDataType, reachabilityAnnotations ?? FixedSet <ReachabilityAnnotation> .Empty) { Name = name; }
public ConstructorSymbol( ObjectTypeSymbol containingSymbol, Name?name, FixedList <DataType> parameterDataTypes, FixedSet <ReachabilityAnnotation>?reachabilityAnnotations = null) : base(containingSymbol, name, parameterDataTypes, containingSymbol.DeclaresDataType.ToConstructorReturn(), reachabilityAnnotations ?? FixedSet <ReachabilityAnnotation> .Empty) { ContainingSymbol = containingSymbol; ReturnDataType = containingSymbol.DeclaresDataType.ToConstructorReturn(); }
public PackageSyntax( Name name, FixedSet <ICompilationUnitSyntax> compilationUnits, FixedDictionary <Name, PackageIL> references) { Symbol = new PackageSymbol(name); SymbolTree = new SymbolTreeBuilder(Symbol); CompilationUnits = compilationUnits; AllEntityDeclarations = GetEntityDeclarations(CompilationUnits).ToFixedSet(); References = references; SymbolTrees = new SymbolForest(Primitive.SymbolTree, SymbolTree, ReferencedPackages.Select(p => p.SymbolTree)); Diagnostics = new Diagnostics(CompilationUnits.SelectMany(cu => cu.Diagnostics)); }
public MethodSymbol( TypeSymbol containingSymbol, Name name, DataType selfDataType, FixedList <DataType> parameterDataTypes, DataType returnDataType, FixedSet <ReachabilityAnnotation>?reachabilityAnnotations = null) : base(containingSymbol, name, parameterDataTypes, returnDataType, reachabilityAnnotations ?? FixedSet <ReachabilityAnnotation> .Empty) { ContainingSymbol = containingSymbol; Name = name; SelfDataType = selfDataType; }
public PackageIL( FixedSymbolTree symbolTree, FixedList <Diagnostic> diagnostics, FixedSet <PackageIL> references, IEnumerable <DeclarationIL> declarations, FunctionIL entryPoint) { Symbol = symbolTree.Package; SymbolTree = symbolTree; Diagnostics = diagnostics; References = references; EntryPoint = entryPoint; Declarations = declarations.ToFixedSet(); }
private void Build(FixedSet <IEntityDeclarationSyntax> entities) { // Process all classes first because they may be referenced by functions etc. foreach (var @class in entities.OfType <IClassDeclarationSyntax>()) { BuildClassSymbol(@class); } // Now resolve all other symbols (class declarations will already have symbols and won't be processed again) foreach (var entity in entities) { BuildEntitySymbol(entity); } }
protected InvocableSymbol( Symbol containingSymbol, Name?name, FixedList <DataType> parameterDataTypes, DataType returnDataType, FixedSet <ReachabilityAnnotation> reachabilityAnnotations) : base(containingSymbol, name) { ContainingSymbol = containingSymbol; Name = name; ParameterDataTypes = parameterDataTypes; ReturnDataType = returnDataType; ReachabilityAnnotations = reachabilityAnnotations; }
public static void Check <TState>( IBackwardDataFlowAnalyzer <TState> strategy, FixedSet <IExecutableDeclaration> declarations, ISymbolTree symbolTree, Diagnostics diagnostics) where TState : class { var dataFlowAnalyzer = new BackwardDataFlowAnalyzer <TState>(strategy, symbolTree, diagnostics); foreach (var invocableDeclaration in declarations) { dataFlowAnalyzer.Check(invocableDeclaration); } }
public PrimitiveSymbolTree(FixedDictionary <Symbol, FixedSet <Symbol> > symbolChildren) { this.symbolChildren = symbolChildren; GlobalSymbols = symbolChildren.Keys.Where(s => s.ContainingSymbol is null).ToFixedSet(); }
public ReachabilityAnnotation(FixedSet <Reference> references, ReachabilityChain canReach) : base(references) { CanReach = canReach; }
public ReachableReferences(FixedSet <Reference> references) : base(references) { }