Inheritance: Expression
コード例 #1
0
ファイル: PythonAst.cs プロジェクト: sabeelcoder/ironpython3
            private MSAst.Expression VisitComprehension(Comprehension comprehension)
            {
                var newScope = (ComprehensionScope)comprehension.Scope.CopyForRewrite();

                newScope.Parent = _curScope;
                var newComprehension = comprehension.CopyForRewrite(newScope);

                ScopeStatement prevScope = _curScope;

                try {
                    // rewrite the comprehension in a new scope
                    _curScope = newScope;

                    return(base.VisitExtension(newComprehension));
                } finally {
                    _curScope = prevScope;
                }
            }
コード例 #2
0
        // Comprehensions

        private void WalkComprehensionIterators(Comprehension node)
        {
            node.Parent = _currentScope;

            // Special walk case: first (outermost) "for" iterator
            // See also: PythonAst.LookupVisitor.VisitComprehension(...)
            var outermostFor = (ComprehensionFor)node.Iterators[0];

            outermostFor.List.Walk(this);
            PushScope(node.Scope);
            Walk(outermostFor);
            outermostFor.Left.Walk(this);
            PostWalk(outermostFor);

            // Regular walk cases: remaining iterators/conditionals
            for (int i = 1; i < node.Iterators.Count; i++)
            {
                node.Iterators[i].Walk(this);
            }
        }
コード例 #3
0
ファイル: PythonAst.cs プロジェクト: xlizzard/ironpython3
            private MSAst.Expression VisitComprehension(Comprehension comprehension)
            {
                var newScope = (ComprehensionScope)comprehension.Scope.CopyForRewrite();

                newScope.Parent = _curScope;
                var newComprehension = comprehension.CopyForRewrite(newScope);

                ScopeStatement prevScope = _curScope;

                try {
                    // mark the first (outermost) "for" iterator for rewrite in the current scope
                    _outerComprehensionScopes[((ComprehensionFor)comprehension.Iterators[0]).List] = _curScope;

                    // rewrite the rest of comprehension in the new scope
                    _curScope = newScope;

                    return(base.VisitExtension(newComprehension));
                } finally {
                    _curScope = prevScope;
                }
            }
コード例 #4
0
 public ComprehensionScope(Comprehension comprehension)
 {
     _comprehension = comprehension;
 }