Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(985)

Side by Side Diff: runtime/lib/errors_patch.dart

Issue 2667353003: Skip the type test for expressions which have already evaluated to true or false. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698