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 11348317: Revert r15577 dart2js: Dot-separated field-and-super descriptor string... (Closed) Base URL: https://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
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
index bc8672a6997b23cf1a23b2ca53156cdc3f26b492..e081a178fa18f3a691edac9ed597760bf54c732e 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
@@ -135,12 +135,12 @@ class CodeEmitterTask extends CompilerTask {
}
String get defineClassFunction {
- // First the class name, then the field names in an array and the members
- // (inside an Object literal).
+ // First the class name, then the super class name, followed by the fields
+ // (in an array) and the members (inside an Object literal).
// The caller can also pass in the constructor as a function if needed.
//
// Example:
- // defineClass("A", ["x", "y"], {
+ // defineClass("A", "B", ["x", "y"], {
// foo$1: function(y) {
// print(this.x + y);
// },
@@ -214,12 +214,10 @@ function(collectedClasses) {
for (var cls in collectedClasses) {
if (hasOwnProperty.call(collectedClasses, cls)) {
var desc = collectedClasses[cls];
-'''/* Get the superclass and the fields in the format Super@field1.field2 from
- the null-string property on the descriptor. */'''
- var s = desc[''].split('@'), supr = s[0];
- var fields = s[1] == '' ? [] : s[1].split('.');
- $isolatePropertiesName[cls] = $defineClassName(cls, fields, desc);
- if (supr) $pendingClassesName[cls] = supr;
+'''/* If the class does not have any declared fields (in the ''
+ property of the description), then provide an empty list of fields. */'''
+ $isolatePropertiesName[cls] = $defineClassName(cls, desc[''] || [], desc);
+ if (desc['super'] !== "") $pendingClassesName[cls] = desc['super'];
}
}
var pendingClasses = $pendingClassesName;
@@ -250,7 +248,7 @@ function(collectedClasses) {
constructor.prototype = newPrototype;
newPrototype.constructor = constructor;
for (var member in prototype) {
- if (!member) continue; '''/* if (member == '') */'''
+ if (member == '' || member == 'super') continue;
if (hasOwnProperty.call(prototype, member)) {
newPrototype[member] = prototype[member];
}
@@ -828,47 +826,38 @@ $lazyInitializerLogic
void emitClassFields(ClassElement classElement,
CodeBuffer buffer,
- { String superClass: "",
- bool isNative: false,
- bool emitEndingComma: false}) {
- assert(!isNative || superClass != "");
+ bool emitEndingComma) {
bool isFirstField = true;
- bool isAnythingOutput = false;
- if (!isNative) {
- buffer.add('"":"$superClass@');
- isAnythingOutput = true;
- }
visitClassFields(classElement, (Element member,
String name,
bool needsGetter,
bool needsSetter,
bool needsCheckedSetter) {
+
if (!getterAndSetterCanBeImplementedByFieldSpec(
member, name, needsGetter, needsSetter)) {
return;
}
- if (!isNative || needsCheckedSetter || needsGetter || needsSetter) {
- if (isFirstField) {
- isFirstField = false;
- if (!isAnythingOutput) {
- buffer.add('"":"');
- isAnythingOutput = true;
- }
- } else {
- buffer.add(".");
- }
- buffer.add('$name');
- if (needsGetter && needsSetter) {
- buffer.add(GETTER_SETTER_SUFFIX);
- } else if (needsGetter) {
- buffer.add(GETTER_SUFFIX);
- } else if (needsSetter) {
- buffer.add(SETTER_SUFFIX);
- }
+
+ if (isFirstField) {
+ buffer.add('"": [');
+ isFirstField = false;
+ } else {
+ buffer.add(", ");
+ }
+ buffer.add('"$name');
+ if (needsGetter && needsSetter) {
+ buffer.add(GETTER_SETTER_SUFFIX);
+ } else if (needsGetter) {
+ buffer.add(GETTER_SUFFIX);
+ } else if (needsSetter) {
+ buffer.add(SETTER_SUFFIX);
}
- });
- if (isAnythingOutput) {
buffer.add('"');
+ });
+ if (!isFirstField) {
+ // There was at least one field.
+ buffer.add(']');
if (emitEndingComma) {
buffer.add(',');
}
@@ -958,12 +947,12 @@ $lazyInitializerLogic
buffer.add('$classesCollector.$className = {');
emitClassConstructor(classElement, buffer);
- emitClassFields(classElement, buffer, superClass: superName,
- isNative: false, emitEndingComma: false);
+ emitClassFields(classElement, buffer, true);
// TODO(floitsch): the emitInstanceMember should simply always emit a ',\n'.
// That does currently not work because the native classes have a different
// syntax.
- emitClassGettersSetters(classElement, buffer, false);
+ buffer.add('\n "super": "$superName"');
+ emitClassGettersSetters(classElement, buffer, true);
emitInstanceMembers(classElement, buffer, true);
buffer.add('\n};\n\n');
}
@@ -1171,10 +1160,11 @@ $lazyInitializerLogic
String superName,
String extraArgument,
CodeBuffer buffer) {
- extraArgument = extraArgument.isEmpty ? '' : ".$extraArgument";
+ extraArgument = extraArgument.isEmpty ? '' : ", '$extraArgument'";
buffer.add("""
$classesCollector.$mangledName = {'':
-\"$superName@self$extraArgument.target\",
+['self'$extraArgument, 'target'],
+'super': '$superName',
""");
}
« 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