Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: pkg/compiler/lib/src/js_model/js_strategy.dart

Issue 2984263002: Make the ClosedWorld build the closure class on the kernel side. (Closed)
Patch Set: . Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
8
7 import '../closure.dart' show ClosureConversionTask; 9 import '../closure.dart' show ClosureConversionTask;
8 import '../common.dart'; 10 import '../common.dart';
9 import '../common/tasks.dart'; 11 import '../common/tasks.dart';
10 import '../common_elements.dart'; 12 import '../common_elements.dart';
11 import '../compiler.dart'; 13 import '../compiler.dart';
12 import '../constants/constant_system.dart'; 14 import '../constants/constant_system.dart';
13 import '../elements/entities.dart'; 15 import '../elements/entities.dart';
14 import '../elements/types.dart'; 16 import '../elements/types.dart';
15 import '../enqueue.dart'; 17 import '../enqueue.dart';
16 import '../io/source_information.dart'; 18 import '../io/source_information.dart';
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 implementedClasses, 377 implementedClasses,
376 liveNativeClasses, 378 liveNativeClasses,
377 liveInstanceMembers, 379 liveInstanceMembers,
378 assignedInstanceMembers, 380 assignedInstanceMembers,
379 allTypedefs, 381 allTypedefs,
380 mixinUses, 382 mixinUses,
381 typesImplementedBySubclasses, 383 typesImplementedBySubclasses,
382 classHierarchyNodes, 384 classHierarchyNodes,
383 classSets); 385 classSets);
384 386
385 @override 387 /// Construct a closure class and set up the necessary class inference
386 void registerClosureClass(ClassEntity cls) { 388 /// hierarchy.
389 KernelClosureClass buildClosureClass(String name, JLibrary enclosingLibrary,
390 KernelScopeInfo info, ir.Location location, KernelToLocalsMap localsMap) {
391 ClassEntity superclass = commonElements.closureClass;
392
393 KernelClosureClass cls = elementMap.constructClosureClass(
394 name,
395 enclosingLibrary,
396 info,
397 location,
398 localsMap,
399 new InterfaceType(superclass, const []));
400
387 // Tell the hierarchy that this is the super class. then we can use 401 // Tell the hierarchy that this is the super class. then we can use
388 // .getSupertypes(class) 402 // .getSupertypes(class)
389 ClassEntity superclass = commonElements.closureClass;
390 ClassHierarchyNode parentNode = getClassHierarchyNode(superclass); 403 ClassHierarchyNode parentNode = getClassHierarchyNode(superclass);
391 ClassHierarchyNode node = new ClassHierarchyNode( 404 ClassHierarchyNode node = new ClassHierarchyNode(
392 parentNode, cls, getHierarchyDepth(superclass) + 1); 405 parentNode, cls, getHierarchyDepth(superclass) + 1);
393 addClassHierarchyNode(cls, node); 406 addClassHierarchyNode(cls, node);
394 for (InterfaceType type in getOrderedTypeSet(superclass).types) { 407 for (InterfaceType type in getOrderedTypeSet(superclass).types) {
395 // TODO(efortuna): assert that the FunctionClass is in this ordered set. 408 // TODO(efortuna): assert that the FunctionClass is in this ordered set.
396 // If not, we need to explicitly add node as a subtype of FunctionClass. 409 // If not, we need to explicitly add node as a subtype of FunctionClass.
397 ClassSet subtypeSet = getClassSet(type.element); 410 ClassSet subtypeSet = getClassSet(type.element);
398 subtypeSet.addSubtype(node); 411 subtypeSet.addSubtype(node);
399 } 412 }
400 addClassSet(cls, new ClassSet(node)); 413 addClassSet(cls, new ClassSet(node));
401 elementMap.addClosureClass(cls, new InterfaceType(superclass, const []));
402 node.isDirectlyInstantiated = true; 414 node.isDirectlyInstantiated = true;
415
416 return cls;
417 }
418
419 @override
420 void registerClosureClass(ClassEntity cls) {
421 throw new UnsupportedError('JsClosedWorld.registerClosureClass');
403 } 422 }
404 } 423 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698