Esempio n. 1
0
        public Binder(SyntaxTree syntaxTree, ISymbolContext symbolContext)
        {
            // TODO use lazy or some other pattern for init
            this.syntaxTree  = syntaxTree;
            this.TargetScope = SyntaxHelper.GetTargetScope(syntaxTree);
            var(allDeclarations, outermostScopes) = DeclarationVisitor.GetAllDeclarations(syntaxTree, symbolContext);
            var uniqueDeclarations = GetUniqueDeclarations(allDeclarations);
            var builtInNamespacs   = GetBuiltInNamespaces(this.TargetScope);

            this.bindings       = GetBindings(syntaxTree, uniqueDeclarations, builtInNamespacs, outermostScopes);
            this.cyclesBySymbol = GetCyclesBySymbol(syntaxTree, uniqueDeclarations, this.bindings);

            // TODO: Avoid looping 5 times?
            this.FileSymbol = new FileSymbol(
                syntaxTree.FileUri.LocalPath,
                syntaxTree.ProgramSyntax,
                builtInNamespacs,
                outermostScopes,
                allDeclarations.OfType <ParameterSymbol>(),
                allDeclarations.OfType <VariableSymbol>(),
                allDeclarations.OfType <ResourceSymbol>(),
                allDeclarations.OfType <ModuleSymbol>(),
                allDeclarations.OfType <OutputSymbol>());
        }