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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
6 | 6 |
7 import '../closure.dart'; | 7 import '../closure.dart'; |
8 import '../common/tasks.dart'; | 8 import '../common/tasks.dart'; |
9 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
10 import '../kernel/element_map.dart'; | 10 import '../kernel/element_map.dart'; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 @override | 139 @override |
140 // TODO(efortuna): Eventually closureScopeMap[node] should always be non-null, | 140 // TODO(efortuna): Eventually closureScopeMap[node] should always be non-null, |
141 // and we should just test that with an assert. | 141 // and we should just test that with an assert. |
142 LoopClosureScope getLoopClosureScope(ir.Node loopNode) => | 142 LoopClosureScope getLoopClosureScope(ir.Node loopNode) => |
143 _closureScopeMap[loopNode] ?? const LoopClosureScope(); | 143 _closureScopeMap[loopNode] ?? const LoopClosureScope(); |
144 | 144 |
145 @override | 145 @override |
146 // TODO(efortuna): Eventually closureRepresentationMap[node] should always be | 146 // TODO(efortuna): Eventually closureRepresentationMap[node] should always be |
147 // non-null, and we should just test that with an assert. | 147 // non-null, and we should just test that with an assert. |
148 ClosureRepresentationInfo getClosureRepresentationInfo(Entity entity) => | 148 ClosureRepresentationInfo getClosureRepresentationInfo(Entity entity) { |
149 _closureRepresentationMap[entity] ?? const ClosureRepresentationInfo(); | 149 // TODO(johnniwinther): Remove this check when constructor bodies a created |
| 150 // eagerly with the J-model; a constructor body should have it's own |
| 151 // [ClosureRepresentationInfo]. |
| 152 if (entity is ConstructorBodyEntity) { |
| 153 ConstructorBodyEntity constructorBody = entity; |
| 154 entity = constructorBody.constructor; |
| 155 } |
| 156 return _closureRepresentationMap[entity] ?? |
| 157 const ClosureRepresentationInfo(); |
| 158 } |
150 } | 159 } |
151 | 160 |
152 class KernelScopeInfo extends ScopeInfo { | 161 class KernelScopeInfo extends ScopeInfo { |
153 final Set<Local> localsUsedInTryOrSync; | 162 final Set<Local> localsUsedInTryOrSync; |
154 final Local thisLocal; | 163 final Local thisLocal; |
155 final Set<Local> boxedVariables; | 164 final Set<Local> boxedVariables; |
156 | 165 |
157 /// The set of variables that were defined in another scope, but are used in | 166 /// The set of variables that were defined in another scope, but are used in |
158 /// this scope. | 167 /// this scope. |
159 Set<ir.VariableDeclaration> freeVariables = new Set<ir.VariableDeclaration>(); | 168 Set<ir.VariableDeclaration> freeVariables = new Set<ir.VariableDeclaration>(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // TODO(efortuna): Implement. | 252 // TODO(efortuna): Implement. |
244 bool isVariableBoxed(Local variable) => false; | 253 bool isVariableBoxed(Local variable) => false; |
245 | 254 |
246 // TODO(efortuna): Implement. | 255 // TODO(efortuna): Implement. |
247 // Why is this closure not actually a closure? Well, to properly call | 256 // Why is this closure not actually a closure? Well, to properly call |
248 // ourselves a closure, we need to register the new closure class with the | 257 // ourselves a closure, we need to register the new closure class with the |
249 // ClosedWorldRefiner, which currently only takes elements. The change to | 258 // ClosedWorldRefiner, which currently only takes elements. The change to |
250 // that (and the subsequent adjustment here) will follow soon. | 259 // that (and the subsequent adjustment here) will follow soon. |
251 bool get isClosure => false; | 260 bool get isClosure => false; |
252 } | 261 } |
OLD | NEW |