OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 5 /** |
6 * This part contains helpers for supporting runtime type information. | 6 * This part contains helpers for supporting runtime type information. |
7 * | 7 * |
8 * The helper use a mixture of Dart and JavaScript objects. To indicate which is | 8 * The helper use a mixture of Dart and JavaScript objects. To indicate which is |
9 * used where we adopt the scheme of using explicit type annotation for Dart | 9 * used where we adopt the scheme of using explicit type annotation for Dart |
10 * objects and 'var' or omitted return type for JavaScript objects. | 10 * objects and 'var' or omitted return type for JavaScript objects. |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 var rti = getRuntimeTypeInfo(o); | 382 var rti = getRuntimeTypeInfo(o); |
383 o = getInterceptor(o); | 383 o = getInterceptor(o); |
384 var type = getRawRuntimeType(o); | 384 var type = getRawRuntimeType(o); |
385 if (rti != null) { | 385 if (rti != null) { |
386 // If the type has type variables (that is, `rti != null`), make a copy of | 386 // If the type has type variables (that is, `rti != null`), make a copy of |
387 // the type arguments and insert [o] in the first position to create a | 387 // the type arguments and insert [o] in the first position to create a |
388 // compound type representation. | 388 // compound type representation. |
389 rti = JS('JSExtendableArray', '#.slice()', rti); // Make a copy. | 389 rti = JS('JSExtendableArray', '#.slice()', rti); // Make a copy. |
390 JS('', '#.splice(0, 0, #)', rti, type); // Insert type at position 0. | 390 JS('', '#.splice(0, 0, #)', rti, type); // Insert type at position 0. |
391 type = rti; | 391 type = rti; |
392 } else if (isDartFunctionType(t)) { | 392 } |
| 393 if (isDartFunctionType(t)) { |
393 // Functions are treated specially and have their type information stored | 394 // Functions are treated specially and have their type information stored |
394 // directly in the instance. | 395 // directly in the instance. |
395 var targetSignatureFunction = | 396 var targetSignatureFunction = |
396 getField(o, '${JS_GET_NAME(JsGetName.SIGNATURE_NAME)}'); | 397 getField(o, '${JS_GET_NAME(JsGetName.SIGNATURE_NAME)}'); |
397 if (targetSignatureFunction == null) return false; | 398 if (targetSignatureFunction == null) return false; |
398 type = invokeOn(targetSignatureFunction, o, null); | 399 type = invokeOn(targetSignatureFunction, o, null); |
399 return isFunctionSubtype(type, t); | 400 return isFunctionSubtype(type, t); |
400 } | 401 } |
401 return isSubtype(type, t); | 402 return isSubtype(type, t); |
402 } | 403 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 * `null` and `undefined` (which we can avoid). | 672 * `null` and `undefined` (which we can avoid). |
672 */ | 673 */ |
673 bool isIdentical(var s, var t) => JS('bool', '# === #', s, t); | 674 bool isIdentical(var s, var t) => JS('bool', '# === #', s, t); |
674 | 675 |
675 /** | 676 /** |
676 * Returns `true` if the JavaScript values [s] and [t] are not identical. We use | 677 * Returns `true` if the JavaScript values [s] and [t] are not identical. We use |
677 * this helper instead of [identical] because `identical` needs to merge | 678 * this helper instead of [identical] because `identical` needs to merge |
678 * `null` and `undefined` (which we can avoid). | 679 * `null` and `undefined` (which we can avoid). |
679 */ | 680 */ |
680 bool isNotIdentical(var s, var t) => JS('bool', '# !== #', s, t); | 681 bool isNotIdentical(var s, var t) => JS('bool', '# !== #', s, t); |
OLD | NEW |