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 dart2js.kernel.backend_strategy; | 5 library dart2js.kernel.backend_strategy; |
6 | 6 |
7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
8 | 8 |
9 import '../backend_strategy.dart'; | 9 import '../backend_strategy.dart'; |
10 import '../closure.dart'; | 10 import '../closure.dart'; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 work.element.enclosingClass, | 145 work.element.enclosingClass, |
146 _elementMap.getMemberNode(work.element), | 146 _elementMap.getMemberNode(work.element), |
147 _compiler, | 147 _compiler, |
148 _elementMap, | 148 _elementMap, |
149 new KernelToTypeInferenceMapImpl(closedWorld), | 149 new KernelToTypeInferenceMapImpl(closedWorld), |
150 new KernelToLocalsMapImpl(work.element), | 150 new KernelToLocalsMapImpl(work.element), |
151 closedWorld, | 151 closedWorld, |
152 _compiler.codegenWorldBuilder, | 152 _compiler.codegenWorldBuilder, |
153 work.registry, | 153 work.registry, |
154 // TODO(johnniwinther): Support these: | 154 // TODO(johnniwinther): Support these: |
155 const KernelClosureClassMaps(), | 155 const KernelClosureDataLookup(), |
156 const SourceInformationBuilder(), | 156 const SourceInformationBuilder(), |
157 null, // Function node used as capture scope id. | 157 null, // Function node used as capture scope id. |
158 targetIsConstructorBody: false); | 158 targetIsConstructorBody: false); |
159 return builder.build(); | 159 return builder.build(); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 class KernelToTypeInferenceMapImpl implements KernelToTypeInferenceMap { | 163 class KernelToTypeInferenceMapImpl implements KernelToTypeInferenceMap { |
164 final ClosedWorld _closedWorld; | 164 final ClosedWorld _closedWorld; |
165 | 165 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 @override | 274 @override |
275 Local getLocal(ir.VariableDeclaration node) { | 275 Local getLocal(ir.VariableDeclaration node) { |
276 return _map.putIfAbsent(node, () { | 276 return _map.putIfAbsent(node, () { |
277 return new KLocal(node.name, currentMember); | 277 return new KLocal(node.name, currentMember); |
278 }); | 278 }); |
279 } | 279 } |
280 | 280 |
281 @override | 281 @override |
282 LoopClosureRepresentationInfo getClosureRepresentationInfoForLoop( | 282 LoopClosureRepresentationInfo getClosureRepresentationInfoForLoop( |
283 ClosureClassMaps closureClassMaps, ir.TreeNode node) { | 283 ClosureDataLookup closureLookup, ir.TreeNode node) { |
284 return const LoopClosureRepresentationInfo(); | 284 return const LoopClosureRepresentationInfo(); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 class KLocal implements Local { | 288 class KLocal implements Local { |
289 final String name; | 289 final String name; |
290 final MemberEntity memberContext; | 290 final MemberEntity memberContext; |
291 | 291 |
292 KLocal(this.name, this.memberContext); | 292 KLocal(this.name, this.memberContext); |
293 | 293 |
294 @override | 294 @override |
295 Entity get executableContext => memberContext; | 295 Entity get executableContext => memberContext; |
296 | 296 |
297 String toString() { | 297 String toString() { |
298 StringBuffer sb = new StringBuffer(); | 298 StringBuffer sb = new StringBuffer(); |
299 sb.write('local('); | 299 sb.write('local('); |
300 if (memberContext.enclosingClass != null) { | 300 if (memberContext.enclosingClass != null) { |
301 sb.write(memberContext.enclosingClass.name); | 301 sb.write(memberContext.enclosingClass.name); |
302 sb.write('.'); | 302 sb.write('.'); |
303 } | 303 } |
304 sb.write(memberContext.name); | 304 sb.write(memberContext.name); |
305 sb.write('#'); | 305 sb.write('#'); |
306 sb.write(name); | 306 sb.write(name); |
307 sb.write(')'); | 307 sb.write(')'); |
308 return sb.toString(); | 308 return sb.toString(); |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 /// TODO(johnniwinther,efortuna): Implement this. | 312 /// TODO(johnniwinther,efortuna): Implement this. |
313 class KernelClosureClassMaps implements ClosureClassMaps<ir.Node> { | 313 class KernelClosureDataLookup implements ClosureDataLookup<ir.Node> { |
314 const KernelClosureClassMaps(); | 314 const KernelClosureDataLookup(); |
315 | 315 |
316 @override | 316 @override |
317 ClosureAnalysisInfo getClosureAnalysisInfo(ir.Node node) { | 317 ClosureAnalysisInfo getClosureAnalysisInfo(ir.Node node) { |
318 return const ClosureAnalysisInfo(); | 318 return const ClosureAnalysisInfo(); |
319 } | 319 } |
320 | 320 |
321 @override | 321 @override |
322 LoopClosureRepresentationInfo getClosureRepresentationInfoForLoop( | 322 LoopClosureRepresentationInfo getClosureRepresentationInfoForLoop( |
323 ir.Node loopNode) { | 323 ir.Node loopNode) { |
324 return const LoopClosureRepresentationInfo(); | 324 return const LoopClosureRepresentationInfo(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { | 377 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { |
378 return classes.toList() | 378 return classes.toList() |
379 ..sort((ClassEntity a, ClassEntity b) { | 379 ..sort((ClassEntity a, ClassEntity b) { |
380 int r = _compareLibraries(a.library, b.library); | 380 int r = _compareLibraries(a.library, b.library); |
381 if (r != 0) return r; | 381 if (r != 0) return r; |
382 return _compareNodes( | 382 return _compareNodes( |
383 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); | 383 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); |
384 }); | 384 }); |
385 } | 385 } |
386 } | 386 } |
OLD | NEW |