Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| index 80a6e7402377046c8c993bf782297cc4238b25b6..5ffda9a0c5caaf65b120032c35e0aa75a1cdf006 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| @@ -360,6 +360,26 @@ class OldEmitter implements Emitter { |
| finishedClassesAccess]); |
| } |
| + List buildSplitOffAliases() { |
|
ahe
2014/11/25 09:33:03
If you follow my suggestion in container_builder.d
herhut
2014/11/25 14:03:19
Done.
|
| + if (backend.aliasedSuperMembers.isEmpty) return []; |
| + return [js(r''' |
| + var splitOffAliases = function(constructor) { |
| + var hasOwnProperty = Object.prototype.hasOwnProperty; |
| + var properties = constructor.prototype; |
| + for (var member in properties) { |
| + if (hasOwnProperty.call(properties, member)) { |
| + var s = member.split(':'); |
| + if (s.length > 1) { |
| + properties[s[0]] = properties[s[1]] = properties[member]; |
| + properties[s[1]].$aliasName = s[1]; |
| + delete properties[member]; |
| + } |
| + } |
| + } |
| + } |
| + ''')]; |
| + } |
| + |
| jsAst.Fun get finishClassesFunction { |
| // Class descriptions are collected in a JS object. |
| // 'finishClasses' takes all collected descriptions and sets up |
| @@ -516,6 +536,11 @@ class OldEmitter implements Emitter { |
| finishedClasses[cls] = true; |
| var superclass = pendingClasses[cls]; |
| + var constructor = allClasses[cls]; |
| + |
| + // Process aliased members due to super calls. We have to do this early |
| + // to ensure that we also hit the object class. |
| + if (#) splitOffAliases(constructor); |
|
floitsch
2014/11/24 10:47:52
Please change this to named js-holes. (you will ne
ahe
2014/11/25 09:33:03
Awesome. I needed that :-)
herhut
2014/11/25 14:03:19
Done.
herhut
2014/11/25 14:03:19
Acknowledged.
|
| // The superclass is only false (empty string) for the Dart Object |
| // class. The minifier together with noSuchMethod can put methods on |
| @@ -523,7 +548,6 @@ class OldEmitter implements Emitter { |
| // that we have a string. |
| if (!superclass || typeof superclass != "string") return; |
| finishClass(superclass); |
| - var constructor = allClasses[cls]; |
| var superConstructor = allClasses[superclass]; |
| if (!superConstructor) |
| @@ -582,6 +606,7 @@ class OldEmitter implements Emitter { |
| } |
| } |
| }''', [finishedClassesAccess, |
| + backend.aliasedSuperMembers.isNotEmpty, |
| !nativeClasses.isEmpty, |
| interceptorsByTagAccess, |
| leafTagsAccess, |
| @@ -693,6 +718,7 @@ class OldEmitter implements Emitter { |
| if (!needsDefineClass) return []; |
| return defineClassFunction |
| ..add(buildInheritFrom()) |
| + ..addAll(buildSplitOffAliases()) |
| ..add(js('$finishClassesName = #', finishClassesFunction)) |
| ..add(initFinishClasses); |
| } |