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

Side by Side Diff: pkg/compiler/lib/src/universe/world_impact.dart

Issue 1416253002: Remove requiredTypes (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 2 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
« no previous file with comments | « pkg/compiler/lib/src/typechecker.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.universe.world_impact; 5 library dart2js.universe.world_impact;
6 6
7 import '../dart_types.dart' show 7 import '../dart_types.dart' show
8 DartType, 8 DartType,
9 InterfaceType; 9 InterfaceType;
10 import '../elements/elements.dart' show 10 import '../elements/elements.dart' show
(...skipping 22 matching lines...) Expand all
33 Iterable<InterfaceType> get instantiatedTypes => const <InterfaceType>[]; 33 Iterable<InterfaceType> get instantiatedTypes => const <InterfaceType>[];
34 34
35 // TODO(johnniwinther): Collect checked types for checked mode separately to 35 // TODO(johnniwinther): Collect checked types for checked mode separately to
36 // support serialization. 36 // support serialization.
37 Iterable<DartType> get isChecks => const <DartType>[]; 37 Iterable<DartType> get isChecks => const <DartType>[];
38 38
39 Iterable<DartType> get checkedModeChecks => const <DartType>[]; 39 Iterable<DartType> get checkedModeChecks => const <DartType>[];
40 40
41 Iterable<DartType> get asCasts => const <DartType>[]; 41 Iterable<DartType> get asCasts => const <DartType>[];
42 42
43 Iterable<DartType> get onCatchTypes => const <DartType>[];
44
43 Iterable<MethodElement> get closurizedFunctions => const <MethodElement>[]; 45 Iterable<MethodElement> get closurizedFunctions => const <MethodElement>[];
44 46
45 Iterable<LocalFunctionElement> get closures => const <LocalFunctionElement>[]; 47 Iterable<LocalFunctionElement> get closures => const <LocalFunctionElement>[];
46 48
47 Iterable<DartType> get typeLiterals => const <DartType>[]; 49 Iterable<DartType> get typeLiterals => const <DartType>[];
48 50
49 String toString() { 51 String toString() => dump(this);
52
53 static String dump(WorldImpact worldImpact) {
50 StringBuffer sb = new StringBuffer(); 54 StringBuffer sb = new StringBuffer();
55 printOn(sb, worldImpact);
56 return sb.toString();
57 }
51 58
59 static void printOn(StringBuffer sb, WorldImpact worldImpact) {
52 void add(String title, Iterable iterable) { 60 void add(String title, Iterable iterable) {
53 if (iterable.isNotEmpty) { 61 if (iterable.isNotEmpty) {
54 sb.write('\n $title:'); 62 sb.write('\n $title:');
55 iterable.forEach((e) => sb.write('\n $e')); 63 iterable.forEach((e) => sb.write('\n $e'));
56 } 64 }
57 } 65 }
58 66
59 add('dynamic invocations', dynamicInvocations); 67 add('dynamic invocations', worldImpact.dynamicInvocations);
60 add('dynamic getters', dynamicGetters); 68 add('dynamic getters', worldImpact.dynamicGetters);
61 add('dynamic setters', dynamicSetters); 69 add('dynamic setters', worldImpact.dynamicSetters);
62 add('static uses', staticUses); 70 add('static uses', worldImpact.staticUses);
63 add('instantiated types', instantiatedTypes); 71 add('instantiated types', worldImpact.instantiatedTypes);
64 add('is-checks', isChecks); 72 add('is-checks', worldImpact.isChecks);
65 add('checked-mode checks', checkedModeChecks); 73 add('checked-mode checks', worldImpact.checkedModeChecks);
66 add('as-casts', asCasts); 74 add('as-casts', worldImpact.asCasts);
67 add('closurized functions', closurizedFunctions); 75 add('on-catch-types', worldImpact.onCatchTypes);
68 add('closures', closures); 76 add('closurized functions', worldImpact.closurizedFunctions);
69 add('type literals', typeLiterals); 77 add('closures', worldImpact.closures);
70 78 add('type literals', worldImpact.typeLiterals);
71 return sb.toString();
72 } 79 }
73 } 80 }
74 81
75 class WorldImpactBuilder { 82 class WorldImpactBuilder {
76 // TODO(johnniwinther): Do we benefit from lazy initialization of the 83 // TODO(johnniwinther): Do we benefit from lazy initialization of the
77 // [Setlet]s? 84 // [Setlet]s?
78 Setlet<UniverseSelector> _dynamicInvocations; 85 Setlet<UniverseSelector> _dynamicInvocations;
79 Setlet<UniverseSelector> _dynamicGetters; 86 Setlet<UniverseSelector> _dynamicGetters;
80 Setlet<UniverseSelector> _dynamicSetters; 87 Setlet<UniverseSelector> _dynamicSetters;
81 Setlet<InterfaceType> _instantiatedTypes; 88 Setlet<InterfaceType> _instantiatedTypes;
82 Setlet<Element> _staticUses; 89 Setlet<Element> _staticUses;
83 Setlet<DartType> _isChecks; 90 Setlet<DartType> _isChecks;
84 Setlet<DartType> _asCasts; 91 Setlet<DartType> _asCasts;
85 Setlet<DartType> _checkedModeChecks; 92 Setlet<DartType> _checkedModeChecks;
93 Setlet<DartType> _onCatchTypes;
86 Setlet<MethodElement> _closurizedFunctions; 94 Setlet<MethodElement> _closurizedFunctions;
87 Setlet<LocalFunctionElement> _closures; 95 Setlet<LocalFunctionElement> _closures;
88 Setlet<DartType> _typeLiterals; 96 Setlet<DartType> _typeLiterals;
89 97
90 void registerDynamicGetter(UniverseSelector selector) { 98 void registerDynamicGetter(UniverseSelector selector) {
91 assert(selector != null); 99 assert(selector != null);
92 if (_dynamicGetters == null) { 100 if (_dynamicGetters == null) {
93 _dynamicGetters = new Setlet<UniverseSelector>(); 101 _dynamicGetters = new Setlet<UniverseSelector>();
94 } 102 }
95 _dynamicGetters.add(selector); 103 _dynamicGetters.add(selector);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 _checkedModeChecks = new Setlet<DartType>(); 202 _checkedModeChecks = new Setlet<DartType>();
195 } 203 }
196 _checkedModeChecks.add(type); 204 _checkedModeChecks.add(type);
197 } 205 }
198 206
199 Iterable<DartType> get checkedModeChecks { 207 Iterable<DartType> get checkedModeChecks {
200 return _checkedModeChecks != null 208 return _checkedModeChecks != null
201 ? _checkedModeChecks : const <DartType>[]; 209 ? _checkedModeChecks : const <DartType>[];
202 } 210 }
203 211
212 void registerOnCatchType(DartType type) {
213 assert(type != null);
214 if (_onCatchTypes == null) {
215 _onCatchTypes = new Setlet<DartType>();
216 }
217 _onCatchTypes.add(type);
218 }
219
220 Iterable<DartType> get onCatchTypes {
221 return _onCatchTypes != null
222 ? _onCatchTypes : const <DartType>[];
223 }
224
204 void registerClosurizedFunction(MethodElement element) { 225 void registerClosurizedFunction(MethodElement element) {
205 if (_closurizedFunctions == null) { 226 if (_closurizedFunctions == null) {
206 _closurizedFunctions = new Setlet<MethodElement>(); 227 _closurizedFunctions = new Setlet<MethodElement>();
207 } 228 }
208 _closurizedFunctions.add(element); 229 _closurizedFunctions.add(element);
209 } 230 }
210 231
211 Iterable<MethodElement> get closurizedFunctions { 232 Iterable<MethodElement> get closurizedFunctions {
212 return _closurizedFunctions != null 233 return _closurizedFunctions != null
213 ? _closurizedFunctions : const <MethodElement>[]; 234 ? _closurizedFunctions : const <MethodElement>[];
214 } 235 }
215 236
216 void registerClosure(LocalFunctionElement element) { 237 void registerClosure(LocalFunctionElement element) {
217 if (_closures == null) { 238 if (_closures == null) {
218 _closures = new Setlet<LocalFunctionElement>(); 239 _closures = new Setlet<LocalFunctionElement>();
219 } 240 }
220 _closures.add(element); 241 _closures.add(element);
221 } 242 }
222 243
223 Iterable<LocalFunctionElement> get closures { 244 Iterable<LocalFunctionElement> get closures {
224 return _closures != null 245 return _closures != null
225 ? _closures : const <LocalFunctionElement>[]; 246 ? _closures : const <LocalFunctionElement>[];
226 } 247 }
227 } 248 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/typechecker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698