Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 @patch class Error { | 5 @patch class Error { |
| 6 @patch static String _objectToString(Object object) { | 6 @patch static String _objectToString(Object object) { |
| 7 return Object._toString(object); | 7 return Object._toString(object); |
| 8 } | 8 } |
| 9 | 9 |
| 10 @patch static String _stringToSafeString(String string) { | 10 @patch static String _stringToSafeString(String string) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 // out of the script. It expects a Dart stack frame from class | 26 // out of the script. It expects a Dart stack frame from class |
| 27 // _AssertionError. Thus we need a Dart stub that calls the native code. | 27 // _AssertionError. Thus we need a Dart stub that calls the native code. |
| 28 static _throwNew(int assertionStart, int assertionEnd, Object message) { | 28 static _throwNew(int assertionStart, int assertionEnd, Object message) { |
| 29 _doThrowNew(assertionStart, assertionEnd, message); | 29 _doThrowNew(assertionStart, assertionEnd, message); |
| 30 } | 30 } |
| 31 | 31 |
| 32 static _doThrowNew(int assertionStart, int assertionEnd, Object message) | 32 static _doThrowNew(int assertionStart, int assertionEnd, Object message) |
| 33 native "AssertionError_throwNew"; | 33 native "AssertionError_throwNew"; |
| 34 | 34 |
| 35 static _evaluateAssertion(condition) { | 35 static _evaluateAssertion(condition) { |
| 36 if (identical(condition, true) || identical(condition, false)) { | |
| 37 return condition; | |
| 38 } | |
| 36 if (condition is Function) { | 39 if (condition is Function) { |
|
rmacnak
2017/02/02 19:02:05
It might be worth adding
if (condition is _Closur
Cutch
2017/02/02 19:57:49
Done.
| |
| 37 condition = condition(); | 40 condition = condition(); |
| 38 } | 41 } |
| 39 return condition; | 42 return condition; |
| 40 } | 43 } |
| 41 | 44 |
| 42 String get _messageString { | 45 String get _messageString { |
| 43 if (message == null) return "is not true."; | 46 if (message == null) return "is not true."; |
| 44 if (message is String) return message; | 47 if (message is String) return message; |
| 45 return Error.safeToString(message); | 48 return Error.safeToString(message); |
| 46 } | 49 } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 return msg_buf.toString(); | 371 return msg_buf.toString(); |
| 369 } | 372 } |
| 370 } | 373 } |
| 371 | 374 |
| 372 | 375 |
| 373 class _CompileTimeError extends Error { | 376 class _CompileTimeError extends Error { |
| 374 final String _errorMsg; | 377 final String _errorMsg; |
| 375 _CompileTimeError(this._errorMsg); | 378 _CompileTimeError(this._errorMsg); |
| 376 String toString() => _errorMsg; | 379 String toString() => _errorMsg; |
| 377 } | 380 } |
| OLD | NEW |