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

Side by Side Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 10915083: Change assert implementation to not depend on a top-level function called 'assert'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moved _assert to js_helper. Created 8 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 | Annotate | Revision Log
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 #library('dart:_js_helper'); 5 #library('dart:_js_helper');
6 6
7 #import('coreimpl.dart'); 7 #import('coreimpl.dart');
8 8
9 #source('constant_map.dart'); 9 #source('constant_map.dart');
10 #source('native_helper.dart'); 10 #source('native_helper.dart');
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 if (message is String) { 804 if (message is String) {
805 if (message.endsWith('is null') || 805 if (message.endsWith('is null') ||
806 message.endsWith('is undefined') || 806 message.endsWith('is undefined') ||
807 message.endsWith('is null or undefined')) { 807 message.endsWith('is null or undefined')) {
808 return new NullPointerException(); 808 return new NullPointerException();
809 } else if (message.contains(' is not a function') || 809 } else if (message.contains(' is not a function') ||
810 (ieErrorCode == 438 && ieFacilityNumber == 10)) { 810 (ieErrorCode == 438 && ieFacilityNumber == 10)) {
811 // Examples: 811 // Examples:
812 // x.foo is not a function 812 // x.foo is not a function
813 // 'undefined' is not a function (evaluating 'x.foo(1,2,3)') 813 // 'undefined' is not a function (evaluating 'x.foo(1,2,3)')
814 // Object doesn't support property or method 'foo' which sets the error 814 // Object doesn't support property or method 'foo' which sets the error
815 // code 438 in IE. 815 // code 438 in IE.
816 // TODO(kasperl): Compute the right name if possible. 816 // TODO(kasperl): Compute the right name if possible.
817 return new NoSuchMethodException('', '<unknown>', []); 817 return new NoSuchMethodException('', '<unknown>', []);
818 } 818 }
819 } 819 }
820 820
821 // If we cannot determine what kind of error this is, we fall back 821 // If we cannot determine what kind of error this is, we fall back
822 // to reporting this as a generic exception. It's probably better 822 // to reporting this as a generic exception. It's probably better
823 // than nothing. 823 // than nothing.
824 return new Exception(message is String ? message : ''); 824 return new Exception(message is String ? message : '');
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 1181
1182 /** 1182 /**
1183 * Special interface recognized by the compiler and implemented by DOM 1183 * Special interface recognized by the compiler and implemented by DOM
1184 * objects that support integer indexing. This interface is not 1184 * objects that support integer indexing. This interface is not
1185 * visible to anyone, and is only injected into special libraries. 1185 * visible to anyone, and is only injected into special libraries.
1186 */ 1186 */
1187 interface JavaScriptIndexingBehavior { 1187 interface JavaScriptIndexingBehavior {
1188 } 1188 }
1189 1189
1190 /** 1190 /**
1191 * Helper function for implementing asserts. The compiler treats this specially.
1192 */
1193 void assert(condition) {
1194 if (condition is Function) condition = condition();
1195 if (!condition) throw new AssertionError();
1196 }
1197
1198 /**
1191 * Called by generated code when a method that must be statically 1199 * Called by generated code when a method that must be statically
1192 * resolved cannot be found. 1200 * resolved cannot be found.
1193 */ 1201 */
1194 void throwNoSuchMethod(obj, name, arguments) { 1202 void throwNoSuchMethod(obj, name, arguments) {
1195 throw new NoSuchMethodException(obj, name, arguments); 1203 throw new NoSuchMethodException(obj, name, arguments);
1196 } 1204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698