| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| 11 const bool REPORT_EXCESS_RESOLUTION = false; | 11 const bool REPORT_EXCESS_RESOLUTION = false; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Contains backend-specific data that is used throughout the compilation of | 14 * Contains backend-specific data that is used throughout the compilation of |
| 15 * one work item. | 15 * one work item. |
| 16 */ | 16 */ |
| 17 class ItemCompilationContext { | 17 class ItemCompilationContext { |
| 18 } | 18 } |
| 19 | 19 |
| 20 abstract class WorkItem { | 20 abstract class WorkItem { |
| 21 final ItemCompilationContext compilationContext; | 21 final ItemCompilationContext compilationContext; |
| 22 /** | 22 /** |
| 23 * Documentation wanted -- johnniwinther | 23 * Documentation wanted -- johnniwinther |
| 24 * | 24 * |
| 25 * Invariant: [element] must be a declaration element. | 25 * Invariant: [element] must be a declaration element. |
| 26 */ | 26 */ |
| 27 final AstElement element; | 27 final AstElement element; |
| 28 |
| 28 TreeElements get resolutionTree; | 29 TreeElements get resolutionTree; |
| 29 | 30 |
| 30 WorkItem(this.element, this.compilationContext) { | 31 WorkItem(this.element, this.compilationContext) { |
| 31 assert(invariant(element, element.isDeclaration)); | 32 assert(invariant(element, element.isDeclaration)); |
| 32 } | 33 } |
| 33 | 34 |
| 34 void run(Compiler compiler, Enqueuer world); | 35 void run(Compiler compiler, Enqueuer world); |
| 35 } | 36 } |
| 36 | 37 |
| 37 /// [WorkItem] used exclusively by the [ResolutionEnqueuer]. | 38 /// [WorkItem] used exclusively by the [ResolutionEnqueuer]. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 180 |
| 180 void registerAsyncMarker(FunctionElement element) { | 181 void registerAsyncMarker(FunctionElement element) { |
| 181 backend.registerAsyncMarker(element, world, this); | 182 backend.registerAsyncMarker(element, world, this); |
| 182 } | 183 } |
| 183 | 184 |
| 184 } | 185 } |
| 185 | 186 |
| 186 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. | 187 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. |
| 187 class CodegenWorkItem extends WorkItem { | 188 class CodegenWorkItem extends WorkItem { |
| 188 Registry registry; | 189 Registry registry; |
| 189 final TreeElements resolutionTree; | |
| 190 | 190 |
| 191 CodegenWorkItem(AstElement element, | 191 factory CodegenWorkItem( |
| 192 ItemCompilationContext compilationContext) | 192 Compiler compiler, |
| 193 : this.resolutionTree = element.resolvedAst.elements, | 193 AstElement element, |
| 194 super(element, compilationContext) { | 194 ItemCompilationContext compilationContext) { |
| 195 assert(invariant(element, resolutionTree != null, | 195 // If this assertion fails, the resolution callbacks of the backend may be |
| 196 // missing call of form registry.registerXXX. Alternatively, the code |
| 197 // generation could spuriously be adding dependencies on things we know we |
| 198 // don't need. |
| 199 assert(invariant(element, |
| 200 compiler.enqueuer.resolution.hasBeenResolved(element), |
| 201 message: "$element has not been resolved.")); |
| 202 assert(invariant(element, element.resolvedAst.elements != null, |
| 196 message: 'Resolution tree is null for $element in codegen work item')); | 203 message: 'Resolution tree is null for $element in codegen work item')); |
| 204 return new CodegenWorkItem.internal(element, compilationContext); |
| 197 } | 205 } |
| 198 | 206 |
| 207 CodegenWorkItem.internal( |
| 208 AstElement element, |
| 209 ItemCompilationContext compilationContext) |
| 210 : super(element, compilationContext); |
| 211 |
| 212 TreeElements get resolutionTree => element.resolvedAst.elements; |
| 213 |
| 199 void run(Compiler compiler, CodegenEnqueuer world) { | 214 void run(Compiler compiler, CodegenEnqueuer world) { |
| 200 if (world.isProcessed(element)) return; | 215 if (world.isProcessed(element)) return; |
| 201 | 216 |
| 202 registry = new CodegenRegistry(compiler, resolutionTree); | 217 registry = new CodegenRegistry(compiler, resolutionTree); |
| 203 compiler.codegen(this, world); | 218 compiler.codegen(this, world); |
| 204 } | 219 } |
| 205 } | 220 } |
| 206 | 221 |
| 207 typedef void DeferredAction(); | 222 typedef void DeferredAction(); |
| 208 | 223 |
| (...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2433 return futureClass.computeType(compiler).createInstantiation([elementType]); | 2448 return futureClass.computeType(compiler).createInstantiation([elementType]); |
| 2434 } | 2449 } |
| 2435 | 2450 |
| 2436 @override | 2451 @override |
| 2437 InterfaceType streamType([DartType elementType = const DynamicType()]) { | 2452 InterfaceType streamType([DartType elementType = const DynamicType()]) { |
| 2438 return streamClass.computeType(compiler).createInstantiation([elementType]); | 2453 return streamClass.computeType(compiler).createInstantiation([elementType]); |
| 2439 } | 2454 } |
| 2440 } | 2455 } |
| 2441 | 2456 |
| 2442 typedef void InternalErrorFunction(Spannable location, String message); | 2457 typedef void InternalErrorFunction(Spannable location, String message); |
| OLD | NEW |