Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: pkg/compiler/lib/src/compiler.dart

Issue 1126163002: Improve resolution/codegen separation invariant. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/enqueue.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/compiler.dart
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 4671212ffad60e10fdac870bc96917479810655b..192712620b9aac1281abe4c112c0078fb1107769 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -25,6 +25,7 @@ abstract class WorkItem {
* Invariant: [element] must be a declaration element.
*/
final AstElement element;
+
TreeElements get resolutionTree;
WorkItem(this.element, this.compilationContext) {
@@ -186,16 +187,30 @@ class CodegenRegistry extends Registry {
/// [WorkItem] used exclusively by the [CodegenEnqueuer].
class CodegenWorkItem extends WorkItem {
Registry registry;
- final TreeElements resolutionTree;
- CodegenWorkItem(AstElement element,
- ItemCompilationContext compilationContext)
- : this.resolutionTree = element.resolvedAst.elements,
- super(element, compilationContext) {
- assert(invariant(element, resolutionTree != null,
+ factory CodegenWorkItem(
+ Compiler compiler,
+ AstElement element,
+ ItemCompilationContext compilationContext) {
+ // If this assertion fails, the resolution callbacks of the backend may be
+ // missing call of form registry.registerXXX. Alternatively, the code
+ // generation could spuriously be adding dependencies on things we know we
+ // don't need.
+ assert(invariant(element,
+ compiler.enqueuer.resolution.hasBeenResolved(element),
+ message: "$element has not been resolved."));
+ assert(invariant(element, element.resolvedAst.elements != null,
message: 'Resolution tree is null for $element in codegen work item'));
+ return new CodegenWorkItem.internal(element, compilationContext);
}
+ CodegenWorkItem.internal(
+ AstElement element,
+ ItemCompilationContext compilationContext)
+ : super(element, compilationContext);
+
+ TreeElements get resolutionTree => element.resolvedAst.elements;
+
void run(Compiler compiler, CodegenEnqueuer world) {
if (world.isProcessed(element)) return;
« no previous file with comments | « no previous file | pkg/compiler/lib/src/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698