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

Unified Diff: tool/input_sdk/private/ddc_runtime/classes.dart

Issue 1962823002: fix #552, Object members on native types (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « tool/input_sdk/patch/core_patch.dart ('k') | tool/input_sdk/private/ddc_runtime/generators.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/ddc_runtime/classes.dart
diff --git a/tool/input_sdk/private/ddc_runtime/classes.dart b/tool/input_sdk/private/ddc_runtime/classes.dart
index 86923f83c33d6384d3c5f6a74cab5ebf5588b12b..fdc72a361eeef9dcbcd597e2f592c9da9cc6aeb9 100644
--- a/tool/input_sdk/private/ddc_runtime/classes.dart
+++ b/tool/input_sdk/private/ddc_runtime/classes.dart
@@ -63,12 +63,20 @@ mixin(base, @rest mixins) => JS('', '''(() => {
return Mixin;
})()''');
+
+/// The Symbol for storing type arguments on a specialized generic type.
+final _mixins = JS('', 'Symbol("mixins")');
+
getMixins(clazz) => JS('', '$clazz[$_mixins]');
-getImplements(clazz) => JS('', '$clazz[$implements_]');
+@JSExportName('implements')
+final _implements = JS('', 'Symbol("implements")');
+
+getImplements(clazz) => JS('', '#[#]', clazz, _implements);
/// The Symbol for storing type arguments on a specialized generic type.
final _typeArguments = JS('', 'Symbol("typeArguments")');
+
final _originalDeclaration = JS('', 'Symbol("originalDeclaration")');
/// Memoize a generic type constructor function.
@@ -82,7 +90,7 @@ generic(typeConstructor) => JS('', '''(() => {
if (args.length != length && args.length != 0) {
$throwInternalError('requires ' + length + ' or 0 type arguments');
}
- while (args.length < length) args.push($dynamicR);
+ while (args.length < length) args.push($dynamic);
let value = resultMap;
for (let i = 0; i < length; i++) {
@@ -255,26 +263,40 @@ defineNamedConstructor(clazz, name) => JS('', '''(() => {
final _extensionType = JS('', 'Symbol("extensionType")');
-getExtensionType(obj) => JS('', '$obj[$_extensionType]');
+getExtensionType(obj) => JS('', '#[#]', obj, _extensionType);
final dartx = JS('', 'dartx');
-getExtensionSymbol(name) => JS('', '''(() => {
- let sym = $dartx[$name];
- if (!sym) $dartx[$name] = sym = Symbol('dartx.' + $name.toString());
+getExtensionSymbol(name) {
+ var sym = JS('', 'dartx[#]', name);
+ if (sym == null) {
+ sym = JS('', 'Symbol("dartx." + #.toString())', name);
+ JS('', 'dartx[#] = #', name, sym);
+ }
return sym;
-})()''');
+}
-defineExtensionNames(names) => JS('', '$names.forEach($getExtensionSymbol)');
+defineExtensionNames(names) =>
+ JS('', '#.forEach(#)', names, getExtensionSymbol);
// Install properties in prototype order. Properties / descriptors from
// more specific types should overwrite ones from less specific types.
-_installProperties(jsProto, extProto) => JS('', '''(() => {
- if (extProto !== $Object.prototype && extProto !== jsProto) {
- $_installProperties(jsProto, extProto.__proto__);
+_installProperties(jsProto, extProto) {
+ var coreObjProto = JS('', '#.prototype', Object);
+ if (JS('bool', '# === #', extProto, coreObjProto)) {
+ // core.Object members need to be copied from the non-symbol name to the
+ // symbol name.
+ for (var name in getOwnPropertyNames(coreObjProto)) {
+ var desc = getOwnPropertyDescriptor(coreObjProto, name);
+ defineProperty(jsProto, getExtensionSymbol(name), desc);
+ }
+ return;
}
- $copyTheseProperties(jsProto, extProto, $getOwnPropertySymbols(extProto));
-})()''');
+ if (JS('bool', '# !== #', jsProto, extProto)) {
+ _installProperties(jsProto, JS('', '#.__proto__', extProto));
+ }
+ copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto));
+}
///
/// Copy symbols from the prototype of the source to destination.
« no previous file with comments | « tool/input_sdk/patch/core_patch.dart ('k') | tool/input_sdk/private/ddc_runtime/generators.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698