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.common.codegen; | 5 library dart2js.common.codegen; |
6 | 6 |
7 import '../common.dart'; | |
8 import '../elements/elements.dart' | 7 import '../elements/elements.dart' |
9 show | 8 show AsyncMarker, ClassElement, LocalFunctionElement, MemberElement; |
10 AsyncMarker, | |
11 ClassElement, | |
12 LocalFunctionElement, | |
13 MemberElement, | |
14 ResolvedAst; | |
15 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
16 import '../elements/types.dart' show DartType, InterfaceType; | 10 import '../elements/types.dart' show DartType, InterfaceType; |
17 import '../js_backend/backend.dart' show JavaScriptBackend; | |
18 import '../universe/use.dart' show ConstantUse, DynamicUse, StaticUse, TypeUse; | 11 import '../universe/use.dart' show ConstantUse, DynamicUse, StaticUse, TypeUse; |
19 import '../universe/world_impact.dart' | 12 import '../universe/world_impact.dart' |
20 show WorldImpact, WorldImpactBuilderImpl, WorldImpactVisitor; | 13 show WorldImpact, WorldImpactBuilderImpl, WorldImpactVisitor; |
21 import '../util/enumset.dart'; | 14 import '../util/enumset.dart'; |
22 import '../util/util.dart' show Pair, Setlet; | 15 import '../util/util.dart' show Pair, Setlet; |
23 import '../world.dart' show ClosedWorld; | |
24 import 'work.dart' show WorkItem; | 16 import 'work.dart' show WorkItem; |
25 | 17 |
26 class CodegenImpact extends WorldImpact { | 18 class CodegenImpact extends WorldImpact { |
27 const CodegenImpact(); | 19 const CodegenImpact(); |
28 | 20 |
29 Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks { | 21 Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks { |
30 return const <Pair<DartType, DartType>>[]; | 22 return const <Pair<DartType, DartType>>[]; |
31 } | 23 } |
32 | 24 |
33 Iterable<String> get constSymbols => const <String>[]; | 25 Iterable<String> get constSymbols => const <String>[]; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 void registerInstantiation(InterfaceType type) { | 166 void registerInstantiation(InterfaceType type) { |
175 registerTypeUse(new TypeUse.instantiation(type)); | 167 registerTypeUse(new TypeUse.instantiation(type)); |
176 } | 168 } |
177 | 169 |
178 void registerAsyncMarker(AsyncMarker asyncMarker) { | 170 void registerAsyncMarker(AsyncMarker asyncMarker) { |
179 worldImpact.registerAsyncMarker(asyncMarker); | 171 worldImpact.registerAsyncMarker(asyncMarker); |
180 } | 172 } |
181 } | 173 } |
182 | 174 |
183 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. | 175 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. |
184 class CodegenWorkItem extends WorkItem { | 176 abstract class CodegenWorkItem extends WorkItem { |
185 CodegenRegistry registry; | 177 CodegenRegistry get registry; |
186 final ResolvedAst resolvedAst; | |
187 final JavaScriptBackend _backend; | |
188 final ClosedWorld _closedWorld; | |
189 | |
190 factory CodegenWorkItem(JavaScriptBackend backend, ClosedWorld closedWorld, | |
191 MemberElement element) { | |
192 // If this assertion fails, the resolution callbacks of the backend may be | |
193 // missing call of form registry.registerXXX. Alternatively, the code | |
194 // generation could spuriously be adding dependencies on things we know we | |
195 // don't need. | |
196 assert(invariant(element, element.hasResolvedAst, | |
197 message: "$element has no resolved ast.")); | |
198 ResolvedAst resolvedAst = element.resolvedAst; | |
199 return new CodegenWorkItem.internal(resolvedAst, backend, closedWorld); | |
200 } | |
201 | |
202 CodegenWorkItem.internal(this.resolvedAst, this._backend, this._closedWorld); | |
203 | |
204 MemberElement get element => resolvedAst.element; | |
205 | |
206 WorldImpact run() { | |
207 registry = new CodegenRegistry(element); | |
208 return _backend.codegen(this, _closedWorld); | |
209 } | |
210 | |
211 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; | |
212 } | 178 } |
OLD | NEW |