| 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 */ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 abstract class WorkItem { | 25 abstract class WorkItem { |
| 26 final ItemCompilationContext compilationContext; | 26 final ItemCompilationContext compilationContext; |
| 27 /** | 27 /** |
| 28 * Documentation wanted -- johnniwinther | 28 * Documentation wanted -- johnniwinther |
| 29 * | 29 * |
| 30 * Invariant: [element] must be a declaration element. | 30 * Invariant: [element] must be a declaration element. |
| 31 */ | 31 */ |
| 32 final Element element; | 32 final Element element; |
| 33 TreeElements get resolutionTree; | 33 TreeElements resolutionTree; |
| 34 | 34 |
| 35 WorkItem(this.element, this.compilationContext) { | 35 WorkItem(this.element, this.compilationContext) { |
| 36 assert(invariant(element, element.isDeclaration)); | 36 assert(invariant(element, element.isDeclaration)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool isAnalyzed() => resolutionTree != null; | |
| 40 | 39 |
| 41 void run(Compiler compiler, Enqueuer world); | 40 void run(Compiler compiler, Enqueuer world); |
| 42 } | 41 } |
| 43 | 42 |
| 44 /// [WorkItem] used exclusively by the [ResolutionEnqueuer]. | 43 /// [WorkItem] used exclusively by the [ResolutionEnqueuer]. |
| 45 class ResolutionWorkItem extends WorkItem { | 44 class ResolutionWorkItem extends WorkItem { |
| 46 TreeElements resolutionTree; | |
| 47 | |
| 48 ResolutionWorkItem(Element element, | 45 ResolutionWorkItem(Element element, |
| 49 ItemCompilationContext compilationContext) | 46 ItemCompilationContext compilationContext) |
| 50 : super(element, compilationContext); | 47 : super(element, compilationContext); |
| 51 | 48 |
| 52 void run(Compiler compiler, ResolutionEnqueuer world) { | 49 void run(Compiler compiler, ResolutionEnqueuer world) { |
| 53 resolutionTree = compiler.analyze(this, world); | 50 resolutionTree = compiler.analyze(this, world); |
| 54 } | 51 } |
| 52 |
| 53 bool isAnalyzed() => resolutionTree != null; |
| 55 } | 54 } |
| 56 | 55 |
| 57 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. | 56 /// [WorkItem] used exclusively by the [CodegenEnqueuer]. |
| 58 class CodegenWorkItem extends WorkItem { | 57 class CodegenWorkItem extends WorkItem { |
| 59 final TreeElements resolutionTree; | |
| 60 | |
| 61 bool allowSpeculativeOptimization = true; | 58 bool allowSpeculativeOptimization = true; |
| 62 List<HTypeGuard> guards = const <HTypeGuard>[]; | 59 List<HTypeGuard> guards = const <HTypeGuard>[]; |
| 63 | 60 |
| 64 CodegenWorkItem(Element element, | 61 CodegenWorkItem(Element element, |
| 65 TreeElements this.resolutionTree, | |
| 66 ItemCompilationContext compilationContext) | 62 ItemCompilationContext compilationContext) |
| 67 : super(element, compilationContext) { | 63 : super(element, compilationContext); |
| 68 assert(invariant(element, resolutionTree != null, | |
| 69 message: 'Resolution tree is null for $element in codegen work item')); | |
| 70 } | |
| 71 | 64 |
| 72 void run(Compiler compiler, CodegenEnqueuer world) { | 65 void run(Compiler compiler, CodegenEnqueuer world) { |
| 73 if (world.isProcessed(element)) return; | 66 if (world.isProcessed(element)) return; |
| 67 resolutionTree = |
| 68 compiler.enqueuer.resolution.getCachedElements(element); |
| 74 compiler.codegen(this, world); | 69 compiler.codegen(this, world); |
| 75 } | 70 } |
| 76 } | 71 } |
| 77 | 72 |
| 78 typedef void PostProcessAction(); | 73 typedef void PostProcessAction(); |
| 79 | 74 |
| 80 class PostProcessTask { | 75 class PostProcessTask { |
| 81 final Element element; | 76 final Element element; |
| 82 final PostProcessAction action; | 77 final PostProcessAction action; |
| 83 | 78 |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 | 1365 |
| 1371 void close() {} | 1366 void close() {} |
| 1372 | 1367 |
| 1373 toString() => name; | 1368 toString() => name; |
| 1374 | 1369 |
| 1375 /// Convenience method for getting an [api.CompilerOutputProvider]. | 1370 /// Convenience method for getting an [api.CompilerOutputProvider]. |
| 1376 static NullSink outputProvider(String name, String extension) { | 1371 static NullSink outputProvider(String name, String extension) { |
| 1377 return new NullSink('$name.$extension'); | 1372 return new NullSink('$name.$extension'); |
| 1378 } | 1373 } |
| 1379 } | 1374 } |
| OLD | NEW |