| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 if ($f === void 0) $f = $obj[$name]; | 163 if ($f === void 0) $f = $obj[$name]; |
| 164 $f = $f.bind($obj); | 164 $f = $f.bind($obj); |
| 165 // TODO(jmesserly): track the function's signature on the function, instead | 165 // TODO(jmesserly): track the function's signature on the function, instead |
| 166 // of having to go back to the class? | 166 // of having to go back to the class? |
| 167 let sig = $getMethodType($obj, $name); | 167 let sig = $getMethodType($obj, $name); |
| 168 $assert_(sig); | 168 $assert_(sig); |
| 169 $tag($f, sig); | 169 $tag($f, sig); |
| 170 return $f; | 170 return $f; |
| 171 })()'''); | 171 })()'''); |
| 172 | 172 |
| 173 /// Instantiate a generic method. |
| 174 /// |
| 175 /// We need to apply the type arguments both to the function, as well as its |
| 176 /// associated function type. |
| 177 gbind(f, @rest typeArgs) { |
| 178 var result = JS('', '#(...#)', f, typeArgs); |
| 179 var sig = JS('', '#(...#)', _getRuntimeType(f), typeArgs); |
| 180 tag(result, sig); |
| 181 return result; |
| 182 } |
| 183 |
| 173 // Set up the method signature field on the constructor | 184 // Set up the method signature field on the constructor |
| 174 _setMethodSignature(f, sigF) => JS('', '''(() => { | 185 _setMethodSignature(f, sigF) => JS('', '''(() => { |
| 175 $defineMemoizedGetter($f, $_methodSig, () => { | 186 $defineMemoizedGetter($f, $_methodSig, () => { |
| 176 let sigObj = $sigF(); | 187 let sigObj = $sigF(); |
| 177 sigObj.__proto__ = $f.__proto__[$_methodSig]; | 188 sigObj.__proto__ = $f.__proto__[$_methodSig]; |
| 178 return sigObj; | 189 return sigObj; |
| 179 }); | 190 }); |
| 180 })()'''); | 191 })()'''); |
| 181 | 192 |
| 182 // Set up the constructor signature field on the constructor | 193 // Set up the constructor signature field on the constructor |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 })()'''); | 361 })()'''); |
| 351 | 362 |
| 352 /// Sets the element type of a list literal. | 363 /// Sets the element type of a list literal. |
| 353 list(obj, elementType) => | 364 list(obj, elementType) => |
| 354 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))'); | 365 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))'); |
| 355 | 366 |
| 356 setBaseClass(derived, base) => JS('', '''(() => { | 367 setBaseClass(derived, base) => JS('', '''(() => { |
| 357 // Link the extension to the type it's extending as a base class. | 368 // Link the extension to the type it's extending as a base class. |
| 358 $derived.prototype.__proto__ = $base.prototype; | 369 $derived.prototype.__proto__ = $base.prototype; |
| 359 })()'''); | 370 })()'''); |
| OLD | NEW |