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

Side by Side Diff: sdk/lib/_internal/js_runtime/lib/js_helper.dart

Issue 1346093003: Revert "Add optional message to assert in Dart2js - continued" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 | « pkg/compiler/lib/src/world.dart ('k') | sdk/lib/core/errors.dart » ('j') | 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) 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 _js_helper; 5 library _js_helper;
6 6
7 import 'dart:_js_embedded_names' show 7 import 'dart:_js_embedded_names' show
8 DEFERRED_LIBRARY_URIS, 8 DEFERRED_LIBRARY_URIS,
9 DEFERRED_LIBRARY_HASHES, 9 DEFERRED_LIBRARY_HASHES,
10 GET_TYPE_FROM_NAME, 10 GET_TYPE_FROM_NAME,
(...skipping 3303 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 String toString() => message; 3314 String toString() => message;
3315 } 3315 }
3316 3316
3317 class FallThroughErrorImplementation extends FallThroughError { 3317 class FallThroughErrorImplementation extends FallThroughError {
3318 FallThroughErrorImplementation(); 3318 FallThroughErrorImplementation();
3319 String toString() => "Switch case fall-through."; 3319 String toString() => "Switch case fall-through.";
3320 } 3320 }
3321 3321
3322 /** 3322 /**
3323 * Helper function for implementing asserts. The compiler treats this specially. 3323 * Helper function for implementing asserts. The compiler treats this specially.
3324 *
3325 * Returns the negation of the condition. That is: `true` if the assert should
3326 * fail.
3327 */ 3324 */
3328 bool assertTest(condition) { 3325 void assertHelper(condition) {
3329 // Do bool success check first, it is common and faster than 'is Function'. 3326 // Do a bool check first because it is common and faster than 'is Function'.
3330 if (true == condition) return false; 3327 if (condition is !bool) {
3331 if (condition is Function) condition = condition(); 3328 if (condition is Function) condition = condition();
3332 if (condition is bool) return !condition; 3329 if (condition is !bool) {
3333 throw new TypeErrorImplementation(condition, 'bool'); 3330 throw new TypeErrorImplementation(condition, 'bool');
3331 }
3332 }
3333 // Compare to true to avoid boolean conversion check in checked
3334 // mode.
3335 if (true != condition) throw new AssertionError();
3334 } 3336 }
3335 3337
3336 /** 3338 /**
3337 * Helper function for implementing asserts with messages.
3338 * The compiler treats this specially.
3339 */
3340 void assertThrow(Object message) {
3341 throw new _AssertionError(message);
3342 }
3343
3344 /**
3345 * Helper function for implementing asserts without messages.
3346 * The compiler treats this specially.
3347 */
3348 @NoInline()
3349 void assertHelper(condition) {
3350 if (assertTest(condition)) throw new AssertionError();
3351 }
3352
3353 /**
3354 * Called by generated code when a method that must be statically 3339 * Called by generated code when a method that must be statically
3355 * resolved cannot be found. 3340 * resolved cannot be found.
3356 */ 3341 */
3357 void throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) { 3342 void throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) {
3358 Symbol memberName = new _symbol_dev.Symbol.unvalidated(name); 3343 Symbol memberName = new _symbol_dev.Symbol.unvalidated(name);
3359 throw new NoSuchMethodError(obj, memberName, arguments, 3344 throw new NoSuchMethodError(obj, memberName, arguments,
3360 new Map<Symbol, dynamic>(), 3345 new Map<Symbol, dynamic>(),
3361 expectedArgumentNames); 3346 expectedArgumentNames);
3362 } 3347 }
3363 3348
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
4003 throw new MainError("No top-level function named 'main'."); 3988 throw new MainError("No top-level function named 'main'.");
4004 } 3989 }
4005 3990
4006 void badMain() { 3991 void badMain() {
4007 throw new MainError("'main' is not a function."); 3992 throw new MainError("'main' is not a function.");
4008 } 3993 }
4009 3994
4010 void mainHasTooManyParameters() { 3995 void mainHasTooManyParameters() {
4011 throw new MainError("'main' expects too many parameters."); 3996 throw new MainError("'main' expects too many parameters.");
4012 } 3997 }
4013
4014 class _AssertionError extends AssertionError {
4015 final _message;
4016 _AssertionError(this._message);
4017
4018 String toString() => "Assertion failed: " + Error.safeToString(_message);
4019 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/world.dart ('k') | sdk/lib/core/errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698