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

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

Issue 693883003: Encode super calls via extra properties on prototypes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
Index: sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart
index 6c266153502120b97a67edcb207ad9877eaddfc2..1f7f2f5bcaacf40f99540200e3d89230b541160e 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart
@@ -308,9 +308,15 @@ class OldEmitter implements Emitter {
var inheritFrom = function() {
function tmp() {}
var hasOwnProperty = Object.prototype.hasOwnProperty;
- return function (constructor, superConstructor) {
+ return function (constructor, superConstructor, aliases) {
tmp.prototype = superConstructor.prototype;
var object = new tmp();
+ if (aliases) {
+ for (var pos = 0; pos < aliases.length; pos++) {
+ var member = aliases[pos].split(':');
+ object[member[0]] = object[member[1]];
+ }
+ }
var properties = constructor.prototype;
for (var member in properties)
if (hasOwnProperty.call(properties, member))
@@ -350,6 +356,7 @@ class OldEmitter implements Emitter {
return js('''
function(collectedClasses, isolateProperties, existingIsolateProperties) {
var pendingClasses = Object.create(null);
+ var pendingAliases = Object.create(null);
if (!#) # = Object.create(null); // embedded allClasses.
var allClasses = #; // embedded allClasses;
@@ -373,16 +380,17 @@ class OldEmitter implements Emitter {
if (desc instanceof Array) desc = desc[1];
/* The 'fields' are either a constructor function or a
- * string encoding fields, constructor and superclass. Get
- * the superclass and the fields in the format
- * '[name/]Super;field1,field2'
+ * string encoding fields, constructor, superclass and methods from
+ * the superclass that need aliasing. Get the superclass, fields
+ * and aliases in the format
+ * '[name/]Super;field1,field2;alias,alias2'
* from the CLASS_DESCRIPTOR_PROPERTY property on the descriptor.
* The 'name/' is optional and contains the name that should be used
* when printing the runtime type string. It is used, for example,
* to print the runtime type JSInt as 'int'.
*/
var classData = desc["${namer.classDescriptorProperty}"],
- supr, name = cls, fields = classData;
+ supr, name = cls, fields = classData, aliases = false;
if (#) // backend.hasRetainedMetadata
if (typeof classData == "object" &&
classData instanceof Array) {
@@ -398,7 +406,9 @@ class OldEmitter implements Emitter {
var s = fields.split(";");
fields = s[1] == "" ? [] : s[1].split(",");
+ if (s.length == 3) aliases = s[2].split(",");
supr = s[0];
+
split = supr.split(":");
if (split.length == 2) {
supr = split[0];
@@ -427,6 +437,7 @@ class OldEmitter implements Emitter {
constructorsList.push(cls);
}
if (supr) pendingClasses[cls] = supr;
+ if (aliases) pendingAliases[cls] = aliases;
}
if (typeof dart_precompiled != "function") {
@@ -497,6 +508,7 @@ class OldEmitter implements Emitter {
finishedClasses[cls] = true;
var superclass = pendingClasses[cls];
+ var aliases = pendingAliases[cls];
// The superclass is only false (empty string) for the Dart Object
// class. The minifier together with noSuchMethod can put methods on
@@ -510,7 +522,7 @@ class OldEmitter implements Emitter {
if (!superConstructor)
superConstructor = existingIsolateProperties[superclass];
- var prototype = inheritFrom(constructor, superConstructor);
+ var prototype = inheritFrom(constructor, superConstructor, aliases);
if (#) { // !nativeClasses.isEmpty,
// The property looks like this:

Powered by Google App Engine
This is Rietveld 408576698