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

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

Issue 878843003: Support enums in dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
Index: pkg/compiler/lib/src/dart_backend/outputter.dart
diff --git a/pkg/compiler/lib/src/dart_backend/outputter.dart b/pkg/compiler/lib/src/dart_backend/outputter.dart
index 45da8e904ebdb97053f18b2c7a2573517050293d..9838c885446e70b8070c45e460f93178bff4fc8a 100644
--- a/pkg/compiler/lib/src/dart_backend/outputter.dart
+++ b/pkg/compiler/lib/src/dart_backend/outputter.dart
@@ -162,7 +162,7 @@ class DartOutputter {
makePlaceholders(element) {
collector.collect(element);
- if (element.isClass) {
+ if (element.isClass && !element.isEnumClass) {
elementInfo.classMembers[element].forEach(makePlaceholders);
}
}
@@ -276,6 +276,7 @@ class LibraryInfo {
}
}
}
+
// As of now names of named optionals are not renamed. Therefore add all
// field names used as named optionals into [fixedMemberNames].
for (final element in resolvedElements) {
@@ -286,6 +287,10 @@ class LibraryInfo {
if (!optional.isInitializingFormal) continue;
fixedDynamicNames.add(optional.name);
}
+ ClassElement cls = element.enclosingClass;
+ if (cls != null && cls.isEnumClass) {
+ fixedDynamicNames.add('index');
+ }
}
// The VM will automatically invoke the call method of objects
// that are invoked as functions. Make sure to not rename that.
@@ -409,7 +414,6 @@ class ElementInfoProcessor implements ElementInfo {
}
void addMember(element) {
- ElementAst elementAst = parseElementAst(element);
if (element.isClassMember) {
ClassElement enclosingClass = element.enclosingClass;
assert(enclosingClass.isClass);
@@ -417,10 +421,11 @@ class ElementInfoProcessor implements ElementInfo {
assert(shouldOutput(enclosingClass));
addClass(enclosingClass);
classMembers[enclosingClass].add(element);
- processElement(element, elementAst);
+ if (enclosingClass.isEnumClass) return;
+ processElement(element, parseElementAst(element));
} else {
if (element.isTopLevel) {
- addTopLevel(element, elementAst);
+ addTopLevel(element, parseElementAst(element));
}
}
}
@@ -448,12 +453,16 @@ class MainOutputGenerator {
bool enableMinification: false}) {
for (Element element in elementInfo.topLevelElements) {
topLevelNodes.add(elementInfo.elementAsts[element].ast);
- if (element.isClass && !element.isMixinApplication) {
+ if (element.isClass) {
+ ClassElement cls = element;
+ if (cls.isMixinApplication || cls.isEnumClass) {
+ continue;
+ }
final members = <Node>[];
- for (Element member in elementInfo.classMembers[element]) {
+ for (Element member in elementInfo.classMembers[cls]) {
members.add(elementInfo.elementAsts[member].ast);
}
- memberNodes[elementInfo.elementAsts[element].ast] = members;
+ memberNodes[elementInfo.elementAsts[cls].ast] = members;
}
}

Powered by Google App Engine
This is Rietveld 408576698