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

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

Issue 1680263002: Support for dart:typed_data (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address comments, rebase Created 4 years, 10 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 | « test/codegen/expect/sunflower/dom.js ('k') | tool/input_sdk/private/native_typed_data.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/classes.dart
diff --git a/tool/input_sdk/private/classes.dart b/tool/input_sdk/private/classes.dart
index 7a784a4257c321f8ed92d193a05ddaca7ac5034c..d10c6d727e233ae48a72dfff56db8d02f4046665 100644
--- a/tool/input_sdk/private/classes.dart
+++ b/tool/input_sdk/private/classes.dart
@@ -259,6 +259,8 @@ defineNamedConstructor(clazz, name) => JS('', '''(() => {
final _extensionType = JS('', 'Symbol("extensionType")');
+getExtensionType(obj) => JS('', '$obj[$_extensionType]');
+
final dartx = JS('', '{}');
getExtensionSymbol(name) => JS('', '''(() => {
@@ -269,6 +271,15 @@ getExtensionSymbol(name) => JS('', '''(() => {
defineExtensionNames(names) => JS('', '$names.forEach($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__);
+ }
+ $copyTheseProperties(jsProto, extProto, $getOwnPropertySymbols(extProto));
+})()''');
+
///
/// Copy symbols from the prototype of the source to destination.
/// These are the only properties safe to copy onto an existing public
@@ -280,13 +291,8 @@ registerExtension(jsType, dartExtType) => JS('', '''(() => {
// Mark the JS type's instances so we can easily check for extensions.
$assert_(jsProto[$_extensionType] === void 0);
- jsProto[$_extensionType] = extProto;
-
- let dartObjProto = $Object.prototype;
- while (extProto !== dartObjProto && extProto !== jsProto) {
- $copyTheseProperties(jsProto, extProto, $getOwnPropertySymbols(extProto));
- extProto = extProto.__proto__;
- }
+ jsProto[$_extensionType] = $dartExtType;
+ $_installProperties(jsProto, extProto);
let originalSigFn = $getOwnPropertyDescriptor($dartExtType, $_methodSig).get;
$assert_(originalSigFn);
$defineMemoizedGetter($jsType, $_methodSig, originalSigFn);
@@ -345,6 +351,9 @@ canonicalMember(obj, name) => JS('', '''(() => {
/// Sets the type of `obj` to be `type`
setType(obj, type) => JS('', '''(() => {
$obj.__proto__ = $type.prototype;
+ // TODO(vsm): This should be set in registerExtension, but that is only
+ // invoked on the generic type (e.g., JSArray<dynamic>, not JSArray<int>).
+ $obj.__proto__[$_extensionType] = $type;
return $obj;
})()''');
« no previous file with comments | « test/codegen/expect/sunflower/dom.js ('k') | tool/input_sdk/private/native_typed_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698