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

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

Issue 1413543004: Extract WorldImpactBuilder from _ResolutionWorldImpact. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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/resolution/registry.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
11 Element, 11 Element,
12 LocalFunctionElement, 12 LocalFunctionElement,
13 MethodElement; 13 MethodElement;
14 import '../util/util.dart' show
15 Setlet;
16
14 import 'universe.dart' show 17 import 'universe.dart' show
15 UniverseSelector; 18 UniverseSelector;
16 19
17 class WorldImpact { 20 class WorldImpact {
18 const WorldImpact(); 21 const WorldImpact();
19 22
20 Iterable<UniverseSelector> get dynamicInvocations => 23 Iterable<UniverseSelector> get dynamicInvocations =>
21 const <UniverseSelector>[]; 24 const <UniverseSelector>[];
22 Iterable<UniverseSelector> get dynamicGetters => const <UniverseSelector>[]; 25 Iterable<UniverseSelector> get dynamicGetters => const <UniverseSelector>[];
23 Iterable<UniverseSelector> get dynamicSetters => const <UniverseSelector>[]; 26 Iterable<UniverseSelector> get dynamicSetters => const <UniverseSelector>[];
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 add('is-checks', isChecks); 64 add('is-checks', isChecks);
62 add('checked-mode checks', checkedModeChecks); 65 add('checked-mode checks', checkedModeChecks);
63 add('as-casts', asCasts); 66 add('as-casts', asCasts);
64 add('closurized functions', closurizedFunctions); 67 add('closurized functions', closurizedFunctions);
65 add('closures', closures); 68 add('closures', closures);
66 add('type literals', typeLiterals); 69 add('type literals', typeLiterals);
67 70
68 return sb.toString(); 71 return sb.toString();
69 } 72 }
70 } 73 }
74
75 class WorldImpactBuilder {
76 // TODO(johnniwinther): Do we benefit from lazy initialization of the
77 // [Setlet]s?
78 Setlet<UniverseSelector> _dynamicInvocations;
79 Setlet<UniverseSelector> _dynamicGetters;
80 Setlet<UniverseSelector> _dynamicSetters;
81 Setlet<InterfaceType> _instantiatedTypes;
82 Setlet<Element> _staticUses;
83 Setlet<DartType> _isChecks;
84 Setlet<DartType> _asCasts;
85 Setlet<DartType> _checkedModeChecks;
86 Setlet<MethodElement> _closurizedFunctions;
87 Setlet<LocalFunctionElement> _closures;
88 Setlet<DartType> _typeLiterals;
89
90 void registerDynamicGetter(UniverseSelector selector) {
91 assert(selector != null);
92 if (_dynamicGetters == null) {
93 _dynamicGetters = new Setlet<UniverseSelector>();
94 }
95 _dynamicGetters.add(selector);
96 }
97
98 Iterable<UniverseSelector> get dynamicGetters {
99 return _dynamicGetters != null
100 ? _dynamicGetters : const <UniverseSelector>[];
101 }
102
103 void registerDynamicInvocation(UniverseSelector selector) {
104 assert(selector != null);
105 if (_dynamicInvocations == null) {
106 _dynamicInvocations = new Setlet<UniverseSelector>();
107 }
108 _dynamicInvocations.add(selector);
109 }
110
111 Iterable<UniverseSelector> get dynamicInvocations {
112 return _dynamicInvocations != null
113 ? _dynamicInvocations : const <UniverseSelector>[];
114 }
115
116 void registerDynamicSetter(UniverseSelector selector) {
117 assert(selector != null);
118 if (_dynamicSetters == null) {
119 _dynamicSetters = new Setlet<UniverseSelector>();
120 }
121 _dynamicSetters.add(selector);
122 }
123
124 Iterable<UniverseSelector> get dynamicSetters {
125 return _dynamicSetters != null
126 ? _dynamicSetters : const <UniverseSelector>[];
127 }
128
129 void registerInstantiatedType(InterfaceType type) {
130 assert(type != null);
131 if (_instantiatedTypes == null) {
132 _instantiatedTypes = new Setlet<InterfaceType>();
133 }
134 _instantiatedTypes.add(type);
135 }
136
137 Iterable<InterfaceType> get instantiatedTypes {
138 return _instantiatedTypes != null
139 ? _instantiatedTypes : const <InterfaceType>[];
140 }
141
142 void registerTypeLiteral(DartType type) {
143 assert(type != null);
144 if (_typeLiterals == null) {
145 _typeLiterals = new Setlet<DartType>();
146 }
147 _typeLiterals.add(type);
148 }
149
150 Iterable<DartType> get typeLiterals {
151 return _typeLiterals != null
152 ? _typeLiterals : const <DartType>[];
153 }
154
155 void registerStaticUse(Element element) {
156 assert(element != null);
157 if (_staticUses == null) {
158 _staticUses = new Setlet<Element>();
159 }
160 _staticUses.add(element);
161 }
162
163 Iterable<Element> get staticUses {
164 return _staticUses != null ? _staticUses : const <Element>[];
165 }
166
167 void registerIsCheck(DartType type) {
168 assert(type != null);
169 if (_isChecks == null) {
170 _isChecks = new Setlet<DartType>();
171 }
172 _isChecks.add(type);
173 }
174
175 Iterable<DartType> get isChecks {
176 return _isChecks != null
177 ? _isChecks : const <DartType>[];
178 }
179
180 void registerAsCast(DartType type) {
181 if (_asCasts == null) {
182 _asCasts = new Setlet<DartType>();
183 }
184 _asCasts.add(type);
185 }
186
187 Iterable<DartType> get asCasts {
188 return _asCasts != null
189 ? _asCasts : const <DartType>[];
190 }
191
192 void registerCheckedModeCheckedType(DartType type) {
193 if (_checkedModeChecks == null) {
194 _checkedModeChecks = new Setlet<DartType>();
195 }
196 _checkedModeChecks.add(type);
197 }
198
199 Iterable<DartType> get checkedModeChecks {
200 return _checkedModeChecks != null
201 ? _checkedModeChecks : const <DartType>[];
202 }
203
204 void registerClosurizedFunction(MethodElement element) {
205 if (_closurizedFunctions == null) {
206 _closurizedFunctions = new Setlet<MethodElement>();
207 }
208 _closurizedFunctions.add(element);
209 }
210
211 Iterable<MethodElement> get closurizedFunctions {
212 return _closurizedFunctions != null
213 ? _closurizedFunctions : const <MethodElement>[];
214 }
215
216 void registerClosure(LocalFunctionElement element) {
217 if (_closures == null) {
218 _closures = new Setlet<LocalFunctionElement>();
219 }
220 _closures.add(element);
221 }
222
223 Iterable<LocalFunctionElement> get closures {
224 return _closures != null
225 ? _closures : const <LocalFunctionElement>[];
226 }
227 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/registry.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698