| 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, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 final IntLiteral size; | 111 final IntLiteral size; |
| 112 final List<VariableDeclaration> variables = <VariableDeclaration>[]; | 112 final List<VariableDeclaration> variables = <VariableDeclaration>[]; |
| 113 final Map<VariableDeclaration, Arguments> initializers = | 113 final Map<VariableDeclaration, Arguments> initializers = |
| 114 <VariableDeclaration, Arguments>{}; | 114 <VariableDeclaration, Arguments>{}; |
| 115 | 115 |
| 116 LocalContext._internal(this.converter, this.parent, this.self, this.size); | 116 LocalContext._internal(this.converter, this.parent, this.self, this.size); |
| 117 | 117 |
| 118 factory LocalContext(ClosureConverter converter, Context parent) { | 118 factory LocalContext(ClosureConverter converter, Context parent) { |
| 119 Class contextClass = converter.contextClass; | 119 Class contextClass = converter.contextClass; |
| 120 assert(contextClass.constructors.length == 1); | 120 assert(contextClass.constructors.length == 1); |
| 121 converter.rewriter.insertContextDeclaration( | 121 converter.rewriter |
| 122 contextClass, parent.expression); | 122 .insertContextDeclaration(contextClass, parent.expression); |
| 123 | 123 |
| 124 return new LocalContext._internal(converter, parent, | 124 return new LocalContext._internal(converter, parent, |
| 125 converter.rewriter.contextDeclaration, | 125 converter.rewriter.contextDeclaration, converter.rewriter.contextSize); |
| 126 converter.rewriter.contextSize); | |
| 127 } | 126 } |
| 128 | 127 |
| 129 Expression get expression => accessor.buildSimpleRead(); | 128 Expression get expression => accessor.buildSimpleRead(); |
| 130 | 129 |
| 131 Accessor get accessor => new VariableAccessor(self); | 130 Accessor get accessor => new VariableAccessor(self); |
| 132 | 131 |
| 133 void extend(VariableDeclaration variable, Expression value) { | 132 void extend(VariableDeclaration variable, Expression value) { |
| 134 Arguments arguments = | 133 Arguments arguments = |
| 135 new Arguments(<Expression>[new IntLiteral(variables.length), value]); | 134 new Arguments(<Expression>[new IntLiteral(variables.length), value]); |
| 136 converter.rewriter.insertExtendContext(expression, arguments); | 135 converter.rewriter.insertExtendContext(expression, arguments); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 228 } |
| 230 context = new PropertyGet(context, new Name('parent')); | 229 context = new PropertyGet(context, new Name('parent')); |
| 231 } | 230 } |
| 232 throw 'Unbound NestedContext.lookup($variable)'; | 231 throw 'Unbound NestedContext.lookup($variable)'; |
| 233 } | 232 } |
| 234 | 233 |
| 235 Context toNestedContext([Accessor accessor]) { | 234 Context toNestedContext([Accessor accessor]) { |
| 236 return new NestedContext(converter, accessor ?? this.accessor, variabless); | 235 return new NestedContext(converter, accessor ?? this.accessor, variabless); |
| 237 } | 236 } |
| 238 } | 237 } |
| OLD | NEW |