OLD | NEW |
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 '../common.dart'; | 8 import '../common.dart'; |
9 import '../common/tasks.dart'; | 9 import '../common/tasks.dart'; |
10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 /// The set of variables that were defined in another scope, but are used in | 286 /// The set of variables that were defined in another scope, but are used in |
287 /// this scope. | 287 /// this scope. |
288 final Set<Local> freeVariables; | 288 final Set<Local> freeVariables; |
289 | 289 |
290 JsScopeInfo.from( | 290 JsScopeInfo.from( |
291 this.boxedVariables, KernelScopeInfo info, KernelToLocalsMap localsMap) | 291 this.boxedVariables, KernelScopeInfo info, KernelToLocalsMap localsMap) |
292 : this.thisLocal = | 292 : this.thisLocal = |
293 info.hasThisLocal ? new ThisLocal(localsMap.currentMember) : null, | 293 info.hasThisLocal ? new ThisLocal(localsMap.currentMember) : null, |
294 this.localsUsedInTryOrSync = | 294 this.localsUsedInTryOrSync = |
295 info.localsUsedInTryOrSync.map(localsMap.getLocalVariable).toSet(), | 295 info.localsUsedInTryOrSync.map(localsMap.getLocalVariable).toSet(), |
296 this.freeVariables = | 296 this.freeVariables = new Set<Local>() { |
297 info.freeVariables.map(localsMap.getLocalVariable).toSet(); | 297 for (var variable in info.freeVariables) { |
| 298 if (variable is ThisVariable) { |
| 299 freeVariables.add(thisLocal); |
| 300 } else { |
| 301 freeVariables.add(localsMap.getLocalVariable(variable)); |
| 302 } |
| 303 } |
| 304 } |
298 | 305 |
299 void forEachBoxedVariable(f(Local local, FieldEntity field)) { | 306 void forEachBoxedVariable(f(Local local, FieldEntity field)) { |
300 boxedVariables.forEach((Local l, JRecordField box) { | 307 boxedVariables.forEach((Local l, JRecordField box) { |
301 f(l, box); | 308 f(l, box); |
302 }); | 309 }); |
303 } | 310 } |
304 | 311 |
305 bool localIsUsedInTryOrSync(Local variable) => | 312 bool localIsUsedInTryOrSync(Local variable) => |
306 localsUsedInTryOrSync.contains(variable); | 313 localsUsedInTryOrSync.contains(variable); |
307 | 314 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 KernelScopeInfo scopeInfo; | 626 KernelScopeInfo scopeInfo; |
620 | 627 |
621 /// Collected [CapturedScope] data for nodes. | 628 /// Collected [CapturedScope] data for nodes. |
622 Map<ir.Node, KernelCapturedScope> capturedScopesMap = | 629 Map<ir.Node, KernelCapturedScope> capturedScopesMap = |
623 <ir.Node, KernelCapturedScope>{}; | 630 <ir.Node, KernelCapturedScope>{}; |
624 | 631 |
625 /// Collected [ScopeInfo] data for nodes. | 632 /// Collected [ScopeInfo] data for nodes. |
626 Map<ir.TreeNode, KernelScopeInfo> closuresToGenerate = | 633 Map<ir.TreeNode, KernelScopeInfo> closuresToGenerate = |
627 <ir.TreeNode, KernelScopeInfo>{}; | 634 <ir.TreeNode, KernelScopeInfo>{}; |
628 } | 635 } |
OLD | NEW |