public Task <Package> CompilePackageAsync( string name, IEnumerable <ICodeFileSource> fileSources, FixedDictionary <string, Task <Package> > references, TaskScheduler taskScheduler) { var lexer = new Lexer(); var parser = new CompilationUnitParser(); var parseBlock = new TransformBlock <ICodeFileSource, CompilationUnitSyntax>( async(fileSource) => { var file = await fileSource.LoadAsync(); var context = new ParseContext(file, new Diagnostics()); var tokens = lexer.Lex(context).WhereNotTrivia(); return(parser.Parse(tokens)); }, new ExecutionDataflowBlockOptions() { TaskScheduler = taskScheduler, EnsureOrdered = false, }); foreach (var fileSource in fileSources) { parseBlock.Post(fileSource); } parseBlock.Complete(); throw new NotImplementedException(); }
public Task <PackageIL> CompilePackageAsync( Name name, IEnumerable <ICodeFileSource> files, FixedDictionary <Name, Task <PackageIL> > referenceTasks) { return(CompilePackageAsync(name, files, referenceTasks, TaskScheduler.Default)); }
public VariableFlags( FixedDictionary <BindingSymbol, int> symbolMap, BitArray flags) { this.symbolMap = symbolMap; this.flags = flags; }
public Task <Package> CompilePackageAsync( string name, IEnumerable <ICodeFileSource> files, FixedDictionary <string, Task <Package> > references) { return(CompilePackageAsync(name, files, references, TaskScheduler.Default)); }
public PackageIL CompilePackage( string name, IEnumerable <CodeFile> files, FixedDictionary <Name, PackageIL> references) { var lexer = new Lexer(); var parser = new CompilationUnitParser(); var compilationUnits = files .Select(file => { var context = new ParseContext(file, new Diagnostics()); var tokens = lexer.Lex(context).WhereNotTrivia(); return(parser.Parse(tokens)); }) .ToFixedSet(); var packageSyntax = new PackageSyntax(name, compilationUnits, references); var analyzer = new SemanticAnalyzer() { SaveLivenessAnalysis = SaveLivenessAnalysis, SaveReachabilityGraphs = SaveReachabilityGraphs, }; return(analyzer.Check(packageSyntax)); }
public LexicalScopesBuilderWalker( NestedScope globalScope, FixedDictionary <NamespaceName, Namespace> namespaces) { this.globalScope = globalScope; this.namespaces = namespaces; }
public VariableFlags(IExecutableDeclaration declaration, ISymbolTree symbolTree, bool defaultValue) { var invocableSymbol = declaration.Symbol; symbolMap = symbolTree.Children(invocableSymbol).Cast <BindingSymbol>().Enumerate().ToFixedDictionary(); flags = new BitArray(symbolMap.Count, defaultValue); }
public PackageIL CompilePackage( string name, IEnumerable <ICodeFileSource> fileSources, FixedDictionary <Name, PackageIL> references) { return(CompilePackage(name, fileSources.Select(s => s.Load()), references)); }
private static FixedList <ISymbol> GetAllSymbols( PackageSyntax packageSyntax, FixedDictionary <string, Package> references) { return(references.Values .SelectMany(p => p.Declarations.Where(d => !d.IsMember)) .Concat(packageSyntax.CompilationUnits.SelectMany(GetAllNonMemberDeclarations)) .ToFixedList()); }
public SymbolForest(PrimitiveSymbolTree primitiveSymbolTree, SymbolTreeBuilder symbolTreeBuilder, IEnumerable <FixedSymbolTree> packageTrees) { if (symbolTreeBuilder.Package is null) { throw new ArgumentException("Can't be builder for primitive symbols", nameof(symbolTreeBuilder)); } PrimitiveSymbolTree = primitiveSymbolTree; this.packageTrees = packageTrees.Append <ISymbolTree>(symbolTreeBuilder).ToFixedDictionary(t => t.Package !); }
public LexicalScopesBuilder( Diagnostics diagnostics, PackageSyntax packageSyntax, FixedDictionary <string, Package> references) { this.diagnostics = diagnostics; allSymbols = GetAllSymbols(packageSyntax, references); globalScope = new GlobalScope(GetAllGlobalSymbols(), allSymbols); }
public FixedSymbolTree(PackageSymbol package, FixedDictionary <Symbol, FixedSet <Symbol> > symbolChildren) { if (symbolChildren.Keys.Any(s => s.Package != package)) { throw new ArgumentException("Children must be for this package", nameof(symbolChildren)); } Package = package; this.symbolChildren = symbolChildren; }
public void Fixed() { foreach (var(t, p) in TestData.TypeNames.Take(1)) { var items = p.Select(x => new KeyValuePair <string, string>(x, x)); var d = new FixedDictionary <string, string, StringComparer>(items); Bench(items, allKeys.Except(p), d); } }
public static SortedList <string, uint> GetEffectHandleList(EffectResource resource) { EffectResource.VisualEffectNameList handleList = resource.VisualEffectNames; int count = handleList.Count; FixedDictionary <string, uint> fd = new FixedDictionary <string, uint>(count); for (int i = 0; i < count; i++) { fd.SetValue(i, handleList[i].EffectName, handleList[i].Index); } return(new SortedList <string, uint>(fd)); }
public async Task <PackageIL> CompilePackageAsync( Name name, IEnumerable <ICodeFileSource> fileSources, FixedDictionary <Name, Task <PackageIL> > referenceTasks, TaskScheduler taskScheduler) { var lexer = new Lexer(); var parser = new CompilationUnitParser(); var parseBlock = new TransformBlock <ICodeFileSource, ICompilationUnitSyntax>( async(fileSource) => { var file = await fileSource.LoadAsync().ConfigureAwait(false); var context = new ParseContext(file, new Diagnostics()); var tokens = lexer.Lex(context).WhereNotTrivia(); return(parser.Parse(tokens)); }, new ExecutionDataflowBlockOptions() { TaskScheduler = taskScheduler, EnsureOrdered = false, }); foreach (var fileSource in fileSources) { parseBlock.Post(fileSource); } parseBlock.Complete(); await parseBlock.Completion.ConfigureAwait(false); if (!parseBlock.TryReceiveAll(out var compilationUnits)) { throw new Exception("Not all compilation units are ready"); } var referencePairs = await Task .WhenAll(referenceTasks.Select(async kv => (alias: kv.Key, package: await kv.Value.ConfigureAwait(false)))) .ConfigureAwait(false); var references = referencePairs.ToFixedDictionary(r => r.alias, r => r.package); // TODO add the references to the package syntax var packageSyntax = new PackageSyntax(name, compilationUnits.ToFixedSet(), references); var analyzer = new SemanticAnalyzer() { SaveLivenessAnalysis = SaveLivenessAnalysis, SaveReachabilityGraphs = SaveReachabilityGraphs, }; return(analyzer.Check(packageSyntax)); }
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 Package( FixedList <INonMemberDeclaration> nonMemberDeclarations, FixedSymbolTree symbolTree, Diagnostics diagnostics, FixedDictionary <Name, PackageIL> references) { AllDeclarations = GetAllDeclarations(nonMemberDeclarations).ToFixedList(); NonMemberDeclarations = nonMemberDeclarations; SymbolTree = symbolTree; Diagnostics = diagnostics; References = references; SymbolTrees = new SymbolForest(Primitive.SymbolTree, ReferencedPackages.Select(p => p.SymbolTree).Append(SymbolTree)); }
public Namespace( NamespaceName name, FixedDictionary <TypeName, FixedSet <IPromise <Symbol> > > symbols, FixedDictionary <TypeName, FixedSet <IPromise <Symbol> > > nestedSymbols, FixedDictionary <TypeName, FixedSet <IPromise <Symbol> > > symbolsInPackage, FixedDictionary <TypeName, FixedSet <IPromise <Symbol> > > nestedSymbolsInPackage) { Name = name; Symbols = symbols; NestedSymbols = nestedSymbols; SymbolsInPackage = symbolsInPackage; NestedSymbolsInPackage = nestedSymbolsInPackage; }
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); } } }
public Package Analyze( PackageSyntax packageSyntax, FixedDictionary <string, Package> references) { // First pull over all the lexer and parser errors from the compilation units var diagnostics = AllDiagnostics(packageSyntax); var scopesBuilder = new LexicalScopesBuilder(diagnostics, packageSyntax, references); scopesBuilder.BuildScopesInPackage(packageSyntax); // Make a list of all the member declarations (i.e. not namespaces) var memberDeclarations = packageSyntax.CompilationUnits .SelectMany(cu => cu.AllMemberDeclarations).ToFixedList(); // TODO we can't do full type checking without some IL gen and code execution, how to handle that? // Do type checking TypeResolver.Check(memberDeclarations, diagnostics); #if DEBUG TypeResolutionValidator.Validate(memberDeclarations); // TODO validate that all ReferencedSymbols lists have a single value non-errored code #endif MoveChecker.Check(memberDeclarations, diagnostics); ShadowChecker.Check(memberDeclarations, diagnostics); // TODO we need to check definite assignment as part of this BindingMutabilityChecker.Check(memberDeclarations, diagnostics); // -------------------------------------------------- // This is where the representation transitions to IR ControlFlowAnalyzer.BuildGraphs(memberDeclarations); // -------------------------------------------------- var liveness = LivenessAnalyzer.Analyze(memberDeclarations); DeleteInserter.Transform(memberDeclarations, liveness); BorrowChecker.Check(memberDeclarations, diagnostics); // Build final declaration objects and find the entry point var declarationBuilder = new DeclarationBuilder(); var declarations = declarationBuilder.Build(memberDeclarations); var entryPoint = DetermineEntryPoint(declarations, diagnostics); return(new Package(packageSyntax.Name, diagnostics.Build(), references, declarations, entryPoint)); }
public Package CompilePackage( string name, IEnumerable <CodeFile> files, FixedDictionary <string, Package> references) { var lexer = new Lexer(); var parser = new CompilationUnitParser(); var compilationUnits = files .Select(file => { var context = new ParseContext(file, new Diagnostics()); var tokens = lexer.Lex(context).WhereNotTrivia(); return(parser.Parse(tokens)); }) .ToFixedList(); var packageSyntax = new PackageSyntax(name, compilationUnits); var analyzer = new SemanticAnalyzer(); return(analyzer.Analyze(packageSyntax, references)); }
public PackagesScope(PackageSymbol currentPackage, FixedDictionary <Name, PackageSymbol> packageAliases) { CurrentPackage = currentPackage; this.packageAliases = packageAliases; }
public SymbolForest(PrimitiveSymbolTree primitiveSymbolTree, IEnumerable <FixedSymbolTree> packageTrees) { PrimitiveSymbolTree = primitiveSymbolTree; this.packageTrees = packageTrees.ToFixedDictionary(t => t.Package !, t => (ISymbolTree)t); }
public PrimitiveSymbolTree(FixedDictionary <Symbol, FixedSet <Symbol> > symbolChildren) { this.symbolChildren = symbolChildren; GlobalSymbols = symbolChildren.Keys.Where(s => s.ContainingSymbol is null).ToFixedSet(); }
static TokenTypes() { KeywordFactories = BuildKeywordFactories(); }
private void button15_Click(object sender, EventArgs e) { FixedDictionary dictionary = new FixedDictionary(folderTextBox.Text, 100); Console.WriteLine(dictionary); }