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

Side by Side Diff: runtime/lib/simd128.dart

Issue 12817003: Change getRange to sublist. Make getRange deprecated. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 patch class Float32x4 { 5 patch class Float32x4 {
6 /* patch */ factory Float32x4(double x, double y, double z, double w) { 6 /* patch */ factory Float32x4(double x, double y, double z, double w) {
7 return new _Float32x4(x, y, z, w); 7 return new _Float32x4(x, y, z, w);
8 } 8 }
9 /* patch */ factory Float32x4.zero() { 9 /* patch */ factory Float32x4.zero() {
10 return new _Float32x4.zero(); 10 return new _Float32x4.zero();
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 576 }
577 Float32x4 _toFloat32x4() native "Uint32x4_toFloat32x4"; 577 Float32x4 _toFloat32x4() native "Uint32x4_toFloat32x4";
578 } 578 }
579 579
580 580
581 class _Float32x4Array extends _ByteArrayBase 581 class _Float32x4Array extends _ByteArrayBase
582 implements Float32x4List { 582 implements Float32x4List {
583 factory _Float32x4Array(int length) { 583 factory _Float32x4Array(int length) {
584 return _new(length); 584 return _new(length);
585 } 585 }
586
586 factory _Float32x4Array.view(ByteArray array, 587 factory _Float32x4Array.view(ByteArray array,
587 [int start = 0, int length]) { 588 [int start = 0, int length]) {
588 if (length == null) { 589 if (length == null) {
589 length = (array.lengthInBytes() - start) ~/ _BYTES_PER_ELEMENT; 590 length = (array.lengthInBytes() - start) ~/ _BYTES_PER_ELEMENT;
590 } 591 }
591 return new _Float32x4ArrayView(array, start, length); 592 return new _Float32x4ArrayView(array, start, length);
592 } 593 }
594
593 Float32x4 operator [](int index) { 595 Float32x4 operator [](int index) {
594 return _getIndexed(index); 596 return _getIndexed(index);
595 } 597 }
598
596 int operator []=(int index, Float32x4 value) { 599 int operator []=(int index, Float32x4 value) {
597 _setIndexed(index, value); 600 _setIndexed(index, value);
598 } 601 }
602
599 Iterator<Float32x4> get iterator { 603 Iterator<Float32x4> get iterator {
600 return new _ByteArrayIterator<Float32x4>(this); 604 return new _ByteArrayIterator<Float32x4>(this);
601 } 605 }
602 List<Float32x4> getRange(int start, int length) { 606
607 List<Float32x4> sublist(int start, [int end]) {
608 if (end == null) end = length;
609 int length = end - start;
603 _rangeCheck(this.length, start, length); 610 _rangeCheck(this.length, start, length);
604 List<Float32x4> result = _new(length); 611 List<Float32x4> result = _new(length);
605 result.setRange(0, length, this, start); 612 result.setRange(0, length, this, start);
606 return result; 613 return result;
607 } 614 }
615
616 List<Float32x4> getRange(int start, int length) {
617 return sublist(start, start + length);
618 }
619
608 void setRange(int start, int length, List<Float32x4> from, 620 void setRange(int start, int length, List<Float32x4> from,
609 [int startFrom = 0]) { 621 [int startFrom = 0]) {
610 if (from is _Float32x4Array) { 622 if (from is _Float32x4Array) {
611 _setRange(start * _BYTES_PER_ELEMENT, 623 _setRange(start * _BYTES_PER_ELEMENT,
612 length * _BYTES_PER_ELEMENT, 624 length * _BYTES_PER_ELEMENT,
613 from, 625 from,
614 startFrom * _BYTES_PER_ELEMENT); 626 startFrom * _BYTES_PER_ELEMENT);
615 } else { 627 } else {
616 IterableMixinWorkaround.setRangeList( 628 IterableMixinWorkaround.setRangeList(
617 this, start, length, from, startFrom); 629 this, start, length, from, startFrom);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 String message = "$index must be in the range [0..$length)"; 672 String message = "$index must be in the range [0..$length)";
661 throw new RangeError(message); 673 throw new RangeError(message);
662 } 674 }
663 _array.setFloat32x4(_offset + (index * _BYTES_PER_ELEMENT), value); 675 _array.setFloat32x4(_offset + (index * _BYTES_PER_ELEMENT), value);
664 } 676 }
665 677
666 Iterator<Float32x4> get iterator { 678 Iterator<Float32x4> get iterator {
667 return new _ByteArrayIterator<Float32x4>(this); 679 return new _ByteArrayIterator<Float32x4>(this);
668 } 680 }
669 681
670 List<Float32x4> getRange(int start, int length) { 682 List<Float32x4> sublist(int start, [int end]) {
683 if (end == null) end = length;
684 int length = end - start;
671 _rangeCheck(this.length, start, length); 685 _rangeCheck(this.length, start, length);
672 List<Float32x4> result = new Float32List(length); 686 List<Float32x4> result = new Float32List(length);
673 result.setRange(0, length, this, start); 687 result.setRange(0, length, this, start);
674 return result; 688 return result;
675 } 689 }
676 690
691 List<Float32x4> getRange(int start, int length) {
692 return sublist(start, start + length);
693 }
694
677 void setRange(int start, int length, List<Float32x4> from, 695 void setRange(int start, int length, List<Float32x4> from,
678 [int startFrom = 0]) { 696 [int startFrom = 0]) {
679 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); 697 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
680 } 698 }
681 699
682 String toString() { 700 String toString() {
683 return Collections.collectionToString(this); 701 return Collections.collectionToString(this);
684 } 702 }
685 703
686 int bytesPerElement() { 704 int bytesPerElement() {
(...skipping 23 matching lines...) Expand all
710 } 728 }
711 729
712 int operator []=(int index, Float32x4 value) { 730 int operator []=(int index, Float32x4 value) {
713 _setIndexed(index, value); 731 _setIndexed(index, value);
714 } 732 }
715 733
716 Iterator<Float32x4> get iterator { 734 Iterator<Float32x4> get iterator {
717 return new _ByteArrayIterator<Float32x4>(this); 735 return new _ByteArrayIterator<Float32x4>(this);
718 } 736 }
719 737
720 List<Float32x4> getRange(int start, int length) { 738 List<Float32x4> sublist(int start, [int end]) {
739 if (end == null) end = length;
740 int length = end - start;
721 _rangeCheck(this.length, start, length); 741 _rangeCheck(this.length, start, length);
722 List<Float32x4> result = new Float32x4List(length); 742 List<Float32x4> result = new Float32x4List(length);
723 result.setRange(0, length, this, start); 743 result.setRange(0, length, this, start);
724 return result; 744 return result;
725 } 745 }
726 746
747 List<Float32x4> getRange(int start, int length) {
748 return sublist(start, start + length);
749 }
750
727 void setRange(int start, int length, List<Float32x4> from, 751 void setRange(int start, int length, List<Float32x4> from,
728 [int startFrom = 0]) { 752 [int startFrom = 0]) {
729 if (from is _ExternalFloat32x4Array) { 753 if (from is _ExternalFloat32x4Array) {
730 _setRange(start * _BYTES_PER_ELEMENT, 754 _setRange(start * _BYTES_PER_ELEMENT,
731 length * _BYTES_PER_ELEMENT, 755 length * _BYTES_PER_ELEMENT,
732 from, 756 from,
733 startFrom * _BYTES_PER_ELEMENT); 757 startFrom * _BYTES_PER_ELEMENT);
734 } else { 758 } else {
735 IterableMixinWorkaround.setRangeList( 759 IterableMixinWorkaround.setRangeList(
736 this, start, length, from, startFrom); 760 this, start, length, from, startFrom);
(...skipping 12 matching lines...) Expand all
749 return _length() * _BYTES_PER_ELEMENT; 773 return _length() * _BYTES_PER_ELEMENT;
750 } 774 }
751 775
752 static const int _BYTES_PER_ELEMENT = 16; 776 static const int _BYTES_PER_ELEMENT = 16;
753 777
754 Float32x4 _getIndexed(int index) 778 Float32x4 _getIndexed(int index)
755 native "ExternalFloat32x4Array_getIndexed"; 779 native "ExternalFloat32x4Array_getIndexed";
756 int _setIndexed(int index, Float32x4 value) 780 int _setIndexed(int index, Float32x4 value)
757 native "ExternalFloat32x4Array_setIndexed"; 781 native "ExternalFloat32x4Array_setIndexed";
758 } 782 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698