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.js_model.strategy; | 5 library dart2js.js_model.strategy; |
6 | 6 |
7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
8 | 8 |
9 import '../closure.dart' show ClosureConversionTask; | 9 import '../closure.dart' show ClosureConversionTask; |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 typesImplementedBySubclasses, | 406 typesImplementedBySubclasses, |
407 classHierarchyNodes, | 407 classHierarchyNodes, |
408 classSets); | 408 classSets); |
409 | 409 |
410 /// Construct a closure class and set up the necessary class inference | 410 /// Construct a closure class and set up the necessary class inference |
411 /// hierarchy. | 411 /// hierarchy. |
412 KernelClosureClass buildClosureClass( | 412 KernelClosureClass buildClosureClass( |
413 MemberEntity member, | 413 MemberEntity member, |
414 ir.FunctionNode originalClosureFunctionNode, | 414 ir.FunctionNode originalClosureFunctionNode, |
415 JLibrary enclosingLibrary, | 415 JLibrary enclosingLibrary, |
| 416 Set<JsCapturedScope> capturedScopes, |
416 KernelScopeInfo info, | 417 KernelScopeInfo info, |
417 ir.Location location, | 418 ir.Location location, |
418 KernelToLocalsMap localsMap) { | 419 KernelToLocalsMap localsMap) { |
419 ClassEntity superclass = commonElements.closureClass; | 420 ClassEntity superclass = commonElements.closureClass; |
420 | 421 |
421 KernelClosureClass cls = elementMap.constructClosureClass( | 422 KernelClosureClass cls = elementMap.constructClosureClass( |
422 member, | 423 member, |
423 originalClosureFunctionNode, | 424 originalClosureFunctionNode, |
424 enclosingLibrary, | 425 enclosingLibrary, |
| 426 capturedScopes, |
425 info, | 427 info, |
426 location, | 428 location, |
427 localsMap, | 429 localsMap, |
428 new InterfaceType(superclass, const [])); | 430 new InterfaceType(superclass, const [])); |
429 | 431 |
430 // Tell the hierarchy that this is the super class. then we can use | 432 // Tell the hierarchy that this is the super class. then we can use |
431 // .getSupertypes(class) | 433 // .getSupertypes(class) |
432 ClassHierarchyNode parentNode = getClassHierarchyNode(superclass); | 434 ClassHierarchyNode parentNode = getClassHierarchyNode(superclass); |
433 ClassHierarchyNode node = new ClassHierarchyNode( | 435 ClassHierarchyNode node = new ClassHierarchyNode( |
434 parentNode, cls, getHierarchyDepth(superclass) + 1); | 436 parentNode, cls.closureClassEntity, getHierarchyDepth(superclass) + 1); |
435 addClassHierarchyNode(cls, node); | 437 addClassHierarchyNode(cls.closureClassEntity, node); |
436 for (InterfaceType type in getOrderedTypeSet(superclass).types) { | 438 for (InterfaceType type in getOrderedTypeSet(superclass).types) { |
437 // TODO(efortuna): assert that the FunctionClass is in this ordered set. | 439 // TODO(efortuna): assert that the FunctionClass is in this ordered set. |
438 // If not, we need to explicitly add node as a subtype of FunctionClass. | 440 // If not, we need to explicitly add node as a subtype of FunctionClass. |
439 ClassSet subtypeSet = getClassSet(type.element); | 441 ClassSet subtypeSet = getClassSet(type.element); |
440 subtypeSet.addSubtype(node); | 442 subtypeSet.addSubtype(node); |
441 } | 443 } |
442 addClassSet(cls, new ClassSet(node)); | 444 addClassSet(cls.closureClassEntity, new ClassSet(node)); |
443 node.isDirectlyInstantiated = true; | 445 node.isDirectlyInstantiated = true; |
444 | 446 |
445 return cls; | 447 return cls; |
446 } | 448 } |
447 | 449 |
448 @override | 450 @override |
449 void registerClosureClass(ClassEntity cls) { | 451 void registerClosureClass(ClassEntity cls) { |
450 throw new UnsupportedError('JsClosedWorld.registerClosureClass'); | 452 throw new UnsupportedError('JsClosedWorld.registerClosureClass'); |
451 } | 453 } |
452 } | 454 } |
OLD | NEW |