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

Side by Side Diff: pkg/compiler/lib/src/world.dart

Issue 2981673002: Register created closure class with the world. (Closed)
Patch Set: . Created 3 years, 5 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.world; 5 library dart2js.world;
6 6
7 import 'closure.dart' show ClosureClassElement;
8 import 'common.dart'; 7 import 'common.dart';
9 import 'constants/constant_system.dart'; 8 import 'constants/constant_system.dart';
10 import 'common_elements.dart' show CommonElements, ElementEnvironment; 9 import 'common_elements.dart' show CommonElements, ElementEnvironment;
11 import 'elements/entities.dart'; 10 import 'elements/entities.dart';
12 import 'elements/elements.dart' 11 import 'elements/elements.dart'
13 show 12 show
14 ClassElement, 13 ClassElement,
15 Element, 14 Element,
16 MemberElement, 15 MemberElement,
17 MethodElement, 16 MethodElement,
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 bool getCurrentlyKnownMightBePassedToApply(FunctionEntity element); 368 bool getCurrentlyKnownMightBePassedToApply(FunctionEntity element);
370 369
371 /// Registers that [element] is called in a loop. 370 /// Registers that [element] is called in a loop.
372 // TODO(johnniwinther): Is this 'potentially called' or 'known to be called'? 371 // TODO(johnniwinther): Is this 'potentially called' or 'known to be called'?
373 void addFunctionCalledInLoop(MemberEntity element); 372 void addFunctionCalledInLoop(MemberEntity element);
374 373
375 /// Registers that [element] is guaranteed not to throw an exception. 374 /// Registers that [element] is guaranteed not to throw an exception.
376 void registerCannotThrow(FunctionEntity element); 375 void registerCannotThrow(FunctionEntity element);
377 376
378 /// Adds the closure class [cls] to the inference world. The class is 377 /// Adds the closure class [cls] to the inference world. The class is
379 /// considered directly instantiated. 378 /// considered directly instantiated. If isInstanceMember is true, this
380 void registerClosureClass(covariant ClassElement cls); 379 /// closure class represents a closure that is an instance member in a class.
Siggi Cherem (dart-lang) 2017/07/12 21:25:04 not sure I understand the concept of a "closure in
Emily Fortuna 2017/07/12 22:02:18 yes, that's what I meant, and that is phrased much
380 void registerClosureClass(covariant ClassEntity cls, bool isInstanceMember);
381 } 381 }
382 382
383 abstract class OpenWorld implements World { 383 abstract class OpenWorld implements World {
384 /// Called to add [cls] to the set of known classes. 384 /// Called to add [cls] to the set of known classes.
385 /// 385 ///
386 /// This ensures that class hierarchy queries can be performed on [cls] and 386 /// This ensures that class hierarchy queries can be performed on [cls] and
387 /// classes that extend or implement it. 387 /// classes that extend or implement it.
388 void registerClass(covariant ClassEntity cls); 388 void registerClass(covariant ClassEntity cls);
389 389
390 void registerUsedElement(MemberEntity element); 390 void registerUsedElement(MemberEntity element);
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 StringBuffer sb = new StringBuffer(); 1171 StringBuffer sb = new StringBuffer();
1172 if (cls != null) { 1172 if (cls != null) {
1173 sb.write("Classes in the closed world related to $cls:\n"); 1173 sb.write("Classes in the closed world related to $cls:\n");
1174 } else { 1174 } else {
1175 sb.write("Instantiated classes in the closed world:\n"); 1175 sb.write("Instantiated classes in the closed world:\n");
1176 } 1176 }
1177 getClassHierarchyNode(commonElements.objectClass) 1177 getClassHierarchyNode(commonElements.objectClass)
1178 .printOn(sb, ' ', instantiatedOnly: cls == null, withRespectTo: cls); 1178 .printOn(sb, ' ', instantiatedOnly: cls == null, withRespectTo: cls);
1179 return sb.toString(); 1179 return sb.toString();
1180 } 1180 }
1181
1182 /// Should only be called by subclasses.
1183 void addClassHierarchyNode(ClassEntity cls, ClassHierarchyNode node) {
1184 _classHierarchyNodes[cls] = node;
1185 }
1186
1187 /// Should only be called by subclasses.
1188 void addClassSet(ClassEntity cls, ClassSet classSet) {
1189 _classSets[cls] = classSet;
1190 }
1181 } 1191 }
1182 1192
1183 class ClosedWorldImpl extends ClosedWorldBase with ClosedWorldRtiNeedMixin { 1193 class ClosedWorldImpl extends ClosedWorldBase with ClosedWorldRtiNeedMixin {
1184 ClosedWorldImpl( 1194 ClosedWorldImpl(
1185 {CompilerOptions options, 1195 {CompilerOptions options,
1186 ElementEnvironment elementEnvironment, 1196 ElementEnvironment elementEnvironment,
1187 DartTypes dartTypes, 1197 DartTypes dartTypes,
1188 CommonElements commonElements, 1198 CommonElements commonElements,
1189 ConstantSystem constantSystem, 1199 ConstantSystem constantSystem,
1190 NativeData nativeData, 1200 NativeData nativeData,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 MemberElement element = findMatchIn(cls, selector); 1300 MemberElement element = findMatchIn(cls, selector);
1291 if (element == null) return false; 1301 if (element == null) return false;
1292 1302
1293 if (element.isAbstract) { 1303 if (element.isAbstract) {
1294 ClassElement enclosingClass = element.enclosingClass; 1304 ClassElement enclosingClass = element.enclosingClass;
1295 return hasConcreteMatch(enclosingClass.superclass, selector); 1305 return hasConcreteMatch(enclosingClass.superclass, selector);
1296 } 1306 }
1297 return selector.appliesUntyped(element); 1307 return selector.appliesUntyped(element);
1298 } 1308 }
1299 1309
1300 void registerClosureClass(ClosureClassElement cls) { 1310 void registerClosureClass(ClassElement cls, bool not_used) {
Siggi Cherem (dart-lang) 2017/07/12 21:25:04 nit: a common convention is to use "_" for unused
Emily Fortuna 2017/07/12 22:02:18 done.
1301 ClassHierarchyNode parentNode = getClassHierarchyNode(cls.superclass); 1311 ClassHierarchyNode parentNode = getClassHierarchyNode(cls.superclass);
1302 ClassHierarchyNode node = _classHierarchyNodes[cls] = 1312 ClassHierarchyNode node = _classHierarchyNodes[cls] =
1303 new ClassHierarchyNode(parentNode, cls, cls.hierarchyDepth); 1313 new ClassHierarchyNode(parentNode, cls, cls.hierarchyDepth);
1304 for (ResolutionInterfaceType type in cls.allSupertypes) { 1314 for (ResolutionInterfaceType type in cls.allSupertypes) {
1305 ClassSet subtypeSet = getClassSet(type.element); 1315 ClassSet subtypeSet = getClassSet(type.element);
1306 subtypeSet.addSubtype(node); 1316 subtypeSet.addSubtype(node);
1307 } 1317 }
1308 _classSets[cls] = new ClassSet(node); 1318 _classSets[cls] = new ClassSet(node);
1309 _updateSuperClassHierarchyNodeForClass(node); 1319 _updateSuperClassHierarchyNodeForClass(node);
1310 node.isDirectlyInstantiated = true; 1320 node.isDirectlyInstantiated = true;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 void computeRtiNeed(ResolutionWorldBuilder resolutionWorldBuilder, 1353 void computeRtiNeed(ResolutionWorldBuilder resolutionWorldBuilder,
1344 RuntimeTypesNeedBuilder rtiNeedBuilder, 1354 RuntimeTypesNeedBuilder rtiNeedBuilder,
1345 {bool enableTypeAssertions}) { 1355 {bool enableTypeAssertions}) {
1346 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed( 1356 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed(
1347 resolutionWorldBuilder, this, 1357 resolutionWorldBuilder, this,
1348 enableTypeAssertions: enableTypeAssertions); 1358 enableTypeAssertions: enableTypeAssertions);
1349 } 1359 }
1350 1360
1351 RuntimeTypesNeed get rtiNeed => _rtiNeed; 1361 RuntimeTypesNeed get rtiNeed => _rtiNeed;
1352 } 1362 }
OLDNEW
« pkg/compiler/lib/src/kernel/env.dart ('K') | « pkg/compiler/lib/src/kernel/env.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698