| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 map._set(key, value); | 681 map._set(key, value); |
| 682 } | 682 } |
| 683 } else if (typeof $values === 'object') { | 683 } else if (typeof $values === 'object') { |
| 684 for (let key of $getOwnPropertyNames($values)) { | 684 for (let key of $getOwnPropertyNames($values)) { |
| 685 map._set(key, $values[key]); | 685 map._set(key, $values[key]); |
| 686 } | 686 } |
| 687 } | 687 } |
| 688 return map; | 688 return map; |
| 689 })()'''); | 689 })()'''); |
| 690 | 690 |
| 691 @JSExportName('assert') | 691 bool dassert(value) { |
| 692 assert_(condition, message()) { | |
| 693 if (JS('bool', '# !== true', condition)) { | |
| 694 if (condition == null) _throwBooleanConversionError(); | |
| 695 throwAssertionError(message); | |
| 696 } | |
| 697 } | |
| 698 | |
| 699 dassert(value, message()) { | |
| 700 if (JS('bool', '# != null && #[#] instanceof #', value, value, _runtimeType, | 692 if (JS('bool', '# != null && #[#] instanceof #', value, value, _runtimeType, |
| 701 AbstractFunctionType)) { | 693 AbstractFunctionType)) { |
| 702 value = JS('', '#(#)', dcall, value); | 694 value = JS('', '#(#)', dcall, value); |
| 703 } | 695 } |
| 704 return assert_(dtest(value), message); | 696 return dtest(value); |
| 705 } | 697 } |
| 706 | 698 |
| 707 /// Store a JS error for an exception. For non-primitives, we store as an | 699 /// Store a JS error for an exception. For non-primitives, we store as an |
| 708 /// expando. For primitive, we use a side cache. To limit memory leakage, we | 700 /// expando. For primitive, we use a side cache. To limit memory leakage, we |
| 709 /// only keep the last [_maxTraceCache] entries. | 701 /// only keep the last [_maxTraceCache] entries. |
| 710 final _error = JS('', 'Symbol("_error")'); | 702 final _error = JS('', 'Symbol("_error")'); |
| 711 Map _primitiveErrorCache; | 703 Map _primitiveErrorCache; |
| 712 const _maxErrorCache = 10; | 704 const _maxErrorCache = 10; |
| 713 | 705 |
| 714 bool _isJsError(exception) { | 706 bool _isJsError(exception) { |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 /// Libraries are not actually deferred in DDC, so this just returns a future | 1006 /// Libraries are not actually deferred in DDC, so this just returns a future |
| 1015 /// that completes immediately. | 1007 /// that completes immediately. |
| 1016 Future loadLibrary() => new Future.value(); | 1008 Future loadLibrary() => new Future.value(); |
| 1017 | 1009 |
| 1018 /// Defines lazy statics. | 1010 /// Defines lazy statics. |
| 1019 void defineLazy(to, from) { | 1011 void defineLazy(to, from) { |
| 1020 for (var name in getOwnNamesAndSymbols(from)) { | 1012 for (var name in getOwnNamesAndSymbols(from)) { |
| 1021 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); | 1013 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); |
| 1022 } | 1014 } |
| 1023 } | 1015 } |
| OLD | NEW |