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('dart:_js_helper'); | 5 #library('dart:_js_helper'); |
6 | 6 |
7 #import('dart:coreimpl'); | 7 #import('dart:coreimpl'); |
8 #import('dart:collection'); | 8 #import('dart:collection'); |
9 | 9 |
10 #source('constant_map.dart'); | 10 #source('constant_map.dart'); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 return UNINTERCEPTED(-a); | 293 return UNINTERCEPTED(-a); |
294 } | 294 } |
295 | 295 |
296 index$slow(var a, var index) { | 296 index$slow(var a, var index) { |
297 if (a is String || isJsArray(a)) { | 297 if (a is String || isJsArray(a)) { |
298 if (index is !int) { | 298 if (index is !int) { |
299 if (index is !num) throw new ArgumentError(index); | 299 if (index is !num) throw new ArgumentError(index); |
300 if (!identical(index.truncate(), index)) throw new ArgumentError(index); | 300 if (!identical(index.truncate(), index)) throw new ArgumentError(index); |
301 } | 301 } |
302 if (index < 0 || index >= a.length) { | 302 if (index < 0 || index >= a.length) { |
303 throw new IndexOutOfRangeException(index); | 303 throw new RangeError.value(index); |
304 } | 304 } |
305 return JS('Object', r'#[#]', a, index); | 305 return JS('Object', r'#[#]', a, index); |
306 } | 306 } |
307 return UNINTERCEPTED(a[index]); | 307 return UNINTERCEPTED(a[index]); |
308 } | 308 } |
309 | 309 |
310 void indexSet$slow(var a, var index, var value) { | 310 void indexSet$slow(var a, var index, var value) { |
311 if (isJsArray(a)) { | 311 if (isJsArray(a)) { |
312 if (index is !int) { | 312 if (index is !int) { |
313 throw new ArgumentError(index); | 313 throw new ArgumentError(index); |
314 } | 314 } |
315 if (index < 0 || index >= a.length) { | 315 if (index < 0 || index >= a.length) { |
316 throw new IndexOutOfRangeException(index); | 316 throw new RangeError.value(index); |
317 } | 317 } |
318 checkMutable(a, 'indexed set'); | 318 checkMutable(a, 'indexed set'); |
319 JS('Object', r'#[#] = #', a, index, value); | 319 JS('Object', r'#[#] = #', a, index, value); |
320 return; | 320 return; |
321 } | 321 } |
322 UNINTERCEPTED(a[index] = value); | 322 UNINTERCEPTED(a[index] = value); |
323 } | 323 } |
324 | 324 |
325 checkMutable(list, reason) { | 325 checkMutable(list, reason) { |
326 if (JS('bool', r'!!(#.immutable$list)', list)) { | 326 if (JS('bool', r'!!(#.immutable$list)', list)) { |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 iae(argument) { | 722 iae(argument) { |
723 throw new ArgumentError(argument); | 723 throw new ArgumentError(argument); |
724 } | 724 } |
725 | 725 |
726 /** | 726 /** |
727 * Called by generated code to throw an index-out-of-range exception, | 727 * Called by generated code to throw an index-out-of-range exception, |
728 * for example, if a bounds check fails in an optimized indexed | 728 * for example, if a bounds check fails in an optimized indexed |
729 * access. | 729 * access. |
730 */ | 730 */ |
731 ioore(index) { | 731 ioore(index) { |
732 throw new IndexOutOfRangeException(index); | 732 throw new RangeError.value(index); |
733 } | 733 } |
734 | 734 |
735 listInsertRange(receiver, start, length, initialValue) { | 735 listInsertRange(receiver, start, length, initialValue) { |
736 if (length == 0) { | 736 if (length == 0) { |
737 return; | 737 return; |
738 } | 738 } |
739 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. | 739 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. |
740 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. | 740 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. |
741 if (length is !int) throw new ArgumentError(length); | 741 if (length is !int) throw new ArgumentError(length); |
742 if (length < 0) throw new ArgumentError(length); | 742 if (length < 0) throw new ArgumentError(length); |
743 if (start is !int) throw new ArgumentError(start); | 743 if (start is !int) throw new ArgumentError(start); |
744 | 744 |
745 var receiverLength = JS('num', r'#.length', receiver); | 745 var receiverLength = JS('num', r'#.length', receiver); |
746 if (start < 0 || start > receiverLength) { | 746 if (start < 0 || start > receiverLength) { |
747 throw new IndexOutOfRangeException(start); | 747 throw new RangeError.value(start); |
748 } | 748 } |
749 receiver.length = receiverLength + length; | 749 receiver.length = receiverLength + length; |
750 Arrays.copy(receiver, | 750 Arrays.copy(receiver, |
751 start, | 751 start, |
752 receiver, | 752 receiver, |
753 start + length, | 753 start + length, |
754 receiverLength - start); | 754 receiverLength - start); |
755 if (initialValue != null) { | 755 if (initialValue != null) { |
756 for (int i = start; i < start + length; i++) { | 756 for (int i = start; i < start + length; i++) { |
757 receiver[i] = initialValue; | 757 receiver[i] = initialValue; |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 JS('void', r'#.runtimeTypeCache[#] = #', JS_CURRENT_ISOLATE(), key, | 1460 JS('void', r'#.runtimeTypeCache[#] = #', JS_CURRENT_ISOLATE(), key, |
1461 runtimeType); | 1461 runtimeType); |
1462 } | 1462 } |
1463 return runtimeType; | 1463 return runtimeType; |
1464 } | 1464 } |
1465 | 1465 |
1466 String getRuntimeTypeString(var object) { | 1466 String getRuntimeTypeString(var object) { |
1467 var typeInfo = JS('Object', r'#.builtin$typeInfo', object); | 1467 var typeInfo = JS('Object', r'#.builtin$typeInfo', object); |
1468 return JS('String', r'#.runtimeType', typeInfo); | 1468 return JS('String', r'#.runtimeType', typeInfo); |
1469 } | 1469 } |
OLD | NEW |