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

Unified Diff: sdk/lib/_internal/compiler/implementation/tree/nodes.dart

Issue 698563005: Support parsing of enums in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add unparser test. Created 6 years, 1 month 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: sdk/lib/_internal/compiler/implementation/tree/nodes.dart
diff --git a/sdk/lib/_internal/compiler/implementation/tree/nodes.dart b/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
index 5bb147e3b8d9ecf4beea419b4cc7539be7637bce..3ec51ac872906b71783b5f8f4429cf4e1924b411 100644
--- a/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
+++ b/sdk/lib/_internal/compiler/implementation/tree/nodes.dart
@@ -21,6 +21,7 @@ abstract class Visitor<R> {
R visitContinueStatement(ContinueStatement node) => visitGotoStatement(node);
R visitDoWhile(DoWhile node) => visitLoop(node);
R visitEmptyStatement(EmptyStatement node) => visitStatement(node);
+ R visitEnum(Enum node) => visitNode(node);
R visitExport(Export node) => visitLibraryDependency(node);
R visitExpression(Expression node) => visitNode(node);
R visitExpressionStatement(ExpressionStatement node) => visitStatement(node);
@@ -153,6 +154,7 @@ abstract class Node extends NullTreeElementMixin implements Spannable {
ContinueStatement asContinueStatement() => null;
DoWhile asDoWhile() => null;
EmptyStatement asEmptyStatement() => null;
+ Enum asEnum() => null;
ErrorExpression asErrorExpression() => null;
Export asExport() => null;
Expression asExpression() => null;
@@ -1851,6 +1853,33 @@ class Import extends LibraryDependency {
}
/**
+ * An `enum` declaration.
+ *
+ * An `enum` defines a number of named constants inside a non-extensible class
+ */
+class Enum extends Node {
+ /** The name of the enum class. */
+ final Identifier name;
+ /** The names of the enum constants. */
+ final NodeList names;
+ final Token enumToken;
+
+ Enum(this.enumToken, this.name, this.names);
+
+ Enum asEnum() => this;
+
+ accept(Visitor visitor) => visitor.visitEnum(this);
+
+ visitChildren(Visitor visitor) {
+ name.accept(visitor);
+ if (names != null) names.accept(visitor);
+ }
+
+ Token getBeginToken() => enumToken;
+ Token getEndToken() => names.getEndToken();
+}
+
+/**
* An [:export:] library tag.
*
* An export tag is dependency on another library where the exported identifiers

Powered by Google App Engine
This is Rietveld 408576698