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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 11415114: Do not generate empty native classes. Fixes issue 6872. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « no previous file | sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (revision 15244)
+++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy)
@@ -236,7 +236,7 @@
for (var cls in collectedClasses) {
if (hasOwnProperty.call(collectedClasses, cls)) {
var desc = collectedClasses[cls];
- $isolatePropertiesName[cls] = $defineClassName(cls, desc[''], desc);
+ $isolatePropertiesName[cls] = $defineClassName(cls, desc[''] || [], desc);
ahe 2012/11/22 12:22:05 I suggest that you use string juxtaposition to get
ngeoffray 2012/11/22 13:15:18 Done.
if (desc['super'] !== "") $pendingClassesName[cls] = desc['super'];
}
}
@@ -671,12 +671,11 @@
*/
void emitInstanceMembers(ClassElement classElement,
CodeBuffer buffer,
- bool needsLeadingComma) {
+ {bool emitLeadingComma: true}) {
ahe 2012/11/22 12:22:05 Why is this a named argument now?
ngeoffray 2012/11/22 13:15:18 It was to make it consistent with the other method
assert(invariant(classElement, classElement.isDeclaration));
- bool needsComma = needsLeadingComma;
void defineInstanceMember(String name, StringBuffer memberBuffer) {
- if (needsComma) buffer.add(',');
- needsComma = true;
+ if (emitLeadingComma) buffer.add(',');
+ emitLeadingComma = true;
buffer.add('\n');
buffer.add(' $name: ');
buffer.add(memberBuffer);
@@ -846,8 +845,9 @@
/* Do nothing. */
}
- void emitClassFields(ClassElement classElement, CodeBuffer buffer) {
- buffer.add('"": [');
+ void emitClassFields(ClassElement classElement,
+ CodeBuffer buffer,
+ {bool emitEndingComma: true}) {
ahe 2012/11/22 12:22:05 I think it would be better to update all the calle
ngeoffray 2012/11/22 13:15:18 Done.
bool isFirstField = true;
visitClassFields(classElement, (Element member,
String name,
@@ -856,6 +856,7 @@
bool needsSetter,
bool needsCheckedSetter) {
if (isFirstField) {
+ buffer.add('"": [');
isFirstField = false;
} else {
buffer.add(", ");
@@ -876,12 +877,18 @@
}
buffer.add('"');
});
- buffer.add(']');
+ if (!isFirstField) {
+ // There was at least one field.
+ buffer.add(']');
+ if (emitEndingComma) {
+ buffer.add(', ');
+ }
+ }
}
/** Each getter/setter must be prefixed with a ",\n ". */
void emitClassGettersSetters(ClassElement classElement, CodeBuffer buffer,
- {bool omitLeadingComma: false}) {
+ {bool emitLeadingComma: true}) {
visitClassFields(classElement, (Element member,
String name,
String accessorName,
@@ -890,10 +897,10 @@
bool needsCheckedSetter) {
if (needsCheckedSetter) {
assert(!needsSetter);
- if (!omitLeadingComma) {
+ if (emitLeadingComma) {
buffer.add(",\n ");
} else {
- omitLeadingComma = false;
+ emitLeadingComma = true;
}
generateCheckedSetter(member, name, accessorName, buffer);
}
@@ -931,9 +938,9 @@
// TODO(floitsch): the emitInstanceMember should simply always emit a ',\n'.
// That does currently not work because the native classes have a different
// syntax.
- buffer.add(',\n "super": "$superName"');
+ buffer.add('\n "super": "$superName"');
emitClassGettersSetters(classElement, buffer);
- emitInstanceMembers(classElement, buffer, true);
+ emitInstanceMembers(classElement, buffer);
buffer.add('\n};\n\n');
}
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698