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 assert(invariant(element, |
asgerf
2015/05/06 12:57:39
Maybe we should add a comment explaining in more d
Johnni Winther
2015/05/07 13:23:08
Done.
| |
196 compiler.enqueuer.resolution.hasBeenResolved(element), | |
197 message: "$element has not been resolved.")); | |
198 assert(invariant(element, element.resolvedAst.elements != null, | |
196 message: 'Resolution tree is null for $element in codegen work item')); | 199 message: 'Resolution tree is null for $element in codegen work item')); |
200 return new CodegenWorkItem.internal(element, compilationContext); | |
197 } | 201 } |
198 | 202 |
203 CodegenWorkItem.internal( | |
204 AstElement element, | |
205 ItemCompilationContext compilationContext) | |
206 : super(element, compilationContext); | |
207 | |
208 TreeElements get resolutionTree => element.resolvedAst.elements; | |
209 | |
199 void run(Compiler compiler, CodegenEnqueuer world) { | 210 void run(Compiler compiler, CodegenEnqueuer world) { |
200 if (world.isProcessed(element)) return; | 211 if (world.isProcessed(element)) return; |
201 | 212 |
202 registry = new CodegenRegistry(compiler, resolutionTree); | 213 registry = new CodegenRegistry(compiler, resolutionTree); |
203 compiler.codegen(this, world); | 214 compiler.codegen(this, world); |
204 } | 215 } |
205 } | 216 } |
206 | 217 |
207 typedef void DeferredAction(); | 218 typedef void DeferredAction(); |
208 | 219 |
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2433 return futureClass.computeType(compiler).createInstantiation([elementType]); | 2444 return futureClass.computeType(compiler).createInstantiation([elementType]); |
2434 } | 2445 } |
2435 | 2446 |
2436 @override | 2447 @override |
2437 InterfaceType streamType([DartType elementType = const DynamicType()]) { | 2448 InterfaceType streamType([DartType elementType = const DynamicType()]) { |
2438 return streamClass.computeType(compiler).createInstantiation([elementType]); | 2449 return streamClass.computeType(compiler).createInstantiation([elementType]); |
2439 } | 2450 } |
2440 } | 2451 } |
2441 | 2452 |
2442 typedef void InternalErrorFunction(Spannable location, String message); | 2453 typedef void InternalErrorFunction(Spannable location, String message); |
OLD | NEW |