| 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 library kernel.transformations.closure.rewriter; | 5 library kernel.transformations.closure.rewriter; |
| 6 | 6 |
| 7 import '../../ast.dart'; | 7 import '../../ast.dart'; |
| 8 import 'converter.dart' show ClosureConverter; | 8 import 'converter.dart' show ClosureConverter; |
| 9 | 9 |
| 10 /// Used by the [Context] to initialize and update the context variable | 10 /// Used by the [Context] to initialize and update the context variable |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 class BlockRewriter extends AstRewriter { | 44 class BlockRewriter extends AstRewriter { |
| 45 Block _currentBlock; | 45 Block _currentBlock; |
| 46 int _insertionIndex; | 46 int _insertionIndex; |
| 47 | 47 |
| 48 BlockRewriter(this._currentBlock) : _insertionIndex = 0; | 48 BlockRewriter(this._currentBlock) : _insertionIndex = 0; |
| 49 | 49 |
| 50 BlockRewriter forNestedBlock(Block block) { | 50 BlockRewriter forNestedBlock(Block block) { |
| 51 return _currentBlock != block ? new BlockRewriter(block) : this; | 51 return _currentBlock != block ? new BlockRewriter(block) : this; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void transformStatements(Block block, ClosureConverter converter) { | 54 void transformStatements(ClosureConverter converter) { |
| 55 while (_insertionIndex < _currentBlock.statements.length) { | 55 while (_insertionIndex < _currentBlock.statements.length) { |
| 56 var original = _currentBlock.statements[_insertionIndex]; | 56 var original = _currentBlock.statements[_insertionIndex]; |
| 57 var transformed = original.accept(converter); | 57 var transformed = original.accept(converter); |
| 58 assert(_currentBlock.statements[_insertionIndex] == original); | 58 assert(_currentBlock.statements[_insertionIndex] == original); |
| 59 if (transformed == null) { | 59 if (transformed == null) { |
| 60 _currentBlock.statements.removeAt(_insertionIndex); | 60 _currentBlock.statements.removeAt(_insertionIndex); |
| 61 } else { | 61 } else { |
| 62 _currentBlock.statements[_insertionIndex++] = transformed; | 62 _currentBlock.statements[_insertionIndex++] = transformed; |
| 63 transformed.parent = _currentBlock; | 63 transformed.parent = _currentBlock; |
| 64 } | 64 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 105 } |
| 106 | 106 |
| 107 @override | 107 @override |
| 108 void insertExtendContext(VectorSet extender) { | 108 void insertExtendContext(VectorSet extender) { |
| 109 var init = new LocalInitializer( | 109 var init = new LocalInitializer( |
| 110 new VariableDeclaration(null, initializer: extender)); | 110 new VariableDeclaration(null, initializer: extender)); |
| 111 init.parent = parentConstructor; | 111 init.parent = parentConstructor; |
| 112 prefix.add(init); | 112 prefix.add(init); |
| 113 } | 113 } |
| 114 } | 114 } |
| OLD | NEW |