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

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

Issue 762213002: Support top-level field declaration and assignment in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years 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
Index: pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart
index ca3253c994529ff788d7cd81c407b33be2b3d97e..6dc960f1dddabbc44e3c5977c2bdec76332f1b7f 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart
@@ -567,6 +567,25 @@ class FieldDefinition extends Node implements ExecutableDefinition {
FieldDefinition(this.element, this.body);
applyPass(Pass pass) => pass.rewriteFieldDefinition(this);
+
+ /// `true` if this field has no initializer.
+ ///
+ /// If `true` [body] is `null`.
+ ///
+ /// This is different from a initializer that is `null`. Consider this class:
+ ///
+ /// class Class {
+ /// final field;
+ /// Class.a(this.field);
+ /// Class.b() : this.field = null;
+ /// Class.c();
+ /// }
+ ///
+ /// If `field` had an initializer, possibly `null`, constructors `Class.a` and
+ /// `Class.b` would be invalid, and since `field` has no initializer
+ /// constructor `Class.c` is invalid. We therefore need to distinguish the two
+ /// cases.
+ bool get hasInitializer => body != null;
}
class FunctionDefinition extends Node implements ExecutableDefinition {
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart ('k') | tests/compiler/dart2js/backend_dart/sexpr2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698