Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart._js_helper; | 5 library dart._js_helper; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'dart:_debugger' show stackTraceMapper; | 9 import 'dart:_debugger' show stackTraceMapper; |
| 10 | 10 |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 854 | 854 |
| 855 /** | 855 /** |
| 856 * Error thrown when a runtime error occurs. | 856 * Error thrown when a runtime error occurs. |
| 857 */ | 857 */ |
| 858 class RuntimeError extends Error { | 858 class RuntimeError extends Error { |
| 859 final message; | 859 final message; |
| 860 RuntimeError(this.message); | 860 RuntimeError(this.message); |
| 861 String toString() => "RuntimeError: $message"; | 861 String toString() => "RuntimeError: $message"; |
| 862 } | 862 } |
| 863 | 863 |
| 864 /** | 864 /// Error thrown by DDC when an `assert()` fails (with or without a message). |
| 865 * Error thrown when an assert() fails with a message: | 865 class AssertionErrorImpl extends AssertionError { |
| 866 * | 866 AssertionErrorImpl(message) : super(message); |
| 867 * assert(false, "Message here"); | 867 String toString() => |
| 868 */ | 868 "Assertion failed: " + |
| 869 class AssertionErrorWithMessage extends AssertionError { | 869 (message != null ? Error.safeToString(message) : "is not true"); |
|
Jennifer Messerly
2017/07/07 23:43:17
this uses Error.safeToString as dart2js does
VM/d
| |
| 870 final Object _message; | |
| 871 AssertionErrorWithMessage(this._message); | |
| 872 String toString() => "Assertion failed: ${_message}"; | |
| 873 } | 870 } |
| 874 | 871 |
| 875 /** | 872 /** |
| 876 * Creates a random number with 64 bits of randomness. | 873 * Creates a random number with 64 bits of randomness. |
| 877 * | 874 * |
| 878 * This will be truncated to the 53 bits available in a double. | 875 * This will be truncated to the 53 bits available in a double. |
| 879 */ | 876 */ |
| 880 int random64() { | 877 int random64() { |
| 881 // TODO(lrn): Use a secure random source. | 878 // TODO(lrn): Use a secure random source. |
| 882 int int32a = JS("int", "(Math.random() * 0x100000000) >>> 0"); | 879 int int32a = JS("int", "(Math.random() * 0x100000000) >>> 0"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 915 // we have no way of telling the compiler yet, so it will generate an extra | 912 // we have no way of telling the compiler yet, so it will generate an extra |
| 916 // layer of indirection that wraps the SyncIterator. | 913 // layer of indirection that wraps the SyncIterator. |
| 917 _jsIterator() => JS('', '#(...#)', _generator, _args); | 914 _jsIterator() => JS('', '#(...#)', _generator, _args); |
| 918 | 915 |
| 919 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); | 916 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); |
| 920 } | 917 } |
| 921 | 918 |
| 922 class BooleanConversionAssertionError extends AssertionError { | 919 class BooleanConversionAssertionError extends AssertionError { |
| 923 toString() => 'Failed assertion: boolean expression must not be null'; | 920 toString() => 'Failed assertion: boolean expression must not be null'; |
| 924 } | 921 } |
| OLD | NEW |