Chromium Code Reviews| 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 runtime operations on objects used by the code | 5 /// This library defines runtime operations on objects used by the code |
| 6 /// generator. | 6 /// generator. |
| 7 part of dart._runtime; | 7 part of dart._runtime; |
| 8 | 8 |
| 9 class InvocationImpl extends Invocation { | 9 class InvocationImpl extends Invocation { |
| 10 final Symbol memberName; | 10 final Symbol memberName; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 !!$isSubtype(actual, $StreamSubscription)) { | 432 !!$isSubtype(actual, $StreamSubscription)) { |
| 433 console.warn('Ignoring cast fail from ' + $typeName(actual) + | 433 console.warn('Ignoring cast fail from ' + $typeName(actual) + |
| 434 ' to ' + $typeName(type)); | 434 ' to ' + $typeName(type)); |
| 435 return true; | 435 return true; |
| 436 } | 436 } |
| 437 return false; | 437 return false; |
| 438 }); | 438 }); |
| 439 })()'''); | 439 })()'''); |
| 440 | 440 |
| 441 /// Returns true if [obj] is an instance of [type] | 441 /// Returns true if [obj] is an instance of [type] |
| 442 /// Returns true if [obj] is a JS function and [type] is a function type | |
| 442 /// Returns false if [obj] is not an instance of [type] in both spec | 443 /// Returns false if [obj] is not an instance of [type] in both spec |
| 443 /// and strong mode | 444 /// and strong mode |
| 444 /// Returns null if [obj] is not an instance of [type] in strong mode | 445 /// Returns null if [obj] is not an instance of [type] in strong mode |
| 445 /// but might be in spec mode | 446 /// but might be in spec mode |
| 446 bool strongInstanceOf(obj, type, ignoreFromWhiteList) => JS( | 447 bool strongInstanceOf(obj, type, ignoreFromWhiteList) => JS( |
| 447 '', | 448 '', |
| 448 '''(() => { | 449 '''(() => { |
| 449 let actual = $getReifiedType($obj); | 450 let actual = $getReifiedType($obj); |
| 450 let result = $isSubtype(actual, $type); | 451 let result = $isSubtype(actual, $type); |
| 451 if (result || actual == $jsobject || | 452 if (result || (actual == $int && $isSubtype($double, $type))) return true; |
| 452 (actual == $int && $isSubtype($double, $type))) return true; | 453 if (actual == $jsobject && $isFunctionType(type) && typeof(obj) === 'function' ) return true; |
|
vsm
2017/04/21 12:35:58
nit: line len
| |
| 453 if (result === false) return false; | 454 if (result === false) return false; |
| 454 if (!$_ignoreWhitelistedErrors || ($ignoreFromWhiteList == void 0)) return res ult; | 455 if (!$_ignoreWhitelistedErrors || ($ignoreFromWhiteList == void 0)) return res ult; |
| 455 if ($_ignoreTypeFailure(actual, $type)) return true; | 456 if ($_ignoreTypeFailure(actual, $type)) return true; |
| 456 return result; | 457 return result; |
| 457 })()'''); | 458 })()'''); |
| 458 | 459 |
| 459 /// Returns true if [obj] is null or an instance of [type] | 460 /// Returns true if [obj] is null or an instance of [type] |
| 460 /// Returns false if [obj] is non-null and not an instance of [type] | 461 /// Returns false if [obj] is non-null and not an instance of [type] |
| 461 /// in strong mode | 462 /// in strong mode |
| 462 instanceOfOrNull(obj, type) => JS( | 463 instanceOfOrNull(obj, type) => JS( |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 928 name = '+' + name; | 929 name = '+' + name; |
| 929 } | 930 } |
| 930 return name; | 931 return name; |
| 931 } | 932 } |
| 932 | 933 |
| 933 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 934 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
| 934 /// | 935 /// |
| 935 /// Libraries are not actually deferred in DDC, so this just returns a future | 936 /// Libraries are not actually deferred in DDC, so this just returns a future |
| 936 /// that completes immediately. | 937 /// that completes immediately. |
| 937 Future loadLibrary() => new Future.value(); | 938 Future loadLibrary() => new Future.value(); |
| OLD | NEW |