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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 '', | 474 '', |
| 475 '''(() => { | 475 '''(() => { |
| 476 let actual = $getReifiedType($obj); | 476 let actual = $getReifiedType($obj); |
| 477 let result = $isSubtype(actual, $type); | 477 let result = $isSubtype(actual, $type); |
| 478 if (result || (actual == $int && $isSubtype($double, $type))) return true; | 478 if (result || (actual == $int && $isSubtype($double, $type))) return true; |
| 479 if (actual == $jsobject && $_isFunctionType(type) && | 479 if (actual == $jsobject && $_isFunctionType(type) && |
| 480 typeof(obj) === 'function') { | 480 typeof(obj) === 'function') { |
| 481 return true; | 481 return true; |
| 482 } | 482 } |
| 483 if (result === false) return false; | 483 if (result === false) return false; |
| 484 if (!$_ignoreWhitelistedErrors || ($ignoreFromWhiteList == void 0)) return res ult; | 484 if (!dart.__ignoreWhitelistedErrors || ($ignoreFromWhiteList == void 0)) retur n result; |
|
Leaf
2017/05/15 22:06:39
line length?
Jacob
2017/05/15 23:27:49
Done.
| |
| 485 if ($_ignoreTypeFailure(actual, $type)) return true; | 485 if ($_ignoreTypeFailure(actual, $type)) return true; |
| 486 return result; | 486 return result; |
| 487 })()'''); | 487 })()'''); |
| 488 | 488 |
| 489 /// Returns true if [obj] is null or an instance of [type] | 489 /// Returns true if [obj] is null or an instance of [type] |
| 490 /// Returns false if [obj] is non-null and not an instance of [type] | 490 /// Returns false if [obj] is non-null and not an instance of [type] |
| 491 /// in strong mode | 491 /// in strong mode |
| 492 instanceOfOrNull(obj, type) => JS( | 492 instanceOfOrNull(obj, type) => JS( |
| 493 '', | 493 '', |
| 494 '''(() => { | 494 '''(() => { |
| 495 // If strongInstanceOf returns null, convert to false here. | 495 // If strongInstanceOf returns null, convert to false here. |
| 496 if (($obj == null) || $strongInstanceOf($obj, $type, true)) return true; | 496 if (($obj == null) || $strongInstanceOf($obj, $type, true)) return true; |
| 497 return false; | 497 return false; |
| 498 })()'''); | 498 })()'''); |
| 499 | 499 |
| 500 @JSExportName('is') | 500 @JSExportName('is') |
| 501 instanceOf(obj, type) => JS( | 501 instanceOf(obj, type) => JS( |
| 502 '', | 502 '', |
| 503 '''(() => { | 503 '''(() => { |
| 504 if ($obj == null) { | 504 if ($obj == null) { |
| 505 return $type == $Null || $_isTop($type); | 505 return $type == $Null || $_isTop($type); |
| 506 } | 506 } |
| 507 let result = $strongInstanceOf($obj, $type); | 507 let result = $strongInstanceOf($obj, $type); |
| 508 if (result !== null) return result; | 508 if (result !== null) return result; |
| 509 if (!$_failForWeakModeIsChecks) return false; | 509 if (!dart.__failForWeakModeIsChecks) return false; |
| 510 let actual = $getReifiedType($obj); | 510 let actual = $getReifiedType($obj); |
| 511 $throwStrongModeError('Strong mode is-check failure: ' + | 511 $throwStrongModeError('Strong mode is-check failure: ' + |
| 512 $typeName(actual) + ' does not soundly subtype ' + | 512 $typeName(actual) + ' does not soundly subtype ' + |
| 513 $typeName($type)); | 513 $typeName($type)); |
| 514 })()'''); | 514 })()'''); |
| 515 | 515 |
| 516 @JSExportName('as') | 516 @JSExportName('as') |
| 517 cast(obj, type) { | 517 cast(obj, type) { |
| 518 if (JS('bool', '# == #', type, dynamic) || obj == null) return obj; | 518 if (JS('bool', '# == #', type, dynamic) || obj == null) return obj; |
| 519 bool result = strongInstanceOf(obj, type, true); | 519 bool result = strongInstanceOf(obj, type, true); |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 name = '+' + name; | 992 name = '+' + name; |
| 993 } | 993 } |
| 994 return name; | 994 return name; |
| 995 } | 995 } |
| 996 | 996 |
| 997 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 997 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
| 998 /// | 998 /// |
| 999 /// Libraries are not actually deferred in DDC, so this just returns a future | 999 /// Libraries are not actually deferred in DDC, so this just returns a future |
| 1000 /// that completes immediately. | 1000 /// that completes immediately. |
| 1001 Future loadLibrary() => new Future.value(); | 1001 Future loadLibrary() => new Future.value(); |
| OLD | NEW |