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

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

Issue 878843003: Support enums in dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 11 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 | « pkg/compiler/lib/src/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/dart_backend/outputter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/dart_backend/backend_ast_to_frontend_ast.dart
diff --git a/pkg/compiler/lib/src/dart_backend/backend_ast_to_frontend_ast.dart b/pkg/compiler/lib/src/dart_backend/backend_ast_to_frontend_ast.dart
index c2381f685fec5cb1e3daeeb68daccd32bfdb6026..373ccfd41371b09a8ff9ab8362225da3afd68a8f 100644
--- a/pkg/compiler/lib/src/dart_backend/backend_ast_to_frontend_ast.dart
+++ b/pkg/compiler/lib/src/dart_backend/backend_ast_to_frontend_ast.dart
@@ -139,6 +139,7 @@ class TreePrinter {
final Token withToken = makeIdToken('with');
final Token implementsToken = makeIdToken('implements');
final Token typedefToken = makeIdToken('typedef');
+ final Token enumToken = makeIdToken('enum');
static tree.Identifier makeIdentifier(String name) {
return new tree.Identifier(
@@ -1060,6 +1061,8 @@ class TreePrinter {
tree.Node makeNodeForClassElement(elements.ClassElement cls) {
if (cls.isMixinApplication) {
return makeNamedMixinApplication(cls);
+ } else if (cls.isEnumClass) {
+ return makeEnum(cls);
} else {
return makeClassNode(cls);
}
@@ -1181,6 +1184,14 @@ class TreePrinter {
interfaces, classToken, semicolon);
}
+ tree.Enum makeEnum(elements.EnumClassElement cls) {
+ return new tree.Enum(
+ enumToken,
+ makeIdentifier(cls.name),
+ makeList(',', cls.enumValues.map((e) => makeIdentifier(e.name)),
+ open: openBrace, close: closeBrace));
+ }
+
/// Creates a [tree.ClassNode] node for [cls].
tree.ClassNode makeClassNode(elements.ClassElement cls) {
assert(dart2js.invariant(cls, !cls.isUnnamedMixinApplication,
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/dart_backend/outputter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698