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', '!#', condition)) throwAssertionError(message); |
vsm
2017/07/07 12:38:47
If the static type of condition is `dynamic`, we w
| |
706 '''(() => { | 706 } |
707 if (!$condition) $throwAssertionError(message); | |
708 })()'''); | |
709 | 707 |
710 /// Store a JS error for an exception. For non-primitives, we store as an | 708 /// 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 | 709 /// expando. For primitive, we use a side cache. To limit memory leakage, we |
712 /// only keep the last [_maxTraceCache] entries. | 710 /// only keep the last [_maxTraceCache] entries. |
713 final _error = JS('', 'Symbol("_error")'); | 711 final _error = JS('', 'Symbol("_error")'); |
714 Map _primitiveErrorCache; | 712 Map _primitiveErrorCache; |
715 const _maxErrorCache = 10; | 713 const _maxErrorCache = 10; |
716 | 714 |
717 bool _isJsError(exception) { | 715 bool _isJsError(exception) { |
718 return JS('bool', '#.Error != null && # instanceof #.Error', global_, | 716 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 | 1023 /// Libraries are not actually deferred in DDC, so this just returns a future |
1026 /// that completes immediately. | 1024 /// that completes immediately. |
1027 Future loadLibrary() => new Future.value(); | 1025 Future loadLibrary() => new Future.value(); |
1028 | 1026 |
1029 /// Defines lazy statics. | 1027 /// Defines lazy statics. |
1030 void defineLazy(to, from) { | 1028 void defineLazy(to, from) { |
1031 for (var name in getOwnNamesAndSymbols(from)) { | 1029 for (var name in getOwnNamesAndSymbols(from)) { |
1032 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); | 1030 defineLazyProperty(to, name, getOwnPropertyDescriptor(from, name)); |
1033 } | 1031 } |
1034 } | 1032 } |
OLD | NEW |