| 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('date_helper.dart'); | 9 #source('date_helper.dart'); |
| 10 #source('regexp_helper.dart'); | 10 #source('regexp_helper.dart'); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 if (isJsArray(receiver)) { | 271 if (isJsArray(receiver)) { |
| 272 checkGrowable(receiver, 'removeLast'); | 272 checkGrowable(receiver, 'removeLast'); |
| 273 if (receiver.length === 0) throw new IndexOutOfRangeException(-1); | 273 if (receiver.length === 0) throw new IndexOutOfRangeException(-1); |
| 274 return JS('Object', @'$0.pop()', receiver); | 274 return JS('Object', @'$0.pop()', receiver); |
| 275 } | 275 } |
| 276 return UNINTERCEPTED(receiver.removeLast()); | 276 return UNINTERCEPTED(receiver.removeLast()); |
| 277 } | 277 } |
| 278 | 278 |
| 279 builtin$filter$1(var receiver, var predicate) { | 279 builtin$filter$1(var receiver, var predicate) { |
| 280 checkNull(receiver); | 280 checkNull(receiver); |
| 281 if (isJsArray(receiver)) { | 281 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.filter(predicate)); |
| 282 return JS('Object', @'$0.filter(function(v) { return $1(v) === true; })', | 282 |
| 283 receiver, predicate); | 283 return Collections.filter(receiver, [], predicate); |
| 284 } | |
| 285 return UNINTERCEPTED(receiver.filter(predicate)); | |
| 286 } | 284 } |
| 287 | 285 |
| 288 | 286 |
| 289 builtin$get$length(var receiver) { | 287 builtin$get$length(var receiver) { |
| 290 checkNull(receiver); | 288 checkNull(receiver); |
| 291 if (receiver is String || isJsArray(receiver)) { | 289 if (receiver is String || isJsArray(receiver)) { |
| 292 return JS('num', @'$0.length', receiver); | 290 return JS('num', @'$0.length', receiver); |
| 293 } | 291 } |
| 294 return UNINTERCEPTED(receiver.length); | 292 return UNINTERCEPTED(receiver.length); |
| 295 } | 293 } |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 Arrays.copy(from, startFrom, receiver, start, length); | 800 Arrays.copy(from, startFrom, receiver, start, length); |
| 803 } | 801 } |
| 804 | 802 |
| 805 builtin$some$1(receiver, f) { | 803 builtin$some$1(receiver, f) { |
| 806 checkNull(receiver); | 804 checkNull(receiver); |
| 807 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.some(f)); | 805 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.some(f)); |
| 808 | 806 |
| 809 return Collections.some(receiver, f); | 807 return Collections.some(receiver, f); |
| 810 } | 808 } |
| 811 | 809 |
| 810 builtin$every$1(receiver, f) { |
| 811 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.every(f)); |
| 812 |
| 813 return Collections.every(receiver, f); |
| 814 } |
| 815 |
| 812 builtin$sort$1(receiver, compare) { | 816 builtin$sort$1(receiver, compare) { |
| 813 checkNull(receiver); | 817 checkNull(receiver); |
| 814 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort(compare)); | 818 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort(compare)); |
| 815 | 819 |
| 816 DualPivotQuicksort.sort(receiver, compare); | 820 DualPivotQuicksort.sort(receiver, compare); |
| 817 } | 821 } |
| 818 | 822 |
| 819 checkNull(object) { | 823 checkNull(object) { |
| 820 if (object === null) throw new NullPointerException(); | 824 if (object === null) throw new NullPointerException(); |
| 821 return object; | 825 return object; |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 } | 1281 } |
| 1278 } | 1282 } |
| 1279 } else if (JS('bool', @'$0 instanceof RangeError', ex)) { | 1283 } else if (JS('bool', @'$0 instanceof RangeError', ex)) { |
| 1280 var message = JS('String', @'$0.message', ex); | 1284 var message = JS('String', @'$0.message', ex); |
| 1281 if (message.contains('call stack')) { | 1285 if (message.contains('call stack')) { |
| 1282 return new StackOverflowException(); | 1286 return new StackOverflowException(); |
| 1283 } | 1287 } |
| 1284 } | 1288 } |
| 1285 return ex; | 1289 return ex; |
| 1286 } | 1290 } |
| OLD | NEW |