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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 AnalyzableElement get analyzedElement; 8 AnalyzableElement get analyzedElement;
9 Iterable<Node> get superUses; 9 Iterable<Node> get superUses;
10 10
(...skipping 4317 matching lines...) Expand 10 before | Expand all | Expand 10 after
4328 superMember = new ErroneousElementX(kind, {}, '', element); 4328 superMember = new ErroneousElementX(kind, {}, '', element);
4329 } 4329 }
4330 } 4330 }
4331 FunctionElement constructor = 4331 FunctionElement constructor =
4332 new SynthesizedConstructorElementX.forDefault(superMember, element); 4332 new SynthesizedConstructorElementX.forDefault(superMember, element);
4333 element.setDefaultConstructor(constructor, compiler); 4333 element.setDefaultConstructor(constructor, compiler);
4334 } 4334 }
4335 return element.computeType(compiler); 4335 return element.computeType(compiler);
4336 } 4336 }
4337 4337
4338 @override
4339 DartType visitEnum(Enum node) {
4340 if (!compiler.enableEnums) {
4341 compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS);
4342 }
4343
4344 invariant(node, element != null);
4345 invariant(element, element.resolutionState == STATE_STARTED,
4346 message: () => 'cyclic resolution of class $element');
4347
4348 InterfaceType enumType = element.computeType(compiler);
4349 element.supertype = compiler.objectClass.computeType(compiler);
4350 element.interfaces = const Link<DartType>();
4351 calculateAllSupertypes(element);
4352
4353 EnumCreator creator = new EnumCreator(compiler, element);
4354 creator.createMembers();
4355 return enumType;
4356 }
4357
4338 /// Resolves the mixed type for [mixinNode] and checks that the the mixin type 4358 /// Resolves the mixed type for [mixinNode] and checks that the the mixin type
4339 /// is a valid, non-blacklisted interface type. The mixin type is returned. 4359 /// is a valid, non-blacklisted interface type. The mixin type is returned.
4340 DartType checkMixinType(TypeAnnotation mixinNode) { 4360 DartType checkMixinType(TypeAnnotation mixinNode) {
4341 DartType mixinType = resolveType(mixinNode); 4361 DartType mixinType = resolveType(mixinNode);
4342 if (isBlackListed(mixinType)) { 4362 if (isBlackListed(mixinType)) {
4343 compiler.reportError(mixinNode, 4363 compiler.reportError(mixinNode,
4344 MessageKind.CANNOT_MIXIN, {'type': mixinType}); 4364 MessageKind.CANNOT_MIXIN, {'type': mixinType});
4345 } else if (mixinType.isTypeVariable) { 4365 } else if (mixinType.isTypeVariable) {
4346 compiler.reportError(mixinNode, MessageKind.CLASS_NAME_EXPECTED); 4366 compiler.reportError(mixinNode, MessageKind.CLASS_NAME_EXPECTED);
4347 } else if (mixinType.isMalformed) { 4367 } else if (mixinType.isMalformed) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 if (node.superclass == null) { 4714 if (node.superclass == null) {
4695 if (!identical(classElement, compiler.objectClass)) { 4715 if (!identical(classElement, compiler.objectClass)) {
4696 loadSupertype(compiler.objectClass, node); 4716 loadSupertype(compiler.objectClass, node);
4697 } 4717 }
4698 } else { 4718 } else {
4699 node.superclass.accept(this); 4719 node.superclass.accept(this);
4700 } 4720 }
4701 visitNodeList(node.interfaces); 4721 visitNodeList(node.interfaces);
4702 } 4722 }
4703 4723
4724 void visitEnum(Enum node) {
4725 loadSupertype(compiler.objectClass, node);
4726 }
4727
4704 void visitMixinApplication(MixinApplication node) { 4728 void visitMixinApplication(MixinApplication node) {
4705 node.superclass.accept(this); 4729 node.superclass.accept(this);
4706 visitNodeList(node.mixins); 4730 visitNodeList(node.mixins);
4707 } 4731 }
4708 4732
4709 void visitNamedMixinApplication(NamedMixinApplication node) { 4733 void visitNamedMixinApplication(NamedMixinApplication node) {
4710 node.superclass.accept(this); 4734 node.superclass.accept(this);
4711 visitNodeList(node.mixins); 4735 visitNodeList(node.mixins);
4712 visitNodeList(node.interfaces); 4736 visitNodeList(node.interfaces);
4713 } 4737 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
5045 } 5069 }
5046 5070
5047 /// The result for the resolution of the `assert` method. 5071 /// The result for the resolution of the `assert` method.
5048 class AssertResult implements ResolutionResult { 5072 class AssertResult implements ResolutionResult {
5049 const AssertResult(); 5073 const AssertResult();
5050 5074
5051 Element get element => null; 5075 Element get element => null;
5052 5076
5053 String toString() => 'AssertResult()'; 5077 String toString() => 'AssertResult()';
5054 } 5078 }
OLDNEW
« 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