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; } }
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; } }