| 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 universe; | 5 library universe; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/backend_api.dart' show Backend; | |
| 11 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
| 12 import '../common/resolution.dart' show Resolution; | 11 import '../common/resolution.dart' show Resolution; |
| 13 import '../core_types.dart'; | 12 import '../core_types.dart'; |
| 14 import '../elements/elements.dart'; | 13 import '../elements/elements.dart'; |
| 15 import '../elements/entities.dart'; | 14 import '../elements/entities.dart'; |
| 16 import '../elements/resolution_types.dart'; | 15 import '../elements/resolution_types.dart'; |
| 17 import '../elements/types.dart'; | 16 import '../elements/types.dart'; |
| 17 import '../js_backend/backend.dart' show JavaScriptBackend; |
| 18 import '../universe/class_set.dart'; | 18 import '../universe/class_set.dart'; |
| 19 import '../universe/function_set.dart' show FunctionSetBuilder; | 19 import '../universe/function_set.dart' show FunctionSetBuilder; |
| 20 import '../util/enumset.dart'; | 20 import '../util/enumset.dart'; |
| 21 import '../util/util.dart'; | 21 import '../util/util.dart'; |
| 22 import '../world.dart' show World, ClosedWorld, ClosedWorldImpl, OpenWorld; | 22 import '../world.dart' show World, ClosedWorld, ClosedWorldImpl, OpenWorld; |
| 23 import 'selector.dart' show Selector; | 23 import 'selector.dart' show Selector; |
| 24 import 'use.dart' show DynamicUse, DynamicUseKind, StaticUse, StaticUseKind; | 24 import 'use.dart' show DynamicUse, DynamicUseKind, StaticUse, StaticUseKind; |
| 25 | 25 |
| 26 /// The known constraint on receiver for a dynamic call site. | 26 /// The known constraint on receiver for a dynamic call site. |
| 27 /// | 27 /// |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 final SelectorConstraintsStrategy selectorConstraintsStrategy; | 453 final SelectorConstraintsStrategy selectorConstraintsStrategy; |
| 454 | 454 |
| 455 bool hasRuntimeTypeSupport = false; | 455 bool hasRuntimeTypeSupport = false; |
| 456 bool hasIsolateSupport = false; | 456 bool hasIsolateSupport = false; |
| 457 bool hasFunctionApplySupport = false; | 457 bool hasFunctionApplySupport = false; |
| 458 | 458 |
| 459 /// Used for testing the new more precise computation of instantiated types | 459 /// Used for testing the new more precise computation of instantiated types |
| 460 /// and classes. | 460 /// and classes. |
| 461 bool useInstantiationMap = false; | 461 bool useInstantiationMap = false; |
| 462 | 462 |
| 463 final Backend _backend; | 463 final JavaScriptBackend _backend; |
| 464 final Resolution _resolution; | 464 final Resolution _resolution; |
| 465 bool _closed = false; | 465 bool _closed = false; |
| 466 ClosedWorld _closedWorldCache; | 466 ClosedWorld _closedWorldCache; |
| 467 FunctionSetBuilder _allFunctions; | 467 FunctionSetBuilder _allFunctions; |
| 468 | 468 |
| 469 final Set<TypedefElement> _allTypedefs = new Set<TypedefElement>(); | 469 final Set<TypedefElement> _allTypedefs = new Set<TypedefElement>(); |
| 470 | 470 |
| 471 final Map<ClassElement, Set<MixinApplicationElement>> _mixinUses = | 471 final Map<ClassElement, Set<MixinApplicationElement>> _mixinUses = |
| 472 new Map<ClassElement, Set<MixinApplicationElement>>(); | 472 new Map<ClassElement, Set<MixinApplicationElement>>(); |
| 473 | 473 |
| 474 // We keep track of subtype and subclass relationships in four | 474 // We keep track of subtype and subclass relationships in four |
| 475 // distinct sets to make class hierarchy analysis faster. | 475 // distinct sets to make class hierarchy analysis faster. |
| 476 final Map<ClassElement, ClassHierarchyNode> _classHierarchyNodes = | 476 final Map<ClassElement, ClassHierarchyNode> _classHierarchyNodes = |
| 477 <ClassElement, ClassHierarchyNode>{}; | 477 <ClassElement, ClassHierarchyNode>{}; |
| 478 final Map<ClassElement, ClassSet> _classSets = <ClassElement, ClassSet>{}; | 478 final Map<ClassElement, ClassSet> _classSets = <ClassElement, ClassSet>{}; |
| 479 | 479 |
| 480 bool get isClosed => _closed; | 480 bool get isClosed => _closed; |
| 481 | 481 |
| 482 ResolutionWorldBuilderImpl( | 482 ResolutionWorldBuilderImpl( |
| 483 Backend backend, Resolution resolution, this.selectorConstraintsStrategy) | 483 this._backend, this._resolution, this.selectorConstraintsStrategy) { |
| 484 : this._backend = backend, | |
| 485 this._resolution = resolution { | |
| 486 _allFunctions = new FunctionSetBuilder(); | 484 _allFunctions = new FunctionSetBuilder(); |
| 487 } | 485 } |
| 488 | 486 |
| 489 Iterable<ClassElement> get processedClasses => _processedClasses.keys | 487 Iterable<ClassElement> get processedClasses => _processedClasses.keys |
| 490 .where((cls) => _processedClasses[cls].isInstantiated); | 488 .where((cls) => _processedClasses[cls].isInstantiated); |
| 491 | 489 |
| 492 CommonElements get commonElements => _resolution.commonElements; | 490 CommonElements get commonElements => _resolution.commonElements; |
| 493 | 491 |
| 494 ClosedWorld get closedWorldForTesting { | 492 ClosedWorld get closedWorldForTesting { |
| 495 if (!_closed) { | 493 if (!_closed) { |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 Iterable<FunctionElement> get staticFunctionsNeedingGetter; | 1110 Iterable<FunctionElement> get staticFunctionsNeedingGetter; |
| 1113 Iterable<FunctionElement> get methodsNeedingSuperGetter; | 1111 Iterable<FunctionElement> get methodsNeedingSuperGetter; |
| 1114 | 1112 |
| 1115 /// The set of all referenced static fields. | 1113 /// The set of all referenced static fields. |
| 1116 /// | 1114 /// |
| 1117 /// Invariant: Elements are declaration elements. | 1115 /// Invariant: Elements are declaration elements. |
| 1118 Iterable<FieldElement> get allReferencedStaticFields; | 1116 Iterable<FieldElement> get allReferencedStaticFields; |
| 1119 } | 1117 } |
| 1120 | 1118 |
| 1121 class CodegenWorldBuilderImpl implements CodegenWorldBuilder { | 1119 class CodegenWorldBuilderImpl implements CodegenWorldBuilder { |
| 1122 final Backend _backend; | 1120 final JavaScriptBackend _backend; |
| 1123 ClosedWorld __world; | 1121 ClosedWorld __world; |
| 1124 | 1122 |
| 1125 /// The set of all directly instantiated classes, that is, classes with a | 1123 /// The set of all directly instantiated classes, that is, classes with a |
| 1126 /// generative constructor that has been called directly and not only through | 1124 /// generative constructor that has been called directly and not only through |
| 1127 /// a super-call. | 1125 /// a super-call. |
| 1128 /// | 1126 /// |
| 1129 /// Invariant: Elements are declaration elements. | 1127 /// Invariant: Elements are declaration elements. |
| 1130 // TODO(johnniwinther): [_directlyInstantiatedClasses] and | 1128 // TODO(johnniwinther): [_directlyInstantiatedClasses] and |
| 1131 // [_instantiatedTypes] sets should be merged. | 1129 // [_instantiatedTypes] sets should be merged. |
| 1132 final Set<ClassElement> _directlyInstantiatedClasses = | 1130 final Set<ClassElement> _directlyInstantiatedClasses = |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 if (hasClosurization) { | 1925 if (hasClosurization) { |
| 1928 return MemberUses.NONE; | 1926 return MemberUses.NONE; |
| 1929 } | 1927 } |
| 1930 hasNormalUse = hasClosurization = true; | 1928 hasNormalUse = hasClosurization = true; |
| 1931 return _pendingUse.removeAll(MemberUses.ALL_STATIC); | 1929 return _pendingUse.removeAll(MemberUses.ALL_STATIC); |
| 1932 } | 1930 } |
| 1933 | 1931 |
| 1934 @override | 1932 @override |
| 1935 EnumSet<MemberUse> get _originalUse => MemberUses.ALL_STATIC; | 1933 EnumSet<MemberUse> get _originalUse => MemberUses.ALL_STATIC; |
| 1936 } | 1934 } |
| OLD | NEW |