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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 } | 694 } |
| 695 } else if (typeof $values === 'object') { | 695 } else if (typeof $values === 'object') { |
| 696 for (let key of $getOwnPropertyNames($values)) { | 696 for (let key of $getOwnPropertyNames($values)) { |
| 697 map._set(key, $values[key]); | 697 map._set(key, $values[key]); |
| 698 } | 698 } |
| 699 } | 699 } |
| 700 return map; | 700 return map; |
| 701 })()'''); | 701 })()'''); |
| 702 | 702 |
| 703 @JSExportName('assert') | 703 @JSExportName('assert') |
| 704 assert_(condition, [message]) => JS( | 704 assert_(condition, message()) { |
| 705 '', | 705 if (JS('bool', '# !== true', condition)) { |
| 706 '''(() => { | 706 if (condition == null) _throwBooleanConversionError(); |
|
Jennifer Messerly
2017/07/07 23:43:17
Now has correct handling for null
| |
| 707 if (!$condition) $throwAssertionError(message); | 707 throwAssertionError(message); |
| 708 })()'''); | 708 } |
| 709 } | |
| 710 | |
| 711 dassert(value, message()) { | |
| 712 if (JS('bool', '# != null && #[#] instanceof #', value, value, _runtimeType, | |
| 713 AbstractFunctionType)) { | |
| 714 value = JS('', '#(#)', dcall, value); | |
| 715 } | |
| 716 return assert_(dtest(value), message); | |
|
Jennifer Messerly
2017/07/07 23:43:17
now correctly handles all cases where a non-boolea
| |
| 717 } | |
| 709 | 718 |
| 710 /// Store a JS error for an exception. For non-primitives, we store as an | 719 /// Store a JS error for an exception. For non-primitives, we store as an |
| 711 /// expando. For primitive, we use a side cache. To limit memory leakage, we | 720 /// expando. For primitive, we use a side cache. To limit memory leakage, we |
| 712 /// only keep the last [_maxTraceCache] entries. | 721 /// only keep the last [_maxTraceCache] entries. |
| 713 final _error = JS('', 'Symbol("_error")'); | 722 final _error = JS('', 'Symbol("_error")'); |
| 714 Map _primitiveErrorCache; | 723 Map _primitiveErrorCache; |
| 715 const _maxErrorCache = 10; | 724 const _maxErrorCache = 10; |
| 716 | 725 |
| 717 bool _isJsError(exception) { | 726 bool _isJsError(exception) { |
| 718 return JS('bool', '#.Error != null && # instanceof #.Error', global_, | 727 return JS('bool', '#.Error != null && # instanceof #.Error', global_, |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1025 /// Libraries are not actually deferred in DDC, so this just returns a future | 1034 /// Libraries are not actually deferred in DDC, so this just returns a future |
| 1026 /// that completes immediately. | 1035 /// that completes immediately. |
| 1027 Future loadLibrary() => new Future.value(); | 1036 Future loadLibrary() => new Future.value(); |
| 1028 | 1037 |
| 1029 /// Defines lazy statics. | 1038 /// Defines lazy statics. |
| 1030 void defineLazy(to, from) { | 1039 void defineLazy(to, from) { |
| 1031 for (var name in getOwnNamesAndSymbols(from)) { | 1040 for (var name in getOwnNamesAndSymbols(from)) { |
| 1032 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); | 1041 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); |
| 1033 } | 1042 } |
| 1034 } | 1043 } |
| OLD | NEW |