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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_array.dart

Issue 1187553005: Revert "Better messages for optimized index errors." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
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 part of _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The interceptor class for [List]. The compiler recognizes this 8 * The interceptor class for [List]. The compiler recognizes this
9 * class as an interceptor, and changes references to [:this:] to 9 * class as an interceptor, and changes references to [:this:] to
10 * actually use the receiver of the method, which is generated as an extra 10 * actually use the receiver of the method, which is generated as an extra
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 Set<E> toSet() => new Set<E>.from(this); 568 Set<E> toSet() => new Set<E>.from(this);
569 569
570 Iterator<E> get iterator => new ArrayIterator<E>(this); 570 Iterator<E> get iterator => new ArrayIterator<E>(this);
571 571
572 int get hashCode => Primitives.objectHashCode(this); 572 int get hashCode => Primitives.objectHashCode(this);
573 573
574 int get length => JS('JSUInt32', r'#.length', this); 574 int get length => JS('JSUInt32', r'#.length', this);
575 575
576 void set length(int newLength) { 576 void set length(int newLength) {
577 checkGrowable('set length'); 577 checkGrowable('set length');
578 if (newLength is !int) { 578 if (newLength is !int) throw new ArgumentError(newLength);
579 throw new ArgumentError.value(newLength, 'newLength'); 579 if (newLength < 0) throw new RangeError.value(newLength);
580 }
581 // TODO(sra): Remove this test and let JavaScript throw an error.
582 if (newLength < 0) {
583 throw new RangeError.range(newLength, 0, null, 'newLength');
584 }
585 // JavaScript with throw a RangeError for numbers that are too big. The
586 // message does not contain the value.
587 JS('void', r'#.length = #', this, newLength); 580 JS('void', r'#.length = #', this, newLength);
588 } 581 }
589 582
590 E operator [](int index) { 583 E operator [](int index) {
591 if (index is !int) throw diagnoseIndexError(this, index); 584 if (index is !int) throw new ArgumentError(index);
592 if (index >= length || index < 0) throw diagnoseIndexError(this, index); 585 if (index >= length || index < 0) throw new RangeError.value(index);
593 return JS('var', '#[#]', this, index); 586 return JS('var', '#[#]', this, index);
594 } 587 }
595 588
596 void operator []=(int index, E value) { 589 void operator []=(int index, E value) {
597 checkMutable('indexed set'); 590 checkMutable('indexed set');
598 if (index is !int) throw diagnoseIndexError(this, index); 591 if (index is !int) throw new ArgumentError(index);
599 if (index >= length || index < 0) throw diagnoseIndexError(this, index); 592 if (index >= length || index < 0) throw new RangeError.value(index);
600 JS('void', r'#[#] = #', this, index, value); 593 JS('void', r'#[#] = #', this, index, value);
601 } 594 }
602 595
603 Map<int, E> asMap() { 596 Map<int, E> asMap() {
604 return new ListMapView<E>(this); 597 return new ListMapView<E>(this);
605 } 598 }
606 } 599 }
607 600
608 /** 601 /**
609 * Dummy subclasses that allow the backend to track more precise 602 * Dummy subclasses that allow the backend to track more precise
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 640
648 if (_index >= length) { 641 if (_index >= length) {
649 _current = null; 642 _current = null;
650 return false; 643 return false;
651 } 644 }
652 _current = _iterable[_index]; 645 _current = _iterable[_index];
653 _index++; 646 _index++;
654 return true; 647 return true;
655 } 648 }
656 } 649 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/interceptors.dart ('k') | sdk/lib/_internal/compiler/js_lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698