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

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

Issue 707463003: Support enums in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. 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
« no previous file with comments | « pkg/compiler/lib/src/resolution/enum_creator.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/members.dart
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart
index 937d308a4afbc195fa6be76d78d86e5b2586eeb7..8159d4a009425f8b4df36f68828b86130de38d47 100644
--- a/pkg/compiler/lib/src/resolution/members.dart
+++ b/pkg/compiler/lib/src/resolution/members.dart
@@ -4335,6 +4335,26 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
return element.computeType(compiler);
}
+ @override
+ DartType visitEnum(Enum node) {
+ if (!compiler.enableEnums) {
+ compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS);
+ }
+
+ invariant(node, element != null);
+ invariant(element, element.resolutionState == STATE_STARTED,
+ message: () => 'cyclic resolution of class $element');
+
+ InterfaceType enumType = element.computeType(compiler);
+ element.supertype = compiler.objectClass.computeType(compiler);
+ element.interfaces = const Link<DartType>();
+ calculateAllSupertypes(element);
+
+ EnumCreator creator = new EnumCreator(compiler, element);
+ creator.createMembers();
+ return enumType;
+ }
+
/// Resolves the mixed type for [mixinNode] and checks that the the mixin type
/// is a valid, non-blacklisted interface type. The mixin type is returned.
DartType checkMixinType(TypeAnnotation mixinNode) {
@@ -4701,6 +4721,10 @@ class ClassSupertypeResolver extends CommonResolverVisitor {
visitNodeList(node.interfaces);
}
+ void visitEnum(Enum node) {
+ loadSupertype(compiler.objectClass, node);
+ }
+
void visitMixinApplication(MixinApplication node) {
node.superclass.accept(this);
visitNodeList(node.mixins);
« no previous file with comments | « pkg/compiler/lib/src/resolution/enum_creator.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698