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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 '''(() => { | 506 '''(() => { |
507 // If strongInstanceOf returns null, convert to false here. | 507 // If strongInstanceOf returns null, convert to false here. |
508 if (($obj == null) || $strongInstanceOf($obj, $type, true)) return true; | 508 if (($obj == null) || $strongInstanceOf($obj, $type, true)) return true; |
509 return false; | 509 return false; |
510 })()'''); | 510 })()'''); |
511 | 511 |
512 @JSExportName('is') | 512 @JSExportName('is') |
513 instanceOf(obj, type) => JS( | 513 instanceOf(obj, type) => JS( |
514 '', | 514 '', |
515 '''(() => { | 515 '''(() => { |
| 516 if ($obj == null) { |
| 517 return $type == $Null || $_isTop($type); |
| 518 } |
516 let result = $strongInstanceOf($obj, $type); | 519 let result = $strongInstanceOf($obj, $type); |
517 if (result !== null) return result; | 520 if (result !== null) return result; |
518 let actual = $getReifiedType($obj); | 521 let actual = $getReifiedType($obj); |
519 $throwStrongModeError('Strong mode is-check failure: ' + | 522 $throwStrongModeError('Strong mode is-check failure: ' + |
520 $typeName(actual) + ' does not soundly subtype ' + | 523 $typeName(actual) + ' does not soundly subtype ' + |
521 $typeName($type)); | 524 $typeName($type)); |
522 })()'''); | 525 })()'''); |
523 | 526 |
524 @JSExportName('as') | 527 @JSExportName('as') |
525 cast(obj, type) { | 528 cast(obj, type) { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 name = '+' + name; | 962 name = '+' + name; |
960 } | 963 } |
961 return name; | 964 return name; |
962 } | 965 } |
963 | 966 |
964 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 967 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
965 /// | 968 /// |
966 /// Libraries are not actually deferred in DDC, so this just returns a future | 969 /// Libraries are not actually deferred in DDC, so this just returns a future |
967 /// that completes immediately. | 970 /// that completes immediately. |
968 Future loadLibrary() => new Future.value(); | 971 Future loadLibrary() => new Future.value(); |
OLD | NEW |