| OLD | NEW |
| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 ctor.prototype = proto; | 261 ctor.prototype = proto; |
| 262 // Use defineProperty so we don't hit a property defined on Function, | 262 // Use defineProperty so we don't hit a property defined on Function, |
| 263 // like `caller` and `arguments`. | 263 // like `caller` and `arguments`. |
| 264 $defineProperty($clazz, $name, { value: ctor, configurable: true }); | 264 $defineProperty($clazz, $name, { value: ctor, configurable: true }); |
| 265 })()'''); | 265 })()'''); |
| 266 | 266 |
| 267 final _extensionType = JS('', 'Symbol("extensionType")'); | 267 final _extensionType = JS('', 'Symbol("extensionType")'); |
| 268 | 268 |
| 269 getExtensionType(obj) => JS('', '$obj[$_extensionType]'); | 269 getExtensionType(obj) => JS('', '$obj[$_extensionType]'); |
| 270 | 270 |
| 271 final dartx = JS('', '{}'); | 271 final dartx = JS('', 'dartx'); |
| 272 | 272 |
| 273 getExtensionSymbol(name) => JS('', '''(() => { | 273 getExtensionSymbol(name) => JS('', '''(() => { |
| 274 let sym = $dartx[$name]; | 274 let sym = $dartx[$name]; |
| 275 if (!sym) $dartx[$name] = sym = Symbol('dartx.' + $name.toString()); | 275 if (!sym) $dartx[$name] = sym = Symbol('dartx.' + $name.toString()); |
| 276 return sym; | 276 return sym; |
| 277 })()'''); | 277 })()'''); |
| 278 | 278 |
| 279 defineExtensionNames(names) => JS('', '$names.forEach($getExtensionSymbol)'); | 279 defineExtensionNames(names) => JS('', '$names.forEach($getExtensionSymbol)'); |
| 280 | 280 |
| 281 // Install properties in prototype order. Properties / descriptors from | 281 // Install properties in prototype order. Properties / descriptors from |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 })()'''); | 372 })()'''); |
| 373 | 373 |
| 374 /// Sets the element type of a list literal. | 374 /// Sets the element type of a list literal. |
| 375 list(obj, elementType) => | 375 list(obj, elementType) => |
| 376 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))'); | 376 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))'); |
| 377 | 377 |
| 378 setBaseClass(derived, base) => JS('', '''(() => { | 378 setBaseClass(derived, base) => JS('', '''(() => { |
| 379 // Link the extension to the type it's extending as a base class. | 379 // Link the extension to the type it's extending as a base class. |
| 380 $derived.prototype.__proto__ = $base.prototype; | 380 $derived.prototype.__proto__ = $base.prototype; |
| 381 })()'''); | 381 })()'''); |
| OLD | NEW |