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 17 matching lines...) Expand all Loading... |
28 void insertExtendContext(VectorSet extender); | 28 void insertExtendContext(VectorSet extender); |
29 | 29 |
30 void _createDeclaration() { | 30 void _createDeclaration() { |
31 assert(contextDeclaration == null && vectorCreation == null); | 31 assert(contextDeclaration == null && vectorCreation == null); |
32 | 32 |
33 // Context size is set to 2 initially, because the 0-th element of it holds | 33 // Context size is set to 2 initially, because the 0-th element of it holds |
34 // the vector of type arguments that the VM creates, and the 1-st element | 34 // the vector of type arguments that the VM creates, and the 1-st element |
35 // works as a link to the parent context. | 35 // works as a link to the parent context. |
36 vectorCreation = new VectorCreation(2); | 36 vectorCreation = new VectorCreation(2); |
37 contextDeclaration = new VariableDeclaration.forValue(vectorCreation, | 37 contextDeclaration = new VariableDeclaration.forValue(vectorCreation, |
38 type: new VectorType()); | 38 type: const DynamicType()); |
39 contextDeclaration.name = "#context"; | 39 contextDeclaration.name = "#context"; |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 /// Adds a local variable for the context and adds update [Statement]s to the | 43 /// Adds a local variable for the context and adds update [Statement]s to the |
44 /// current block. | 44 /// current block. |
45 class BlockRewriter extends AstRewriter { | 45 class BlockRewriter extends AstRewriter { |
46 Block _currentBlock; | 46 Block _currentBlock; |
47 int _insertionIndex; | 47 int _insertionIndex; |
48 | 48 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 @override | 108 @override |
109 void insertExtendContext(VectorSet extender) { | 109 void insertExtendContext(VectorSet extender) { |
110 var init = new LocalInitializer( | 110 var init = new LocalInitializer( |
111 new VariableDeclaration(null, initializer: extender)); | 111 new VariableDeclaration(null, initializer: extender)); |
112 init.parent = parentConstructor; | 112 init.parent = parentConstructor; |
113 prefix.add(init); | 113 prefix.add(init); |
114 } | 114 } |
115 } | 115 } |
OLD | NEW |