| 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'; | 7 import '../common.dart'; |
| 8 import '../common/backend_api.dart' show Backend; | |
| 9 import '../constants/values.dart' show ConstantValue; | 8 import '../constants/values.dart' show ConstantValue; |
| 10 import '../elements/resolution_types.dart' | 9 import '../elements/resolution_types.dart' |
| 11 show ResolutionDartType, ResolutionInterfaceType; | 10 show ResolutionDartType, ResolutionInterfaceType; |
| 12 import '../elements/elements.dart' | 11 import '../elements/elements.dart' |
| 13 show | 12 show |
| 14 AstElement, | 13 AstElement, |
| 15 ClassElement, | 14 ClassElement, |
| 16 Element, | 15 Element, |
| 17 FunctionElement, | 16 FunctionElement, |
| 18 LocalFunctionElement, | 17 LocalFunctionElement, |
| 19 ResolvedAst; | 18 ResolvedAst; |
| 19 import '../js_backend/backend.dart' show JavaScriptBackend; |
| 20 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse; | 20 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse; |
| 21 import '../universe/world_impact.dart' | 21 import '../universe/world_impact.dart' |
| 22 show WorldImpact, WorldImpactBuilderImpl, WorldImpactVisitor; | 22 show WorldImpact, WorldImpactBuilderImpl, WorldImpactVisitor; |
| 23 import '../util/util.dart' show Pair, Setlet; | 23 import '../util/util.dart' show Pair, Setlet; |
| 24 import 'work.dart' show WorkItem; | 24 import 'work.dart' show WorkItem; |
| 25 | 25 |
| 26 class CodegenImpact extends WorldImpact { | 26 class CodegenImpact extends WorldImpact { |
| 27 const CodegenImpact(); | 27 const CodegenImpact(); |
| 28 | 28 |
| 29 Iterable<ConstantValue> get compileTimeConstants => const <ConstantValue>[]; | 29 Iterable<ConstantValue> get compileTimeConstants => const <ConstantValue>[]; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 void registerAsyncMarker(FunctionElement element) { | 219 void registerAsyncMarker(FunctionElement element) { |
| 220 worldImpact.registerAsyncMarker(element); | 220 worldImpact.registerAsyncMarker(element); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. | 224 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. |
| 225 class CodegenWorkItem extends WorkItem { | 225 class CodegenWorkItem extends WorkItem { |
| 226 CodegenRegistry registry; | 226 CodegenRegistry registry; |
| 227 final ResolvedAst resolvedAst; | 227 final ResolvedAst resolvedAst; |
| 228 final Backend backend; | 228 final JavaScriptBackend backend; |
| 229 | 229 |
| 230 factory CodegenWorkItem(Backend backend, AstElement element) { | 230 factory CodegenWorkItem(JavaScriptBackend backend, AstElement element) { |
| 231 // If this assertion fails, the resolution callbacks of the backend may be | 231 // If this assertion fails, the resolution callbacks of the backend may be |
| 232 // missing call of form registry.registerXXX. Alternatively, the code | 232 // missing call of form registry.registerXXX. Alternatively, the code |
| 233 // generation could spuriously be adding dependencies on things we know we | 233 // generation could spuriously be adding dependencies on things we know we |
| 234 // don't need. | 234 // don't need. |
| 235 assert(invariant(element, element.hasResolvedAst, | 235 assert(invariant(element, element.hasResolvedAst, |
| 236 message: "$element has no resolved ast.")); | 236 message: "$element has no resolved ast.")); |
| 237 ResolvedAst resolvedAst = element.resolvedAst; | 237 ResolvedAst resolvedAst = element.resolvedAst; |
| 238 return new CodegenWorkItem.internal(resolvedAst, backend); | 238 return new CodegenWorkItem.internal(resolvedAst, backend); |
| 239 } | 239 } |
| 240 | 240 |
| 241 CodegenWorkItem.internal(ResolvedAst resolvedAst, this.backend) | 241 CodegenWorkItem.internal(ResolvedAst resolvedAst, this.backend) |
| 242 : this.resolvedAst = resolvedAst, | 242 : this.resolvedAst = resolvedAst, |
| 243 super(resolvedAst.element); | 243 super(resolvedAst.element); |
| 244 | 244 |
| 245 WorldImpact run() { | 245 WorldImpact run() { |
| 246 registry = new CodegenRegistry(element); | 246 registry = new CodegenRegistry(element); |
| 247 return backend.codegen(this); | 247 return backend.codegen(this); |
| 248 } | 248 } |
| 249 | 249 |
| 250 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; | 250 String toString() => 'CodegenWorkItem(${resolvedAst.element})'; |
| 251 } | 251 } |
| OLD | NEW |