Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: pkg/compiler/lib/src/js_model/closure_visitors.dart

Issue 2985683002: Remove KernelScopeInfo.localsMap (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/js_model/closure.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 import '../kernel/element_map.dart'; 9 import '../kernel/element_map.dart';
10 import 'closure.dart'; 10 import 'closure.dart';
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 if (!capturedVariablesForScope.isEmpty) { 91 if (!capturedVariablesForScope.isEmpty) {
92 assert(_scopeInfoMap[_currentMember] != null); 92 assert(_scopeInfoMap[_currentMember] != null);
93 assert(_currentLocalFunction != null); 93 assert(_currentLocalFunction != null);
94 KernelScopeInfo from = _scopeInfoMap[_currentMember]; 94 KernelScopeInfo from = _scopeInfoMap[_currentMember];
95 _scopesCapturedInClosureMap[node] = new KernelCapturedScope( 95 _scopesCapturedInClosureMap[node] = new KernelCapturedScope(
96 capturedVariablesForScope, 96 capturedVariablesForScope,
97 _currentLocalFunction, 97 _currentLocalFunction,
98 from.localsUsedInTryOrSync, 98 from.localsUsedInTryOrSync,
99 from.freeVariables, 99 from.freeVariables,
100 from.localsMap,
101 _thisLocal); 100 _thisLocal);
102 } 101 }
103 } 102 }
104 103
105 /// Perform book-keeping with the current set of local variables that have 104 /// Perform book-keeping with the current set of local variables that have
106 /// been seen thus far before entering this new scope. 105 /// been seen thus far before entering this new scope.
107 void enterNewScope(ir.Node node, void visitNewScope()) { 106 void enterNewScope(ir.Node node, void visitNewScope()) {
108 List<ir.VariableDeclaration> oldScopeVariables = _scopeVariables; 107 List<ir.VariableDeclaration> oldScopeVariables = _scopeVariables;
109 _scopeVariables = <ir.VariableDeclaration>[]; 108 _scopeVariables = <ir.VariableDeclaration>[];
110 visitNewScope(); 109 visitNewScope();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 199 }
201 }); 200 });
202 KernelCapturedScope scope = _scopesCapturedInClosureMap[node]; 201 KernelCapturedScope scope = _scopesCapturedInClosureMap[node];
203 if (scope == null) return; 202 if (scope == null) return;
204 _scopesCapturedInClosureMap[node] = new KernelCapturedLoopScope( 203 _scopesCapturedInClosureMap[node] = new KernelCapturedLoopScope(
205 scope.boxedVariables, 204 scope.boxedVariables,
206 boxedLoopVariables, 205 boxedLoopVariables,
207 scope.context, 206 scope.context,
208 scope.localsUsedInTryOrSync, 207 scope.localsUsedInTryOrSync,
209 scope.freeVariables, 208 scope.freeVariables,
210 _localsMap,
211 scope.thisLocal); 209 scope.thisLocal);
212 } 210 }
213 211
214 void visitInvokable(ir.TreeNode node) { 212 void visitInvokable(ir.TreeNode node) {
215 bool oldIsInsideClosure = _isInsideClosure; 213 bool oldIsInsideClosure = _isInsideClosure;
216 ir.Node oldExecutableContext = _executableContext; 214 ir.Node oldExecutableContext = _executableContext;
217 KernelScopeInfo oldScopeInfo = _currentScopeInfo; 215 KernelScopeInfo oldScopeInfo = _currentScopeInfo;
218 Local oldLocalFunction = _currentLocalFunction; 216 Local oldLocalFunction = _currentLocalFunction;
219 217
220 // _outermostNode is only null the first time we enter the body of the 218 // _outermostNode is only null the first time we enter the body of the
221 // field, constructor, or method that is being analyzed. 219 // field, constructor, or method that is being analyzed.
222 _isInsideClosure = _outermostNode != null; 220 _isInsideClosure = _outermostNode != null;
223 _executableContext = node; 221 _executableContext = node;
224 222
225 _currentScopeInfo = new KernelScopeInfo(_thisLocal, _localsMap); 223 _currentScopeInfo = new KernelScopeInfo(_thisLocal);
226 if (_isInsideClosure) { 224 if (_isInsideClosure) {
227 _closuresToGenerate[node] = _currentScopeInfo; 225 _closuresToGenerate[node] = _currentScopeInfo;
228 _currentLocalFunction = _localsMap.getLocalFunction(node.parent); 226 _currentLocalFunction = _localsMap.getLocalFunction(node.parent);
229 } else { 227 } else {
230 _outermostNode = node; 228 _outermostNode = node;
231 _scopeInfoMap[_currentMember] = _currentScopeInfo; 229 _scopeInfoMap[_currentMember] = _currentScopeInfo;
232 } 230 }
233 231
234 enterNewScope(node, () { 232 enterNewScope(node, () {
235 node.visitChildren(this); 233 node.visitChildren(this);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 269 }
272 270
273 void translateConstructorOrProcedure(ir.Node constructorOrProcedure) { 271 void translateConstructorOrProcedure(ir.Node constructorOrProcedure) {
274 constructorOrProcedure.accept(this); 272 constructorOrProcedure.accept(this);
275 } 273 }
276 274
277 void visitFunctionNode(ir.FunctionNode functionNode) { 275 void visitFunctionNode(ir.FunctionNode functionNode) {
278 visitInvokable(functionNode); 276 visitInvokable(functionNode);
279 } 277 }
280 } 278 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_model/closure.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698