| 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 Arguments, | 9 Arguments, |
| 10 Class, | 10 Class, |
| 11 Expression, | 11 Expression, |
| 12 IntLiteral, | 12 IntLiteral, |
| 13 MethodInvocation, | 13 MethodInvocation, |
| 14 Name, | 14 Name, |
| 15 NullLiteral, | 15 NullLiteral, |
| 16 PropertyGet, | 16 PropertyGet, |
| 17 StringLiteral, | 17 StringLiteral, |
| 18 Throw, | 18 Throw, |
| 19 TreeNode, |
| 19 VariableDeclaration, | 20 VariableDeclaration, |
| 20 VariableGet, | 21 VariableGet, |
| 21 VariableSet; | 22 VariableSet; |
| 22 | 23 |
| 23 import '../../frontend/accessors.dart' | 24 import '../../frontend/accessors.dart' |
| 24 show Accessor, IndexAccessor, VariableAccessor; | 25 show Accessor, IndexAccessor, VariableAccessor; |
| 25 | 26 |
| 26 import 'converter.dart' show ClosureConverter; | 27 import 'converter.dart' show ClosureConverter; |
| 27 | 28 |
| 28 abstract class Context { | 29 abstract class Context { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 assert(contextClass.constructors.length == 1); | 121 assert(contextClass.constructors.length == 1); |
| 121 converter.rewriter | 122 converter.rewriter |
| 122 .insertContextDeclaration(contextClass, parent.expression); | 123 .insertContextDeclaration(contextClass, parent.expression); |
| 123 | 124 |
| 124 return new LocalContext._internal(converter, parent, | 125 return new LocalContext._internal(converter, parent, |
| 125 converter.rewriter.contextDeclaration, converter.rewriter.contextSize); | 126 converter.rewriter.contextDeclaration, converter.rewriter.contextSize); |
| 126 } | 127 } |
| 127 | 128 |
| 128 Expression get expression => accessor.buildSimpleRead(); | 129 Expression get expression => accessor.buildSimpleRead(); |
| 129 | 130 |
| 130 Accessor get accessor => new VariableAccessor(self); | 131 Accessor get accessor => new VariableAccessor(self, null, TreeNode.noOffset); |
| 131 | 132 |
| 132 void extend(VariableDeclaration variable, Expression value) { | 133 void extend(VariableDeclaration variable, Expression value) { |
| 133 Arguments arguments = | 134 Arguments arguments = |
| 134 new Arguments(<Expression>[new IntLiteral(variables.length), value]); | 135 new Arguments(<Expression>[new IntLiteral(variables.length), value]); |
| 135 converter.rewriter.insertExtendContext(expression, arguments); | 136 converter.rewriter.insertExtendContext(expression, arguments); |
| 136 ++size.value; | 137 ++size.value; |
| 137 variables.add(variable); | 138 variables.add(variable); |
| 138 initializers[variable] = arguments; | 139 initializers[variable] = arguments; |
| 139 } | 140 } |
| 140 | 141 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 229 } |
| 229 context = new PropertyGet(context, new Name('parent')); | 230 context = new PropertyGet(context, new Name('parent')); |
| 230 } | 231 } |
| 231 throw 'Unbound NestedContext.lookup($variable)'; | 232 throw 'Unbound NestedContext.lookup($variable)'; |
| 232 } | 233 } |
| 233 | 234 |
| 234 Context toNestedContext([Accessor accessor]) { | 235 Context toNestedContext([Accessor accessor]) { |
| 235 return new NestedContext(converter, accessor ?? this.accessor, variabless); | 236 return new NestedContext(converter, accessor ?? this.accessor, variabless); |
| 236 } | 237 } |
| 237 } | 238 } |
| OLD | NEW |