OLD | NEW |
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 'common.dart'; | 7 import 'common.dart'; |
8 import 'constants/constant_system.dart'; | 8 import 'constants/constant_system.dart'; |
9 import 'common_elements.dart' show CommonElements, ElementEnvironment; | 9 import 'common_elements.dart' show CommonElements, ElementEnvironment; |
10 import 'elements/entities.dart'; | 10 import 'elements/entities.dart'; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 // TODO(johnniwinther): Is this 'potentially called' or 'known to be called'? | 370 // TODO(johnniwinther): Is this 'potentially called' or 'known to be called'? |
371 void addFunctionCalledInLoop(MemberEntity element); | 371 void addFunctionCalledInLoop(MemberEntity element); |
372 | 372 |
373 /// Registers that [element] is guaranteed not to throw an exception. | 373 /// Registers that [element] is guaranteed not to throw an exception. |
374 void registerCannotThrow(FunctionEntity element); | 374 void registerCannotThrow(FunctionEntity element); |
375 | 375 |
376 /// Adds the closure class [cls] to the inference world. The class is | 376 /// Adds the closure class [cls] to the inference world. The class is |
377 /// considered directly instantiated. If [fromInstanceMember] is true, this | 377 /// considered directly instantiated. If [fromInstanceMember] is true, this |
378 /// closure class represents a closure that is inside an instance member, thus | 378 /// closure class represents a closure that is inside an instance member, thus |
379 /// has access to `this`. | 379 /// has access to `this`. |
380 void registerClosureClass(covariant ClassEntity cls, bool fromInstanceMember); | 380 void registerClosureClass(ClassEntity cls); |
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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 MemberElement element = findMatchIn(cls, selector); | 1300 MemberElement element = findMatchIn(cls, selector); |
1301 if (element == null) return false; | 1301 if (element == null) return false; |
1302 | 1302 |
1303 if (element.isAbstract) { | 1303 if (element.isAbstract) { |
1304 ClassElement enclosingClass = element.enclosingClass; | 1304 ClassElement enclosingClass = element.enclosingClass; |
1305 return hasConcreteMatch(enclosingClass.superclass, selector); | 1305 return hasConcreteMatch(enclosingClass.superclass, selector); |
1306 } | 1306 } |
1307 return selector.appliesUntyped(element); | 1307 return selector.appliesUntyped(element); |
1308 } | 1308 } |
1309 | 1309 |
1310 void registerClosureClass(ClassElement cls, bool _) { | 1310 void registerClosureClass(covariant ClassElement cls) { |
1311 ClassHierarchyNode parentNode = getClassHierarchyNode(cls.superclass); | 1311 ClassHierarchyNode parentNode = getClassHierarchyNode(cls.superclass); |
1312 ClassHierarchyNode node = _classHierarchyNodes[cls] = | 1312 ClassHierarchyNode node = _classHierarchyNodes[cls] = |
1313 new ClassHierarchyNode(parentNode, cls, cls.hierarchyDepth); | 1313 new ClassHierarchyNode(parentNode, cls, cls.hierarchyDepth); |
1314 for (ResolutionInterfaceType type in cls.allSupertypes) { | 1314 for (ResolutionInterfaceType type in cls.allSupertypes) { |
1315 ClassSet subtypeSet = getClassSet(type.element); | 1315 ClassSet subtypeSet = getClassSet(type.element); |
1316 subtypeSet.addSubtype(node); | 1316 subtypeSet.addSubtype(node); |
1317 } | 1317 } |
1318 _classSets[cls] = new ClassSet(node); | 1318 _classSets[cls] = new ClassSet(node); |
1319 _updateSuperClassHierarchyNodeForClass(node); | 1319 _updateSuperClassHierarchyNodeForClass(node); |
1320 node.isDirectlyInstantiated = true; | 1320 node.isDirectlyInstantiated = true; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 void computeRtiNeed(ResolutionWorldBuilder resolutionWorldBuilder, | 1353 void computeRtiNeed(ResolutionWorldBuilder resolutionWorldBuilder, |
1354 RuntimeTypesNeedBuilder rtiNeedBuilder, | 1354 RuntimeTypesNeedBuilder rtiNeedBuilder, |
1355 {bool enableTypeAssertions}) { | 1355 {bool enableTypeAssertions}) { |
1356 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed( | 1356 _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed( |
1357 resolutionWorldBuilder, this, | 1357 resolutionWorldBuilder, this, |
1358 enableTypeAssertions: enableTypeAssertions); | 1358 enableTypeAssertions: enableTypeAssertions); |
1359 } | 1359 } |
1360 | 1360 |
1361 RuntimeTypesNeed get rtiNeed => _rtiNeed; | 1361 RuntimeTypesNeed get rtiNeed => _rtiNeed; |
1362 } | 1362 } |
OLD | NEW |