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

Side by Side Diff: tool/input_sdk/private/ddc_runtime/classes.dart

Issue 1969093002: Miscellaneous runtime fixes. (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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// This library defines the operations that define and manipulate Dart 5 /// This library defines the operations that define and manipulate Dart
6 /// classes. Included in this are: 6 /// classes. Included in this are:
7 /// - Generics 7 /// - Generics
8 /// - Class metadata 8 /// - Class metadata
9 /// - Extension methods 9 /// - Extension methods
10 /// 10 ///
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 JS('', 'dartx[#] = #', name, sym); 274 JS('', 'dartx[#] = #', name, sym);
275 } 275 }
276 return sym; 276 return sym;
277 } 277 }
278 278
279 defineExtensionNames(names) => 279 defineExtensionNames(names) =>
280 JS('', '#.forEach(#)', names, getExtensionSymbol); 280 JS('', '#.forEach(#)', names, getExtensionSymbol);
281 281
282 // Install properties in prototype order. Properties / descriptors from 282 // Install properties in prototype order. Properties / descriptors from
283 // more specific types should overwrite ones from less specific types. 283 // more specific types should overwrite ones from less specific types.
284 _installProperties(jsProto, extProto) { 284 _installProperties(jsProto, extProto) => JS('', '''(() => {
285 var coreObjProto = JS('', '#.prototype', Object); 285 let coreObjProto = $Object.prototype;
286 if (JS('bool', '# === #', extProto, coreObjProto)) { 286 if (extProto === coreObjProto) {
287 // core.Object members need to be copied from the non-symbol name to the 287 // core.Object members need to be copied from the non-symbol name to the
288 // symbol name. 288 // symbol name.
289 for (var name in getOwnPropertyNames(coreObjProto)) { 289 let names = $getOwnPropertyNames(coreObjProto);
290 var desc = getOwnPropertyDescriptor(coreObjProto, name); 290 for (var i = 0; i < names.length; ++i) {
Jennifer Messerly 2016/05/11 19:56:26 nit: use `let` if writing JS code
Leaf 2016/05/12 17:00:44 Done.
291 defineProperty(jsProto, getExtensionSymbol(name), desc); 291 let name = names[i];
Jennifer Messerly 2016/05/11 19:56:26 fyi ... there is a way to write this in Dart witho
Leaf 2016/05/12 17:00:44 Done.
292 let desc = $getOwnPropertyDescriptor(coreObjProto, name);
293 $defineProperty(jsProto, $getExtensionSymbol(name), desc);
292 } 294 }
293 return; 295 return;
294 } 296 }
295 if (JS('bool', '# !== #', jsProto, extProto)) { 297 if (jsProto !== extProto) {
296 _installProperties(jsProto, JS('', '#.__proto__', extProto)); 298 $_installProperties(jsProto, extProto.__proto__);
297 } 299 }
298 copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto)); 300 $copyTheseProperties(jsProto, extProto, $getOwnPropertySymbols(extProto));
299 } 301 })()''');
300 302
301 /// 303 ///
302 /// Copy symbols from the prototype of the source to destination. 304 /// Copy symbols from the prototype of the source to destination.
303 /// These are the only properties safe to copy onto an existing public 305 /// These are the only properties safe to copy onto an existing public
304 /// JavaScript class. 306 /// JavaScript class.
305 /// 307 ///
306 registerExtension(jsType, dartExtType) => JS('', '''(() => { 308 registerExtension(jsType, dartExtType) => JS('', '''(() => {
307 // TODO(vsm): Not all registered js types are real. 309 // TODO(vsm): Not all registered js types are real.
308 if (!jsType) return; 310 if (!jsType) return;
309 311
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 })()'''); 388 })()''');
387 389
388 /// Sets the element type of a list literal. 390 /// Sets the element type of a list literal.
389 list(obj, elementType) => 391 list(obj, elementType) =>
390 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))'); 392 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))');
391 393
392 setBaseClass(derived, base) => JS('', '''(() => { 394 setBaseClass(derived, base) => JS('', '''(() => {
393 // Link the extension to the type it's extending as a base class. 395 // Link the extension to the type it's extending as a base class.
394 $derived.prototype.__proto__ = $base.prototype; 396 $derived.prototype.__proto__ = $base.prototype;
395 })()'''); 397 })()''');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698