| 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 '../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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 _isInsideClosure = oldIsInsideClosure; | 259 _isInsideClosure = oldIsInsideClosure; |
| 260 _currentScopeInfo = oldScopeInfo; | 260 _currentScopeInfo = oldScopeInfo; |
| 261 _executableContext = oldExecutableContext; | 261 _executableContext = oldExecutableContext; |
| 262 | 262 |
| 263 // Mark all free variables as captured and expect to encounter them in the | 263 // Mark all free variables as captured and expect to encounter them in the |
| 264 // outer function. | 264 // outer function. |
| 265 Iterable<ir.VariableDeclaration> freeVariables = | 265 Iterable<ir.VariableDeclaration> freeVariables = |
| 266 savedScopeInfo.freeVariables; | 266 savedScopeInfo.freeVariables; |
| 267 assert(freeVariables.isEmpty || savedIsInsideClosure); | 267 assert(freeVariables.isEmpty || savedIsInsideClosure); |
| 268 for (ir.VariableDeclaration freeVariable in freeVariables) { | 268 for (ir.VariableDeclaration freeVariable in freeVariables) { |
| 269 assert(!_capturedVariables.contains(freeVariable)); | |
| 270 _capturedVariables.add(freeVariable); | 269 _capturedVariables.add(freeVariable); |
| 271 _markVariableAsUsed(freeVariable); | 270 _markVariableAsUsed(freeVariable); |
| 272 } | 271 } |
| 273 } | 272 } |
| 274 | 273 |
| 275 /// Return true if [variable]'s context is the same as the current executable | 274 /// Return true if [variable]'s context is the same as the current executable |
| 276 /// context. | 275 /// context. |
| 277 bool _inCurrentContext(ir.VariableDeclaration variable) { | 276 bool _inCurrentContext(ir.VariableDeclaration variable) { |
| 278 ir.TreeNode node = variable; | 277 ir.TreeNode node = variable; |
| 279 while (node != _outermostNode && node != _executableContext) { | 278 while (node != _outermostNode && node != _executableContext) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 nodeToConvert.isInstanceMember)) { | 314 nodeToConvert.isInstanceMember)) { |
| 316 return new ThisLocal(_kernelToElementMap.getConstructor(nodeToConvert)); | 315 return new ThisLocal(_kernelToElementMap.getConstructor(nodeToConvert)); |
| 317 } else if (nodeToConvert is ir.Procedure && | 316 } else if (nodeToConvert is ir.Procedure && |
| 318 nodeToConvert.isInstanceMember) { | 317 nodeToConvert.isInstanceMember) { |
| 319 return new ThisLocal(_kernelToElementMap.getMethod(nodeToConvert)); | 318 return new ThisLocal(_kernelToElementMap.getMethod(nodeToConvert)); |
| 320 } | 319 } |
| 321 } | 320 } |
| 322 return null; | 321 return null; |
| 323 } | 322 } |
| 324 } | 323 } |
| OLD | NEW |