Ejemplo n.º 1
0
            public static Analysis Analyze(
                BoundNode node,
                MethodSymbol method,
                int topLevelMethodOrdinal,
                MethodSymbol substitutedSourceMethod,
                VariableSlotAllocator slotAllocatorOpt,
                TypeCompilationState compilationState,
                ArrayBuilder <ClosureDebugInfo> closureDebugInfo,
                DiagnosticBag diagnostics)
            {
                var methodsConvertedToDelegates = PooledHashSet <MethodSymbol> .GetInstance();

                var scopeTree = ScopeTreeBuilder.Build(
                    node,
                    method,
                    methodsConvertedToDelegates,
                    diagnostics);

                Debug.Assert(scopeTree != null);

                var analysis = new Analysis(
                    scopeTree,
                    methodsConvertedToDelegates,
                    method,
                    topLevelMethodOrdinal,
                    substitutedSourceMethod,
                    slotAllocatorOpt,
                    compilationState);

                analysis.MakeAndAssignEnvironments();
                analysis.ComputeLambdaScopesAndFrameCaptures(method.ThisParameter);
                analysis.InlineThisOnlyEnvironments();
                return(analysis);
            }
Ejemplo n.º 2
0
            private void Analyze(BoundNode node)
            {
                ScopeTree     = ScopeTreeBuilder.Build(node, this);
                _currentScope = FindNodeToAnalyze(node);

                Debug.Assert(!_inExpressionLambda);
                Debug.Assert((object)_topLevelMethod != null);
                Debug.Assert((object)_currentParent != null);

                foreach (ParameterSymbol parameter in _topLevelMethod.Parameters)
                {
                    // parameters are counted as if they are inside the block
                    VariableScope[parameter] = _currentScope;
                }

                Visit(node);

                // scopeOwner may already contain the same key/value if _currentScope is a BoundBlock.
                MethodSymbol shouldBeCurrentParent;

                if (ScopeOwner.TryGetValue(_currentScope, out shouldBeCurrentParent))
                {
                    // Check to make sure the above comment is right.
                    Debug.Assert(_currentParent == shouldBeCurrentParent);
                }
                else
                {
                    ScopeOwner.Add(_currentScope, _currentParent);
                }
            }
Ejemplo n.º 3
0
                public static Scope Build(BoundNode node, Analysis analysis)
                {
                    // This should be the top-level node
                    Debug.Assert(node == FindNodeToAnalyze(node));

                    var rootScope = new Scope(parent: null, boundNode: node, containingClosure: null);
                    var builder   = new ScopeTreeBuilder(rootScope, analysis);

                    builder.Build();
                    return(rootScope);
                }
Ejemplo n.º 4
0
            public static Analysis Analyze(BoundNode node, MethodSymbol method, DiagnosticBag diagnostics)
            {
                var methodsConvertedToDelegates = PooledHashSet <MethodSymbol> .GetInstance();

                var scopeTree = ScopeTreeBuilder.Build(
                    node,
                    method,
                    methodsConvertedToDelegates,
                    diagnostics);

                return(new Analysis(scopeTree, methodsConvertedToDelegates));
            }
Ejemplo n.º 5
0
            public static Analysis Analyze(
                BoundNode node,
                MethodSymbol method,
                int topLevelMethodOrdinal,
                MethodSymbol substitutedSourceMethod,
                VariableSlotAllocator slotAllocatorOpt,
                TypeCompilationState compilationState,
                ArrayBuilder <ClosureDebugInfo> closureDebugInfo,
                DiagnosticBag diagnostics
                )
            {
                var methodsConvertedToDelegates = PooledHashSet <MethodSymbol> .GetInstance();

                var scopeTree = ScopeTreeBuilder.Build(
                    node,
                    method,
                    methodsConvertedToDelegates,
                    diagnostics
                    );

                Debug.Assert(scopeTree != null);

                var analysis = new Analysis(
                    scopeTree,
                    methodsConvertedToDelegates,
                    method,
                    topLevelMethodOrdinal,
                    slotAllocatorOpt,
                    compilationState
                    );

                analysis.MakeAndAssignEnvironments();
                analysis.ComputeLambdaScopesAndFrameCaptures();
                if (
                    compilationState.Compilation.Options.OptimizationLevel
                    == OptimizationLevel.Release
                    )
                {
                    // This can affect when a variable is in scope whilst debugging, so only do this in release mode.
                    analysis.MergeEnvironments();
                }
                analysis.InlineThisOnlyEnvironments();
                return(analysis);
            }
Ejemplo n.º 6
0
                public static Scope Build(
                    BoundNode node,
                    MethodSymbol topLevelMethod,
                    HashSet <MethodSymbol> methodsConvertedToDelegates,
                    DiagnosticBag diagnostics)
                {
                    // This should be the top-level node
                    Debug.Assert(node == FindNodeToAnalyze(node));
                    Debug.Assert(topLevelMethod != null);

                    var rootScope = new Scope(parent: null, boundNode: node, containingClosure: null);
                    var builder   = new ScopeTreeBuilder(
                        rootScope,
                        topLevelMethod,
                        methodsConvertedToDelegates,
                        diagnostics);

                    builder.Build();
                    return(rootScope);
                }