| 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 #library('js_helper'); | 5 #library('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('date_helper.dart'); | 10 #source('date_helper.dart'); |
| 11 #source('native_helper.dart'); |
| 11 #source('regexp_helper.dart'); | 12 #source('regexp_helper.dart'); |
| 12 #source('string_helper.dart'); | 13 #source('string_helper.dart'); |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * Returns true if both arguments are numbers. | 16 * Returns true if both arguments are numbers. |
| 16 * | 17 * |
| 17 * If only the first argument is a number, an | 18 * If only the first argument is a number, an |
| 18 * [IllegalArgumentException] with the other argument is thrown. | 19 * [IllegalArgumentException] with the other argument is thrown. |
| 19 */ | 20 */ |
| 20 bool checkNumbers(var a, var b) { | 21 bool checkNumbers(var a, var b) { |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 // TODO(ahe): Dynamic may be overridden. | 1173 // TODO(ahe): Dynamic may be overridden. |
| 1173 builtin$get$dynamic(receiver) => receiver; | 1174 builtin$get$dynamic(receiver) => receiver; |
| 1174 | 1175 |
| 1175 /** | 1176 /** |
| 1176 * Called by generated code to capture the stacktrace before throwing | 1177 * Called by generated code to capture the stacktrace before throwing |
| 1177 * an exception. | 1178 * an exception. |
| 1178 */ | 1179 */ |
| 1179 captureStackTrace(ex) { | 1180 captureStackTrace(ex) { |
| 1180 var jsError = JS('Object', @'new Error()'); | 1181 var jsError = JS('Object', @'new Error()'); |
| 1181 JS('void', @'#.dartException = #', jsError, ex); | 1182 JS('void', @'#.dartException = #', jsError, ex); |
| 1182 JS('void', @'''#.toString = #''', jsError, toStringWrapper); | 1183 JS('void', @'''#.toString = #''', jsError, JS_TO_CLOSURE(toStringWrapper)); |
| 1183 return jsError; | 1184 return jsError; |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 /** | 1187 /** |
| 1187 * This method is installed as JavaScript toString method on exception | 1188 * This method is installed as JavaScript toString method on exception |
| 1188 * objects in [captureStackTrace]. So JavaScript 'this' binds to an | 1189 * objects in [captureStackTrace]. So JavaScript 'this' binds to an |
| 1189 * instance of JavaScript Error to which we have added a property | 1190 * instance of JavaScript Error to which we have added a property |
| 1190 * 'dartException' which holds a Dart object. | 1191 * 'dartException' which holds a Dart object. |
| 1191 */ | 1192 */ |
| 1192 toStringWrapper() => JS('Object', @'this.dartException').toString(); | 1193 toStringWrapper() => JS('Object', @'this.dartException').toString(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 * closure when the Dart closure is passed to the DOM. | 1304 * closure when the Dart closure is passed to the DOM. |
| 1304 */ | 1305 */ |
| 1305 convertDartClosureToJS(closure) { | 1306 convertDartClosureToJS(closure) { |
| 1306 if (closure === null) return null; | 1307 if (closure === null) return null; |
| 1307 var function = JS('var', @'#.$identity', closure); | 1308 var function = JS('var', @'#.$identity', closure); |
| 1308 if (JS('bool', @'!!#', function)) return function; | 1309 if (JS('bool', @'!!#', function)) return function; |
| 1309 | 1310 |
| 1310 function = JS("var", @"""function() { | 1311 function = JS("var", @"""function() { |
| 1311 return #(#, #, arguments.length, arguments[0], arguments[1]); | 1312 return #(#, #, arguments.length, arguments[0], arguments[1]); |
| 1312 }""", | 1313 }""", |
| 1313 invokeClosure, | 1314 JS_TO_CLOSURE(invokeClosure), |
| 1314 closure, | 1315 closure, |
| 1315 JS_CURRENT_ISOLATE()); | 1316 JS_CURRENT_ISOLATE()); |
| 1316 | 1317 |
| 1317 JS('void', @'#.$identity = #', closure, function); | 1318 JS('void', @'#.$identity = #', closure, function); |
| 1318 return function; | 1319 return function; |
| 1319 } | 1320 } |
| 1320 | 1321 |
| 1321 /** | 1322 /** |
| 1322 * Super class for Dart closures. | 1323 * Super class for Dart closures. |
| 1323 */ | 1324 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 } | 1357 } |
| 1357 | 1358 |
| 1358 /** | 1359 /** |
| 1359 * Represents the type of Null. The compiler treats this specially. | 1360 * Represents the type of Null. The compiler treats this specially. |
| 1360 */ | 1361 */ |
| 1361 class Null { | 1362 class Null { |
| 1362 factory Null() { | 1363 factory Null() { |
| 1363 throw UnsupportedOperationException('new Null()'); | 1364 throw UnsupportedOperationException('new Null()'); |
| 1364 } | 1365 } |
| 1365 } | 1366 } |
| OLD | NEW |