OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.context; | 5 library kernel.transformations.closure.context; |
6 | 6 |
7 import '../../ast.dart' | 7 import '../../ast.dart' |
8 show | 8 show |
9 Expression, | 9 Expression, |
| 10 FunctionNode, |
10 NullLiteral, | 11 NullLiteral, |
11 StringLiteral, | 12 StringLiteral, |
12 Throw, | 13 Throw, |
13 TreeNode, | 14 TreeNode, |
14 VariableDeclaration, | 15 VariableDeclaration, |
15 VariableGet, | 16 VariableGet, |
16 VariableSet, | 17 VariableSet, |
17 VectorCreation, | 18 VectorCreation, |
18 VectorGet, | 19 VectorGet, |
19 VectorSet, | 20 VectorSet, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 131 |
131 void extend(VariableDeclaration variable, Expression value) { | 132 void extend(VariableDeclaration variable, Expression value) { |
132 // Increase index by 2, because the type arguments vector occupies position | 133 // Increase index by 2, because the type arguments vector occupies position |
133 // 0, the parent occupies position 1, and all other variables are therefore | 134 // 0, the parent occupies position 1, and all other variables are therefore |
134 // shifted by 2. | 135 // shifted by 2. |
135 VectorSet initializer = | 136 VectorSet initializer = |
136 new VectorSet(expression, variables.length + 2, value); | 137 new VectorSet(expression, variables.length + 2, value); |
137 value.parent = initializer; | 138 value.parent = initializer; |
138 | 139 |
139 converter.rewriter.insertExtendContext(initializer); | 140 converter.rewriter.insertExtendContext(initializer); |
| 141 if (variable.parent is FunctionNode) { |
| 142 converter.rewriter.insertZeroOutParameter(variable); |
| 143 } |
140 | 144 |
141 ++vectorCreation.length; | 145 ++vectorCreation.length; |
142 variables.add(variable); | 146 variables.add(variable); |
143 initializers[variable] = initializer; | 147 initializers[variable] = initializer; |
144 } | 148 } |
145 | 149 |
146 void update(VariableDeclaration variable, Expression value) { | 150 void update(VariableDeclaration variable, Expression value) { |
147 VectorSet initializer = initializers[variable]; | 151 VectorSet initializer = initializers[variable]; |
148 initializer.value = value; | 152 initializer.value = value; |
149 value.parent = initializer; | 153 value.parent = initializer; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // Item 1 of a context always points to its parent. | 242 // Item 1 of a context always points to its parent. |
239 context = new VectorGet(context, 1); | 243 context = new VectorGet(context, 1); |
240 } | 244 } |
241 throw 'Unbound NestedContext.lookup($variable)'; | 245 throw 'Unbound NestedContext.lookup($variable)'; |
242 } | 246 } |
243 | 247 |
244 Context toNestedContext([Accessor accessor]) { | 248 Context toNestedContext([Accessor accessor]) { |
245 return new NestedContext(converter, accessor ?? this.accessor, variabless); | 249 return new NestedContext(converter, accessor ?? this.accessor, variabless); |
246 } | 250 } |
247 } | 251 } |
OLD | NEW |