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

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

Issue 13137002: Adapt remaining dart:scalarlist tests to use dart:typeddata (Closed) Base URL: http://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
« no previous file with comments | « no previous file | runtime/tests/vm/dart/byte_array_optimized_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 classes for Int8List ..... Float64List and ByteData implementations. 5 // patch classes for Int8List ..... Float64List and ByteData implementations.
6 6
7 patch class Int8List { 7 patch class Int8List {
8 /* patch */ factory Int8List(int length) { 8 /* patch */ factory Int8List(int length) {
9 return new _Int8Array(length); 9 return new _Int8Array(length);
10 } 10 }
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 length = buffer.lengthInBytes; 586 length = buffer.lengthInBytes;
587 } 587 }
588 return new _Int8ArrayView(buffer, offsetInBytes, length); 588 return new _Int8ArrayView(buffer, offsetInBytes, length);
589 } 589 }
590 590
591 591
592 // Method(s) implementing List interface. 592 // Method(s) implementing List interface.
593 593
594 int operator[](int index) { 594 int operator[](int index) {
595 if (index < 0 || index >= length) { 595 if (index < 0 || index >= length) {
596 String message = "$index must be in the range [0..$length)"; 596 _throwRangeError(index, length);
597 throw new RangeError(message);
598 } 597 }
599 return _getInt8(index); 598 return _getInt8(index);
600 } 599 }
601 600
602 void operator[]=(int index, int value) { 601 void operator[]=(int index, int value) {
603 if (index < 0 || index >= length) { 602 if (index < 0 || index >= length) {
604 String message = "$index must be in the range [0..$length)"; 603 _throwRangeError(index, length);
605 throw new RangeError(message);
606 } 604 }
607 _setInt8(index, _toInt8(value)); 605 _setInt8(index, _toInt8(value));
608 } 606 }
609 607
610 Iterator<int> get iterator { 608 Iterator<int> get iterator {
611 return new _TypedListIterator<int>(this); 609 return new _TypedListIterator<int>(this);
612 } 610 }
613 611
614 612
615 // Method(s) implementing TypedData interface. 613 // Method(s) implementing TypedData interface.
(...skipping 29 matching lines...) Expand all
645 if (length == null) { 643 if (length == null) {
646 length = buffer.lengthInBytes; 644 length = buffer.lengthInBytes;
647 } 645 }
648 return new _Uint8ArrayView(buffer, offsetInBytes, length); 646 return new _Uint8ArrayView(buffer, offsetInBytes, length);
649 } 647 }
650 648
651 649
652 // Methods implementing List interface. 650 // Methods implementing List interface.
653 int operator[](int index) { 651 int operator[](int index) {
654 if (index < 0 || index >= length) { 652 if (index < 0 || index >= length) {
655 String message = "$index must be in the range [0..$length)"; 653 _throwRangeError(index, length);
656 throw new RangeError(message);
657 } 654 }
658 return _getUint8(index); 655 return _getUint8(index);
659 } 656 }
660 657
661 void operator[]=(int index, int value) { 658 void operator[]=(int index, int value) {
662 if (index < 0 || index >= length) { 659 if (index < 0 || index >= length) {
663 String message = "$index must be in the range [0..$length)"; 660 _throwRangeError(index, length);
664 throw new RangeError(message);
665 } 661 }
666 _setUint8(index, _toUint8(value)); 662 _setUint8(index, _toUint8(value));
667 } 663 }
668 664
669 Iterator<int> get iterator { 665 Iterator<int> get iterator {
670 return new _TypedListIterator<int>(this); 666 return new _TypedListIterator<int>(this);
671 } 667 }
672 668
673 669
674 // Methods implementing TypedData interface. 670 // Methods implementing TypedData interface.
(...skipping 29 matching lines...) Expand all
704 length = buffer.lengthInBytes; 700 length = buffer.lengthInBytes;
705 } 701 }
706 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); 702 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length);
707 } 703 }
708 704
709 705
710 // Methods implementing List interface. 706 // Methods implementing List interface.
711 707
712 int operator[](int index) { 708 int operator[](int index) {
713 if (index < 0 || index >= length) { 709 if (index < 0 || index >= length) {
714 String message = "$index must be in the range [0..$length)"; 710 _throwRangeError(index, length);
715 throw new RangeError(message);
716 } 711 }
717 return _getUint8(index); 712 return _getUint8(index);
718 } 713 }
719 714
720 void operator[]=(int index, int value) { 715 void operator[]=(int index, int value) {
721 if (index < 0 || index >= length) { 716 if (index < 0 || index >= length) {
722 String message = "$index must be in the range [0..$length)"; 717 _throwRangeError(index, length);
723 throw new RangeError(message);
724 } 718 }
725 _setUint8(index, _toClampedUint8(value)); 719 _setUint8(index, _toClampedUint8(value));
726 } 720 }
727 721
728 Iterator<int> get iterator { 722 Iterator<int> get iterator {
729 return new _TypedListIterator<int>(this); 723 return new _TypedListIterator<int>(this);
730 } 724 }
731 725
732 726
733 // Methods implementing TypedData interface. 727 // Methods implementing TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 Int16List.BYTES_PER_ELEMENT; 759 Int16List.BYTES_PER_ELEMENT;
766 } 760 }
767 return new _Int16ArrayView(buffer, offsetInBytes, length); 761 return new _Int16ArrayView(buffer, offsetInBytes, length);
768 } 762 }
769 763
770 764
771 // Method(s) implementing List interface. 765 // Method(s) implementing List interface.
772 766
773 int operator[](int index) { 767 int operator[](int index) {
774 if (index < 0 || index >= length) { 768 if (index < 0 || index >= length) {
775 String message = "$index must be in the range [0..$length)"; 769 _throwRangeError(index, length);
776 throw new RangeError(message);
777 } 770 }
778 return _getIndexedInt16(index); 771 return _getIndexedInt16(index);
779 } 772 }
780 773
781 void operator[]=(int index, int value) { 774 void operator[]=(int index, int value) {
782 if (index < 0 || index >= length) { 775 if (index < 0 || index >= length) {
783 String message = "$index must be in the range [0..$length)"; 776 _throwRangeError(index, length);
784 throw new RangeError(message);
785 } 777 }
786 _setIndexedInt16(index, _toInt16(value)); 778 _setIndexedInt16(index, _toInt16(value));
787 } 779 }
788 780
789 Iterator<int> get iterator { 781 Iterator<int> get iterator {
790 return new _TypedListIterator<int>(this); 782 return new _TypedListIterator<int>(this);
791 } 783 }
792 784
793 785
794 // Method(s) implementing TypedData interface. 786 // Method(s) implementing TypedData interface.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 Uint16List.BYTES_PER_ELEMENT; 826 Uint16List.BYTES_PER_ELEMENT;
835 } 827 }
836 return new _Uint16ArrayView(buffer, offsetInBytes, length); 828 return new _Uint16ArrayView(buffer, offsetInBytes, length);
837 } 829 }
838 830
839 831
840 // Method(s) implementing the List interface. 832 // Method(s) implementing the List interface.
841 833
842 int operator[](int index) { 834 int operator[](int index) {
843 if (index < 0 || index >= length) { 835 if (index < 0 || index >= length) {
844 String message = "$index must be in the range [0..$length)"; 836 _throwRangeError(index, length);
845 throw new RangeError(message);
846 } 837 }
847 return _getIndexedUint16(index); 838 return _getIndexedUint16(index);
848 } 839 }
849 840
850 void operator[]=(int index, int value) { 841 void operator[]=(int index, int value) {
851 if (index < 0 || index >= length) { 842 if (index < 0 || index >= length) {
852 String message = "$index must be in the range [0..$length)"; 843 _throwRangeError(index, length);
853 throw new RangeError(message);
854 } 844 }
855 _setIndexedUint16(index, _toUint16(value)); 845 _setIndexedUint16(index, _toUint16(value));
856 } 846 }
857 847
858 Iterator<int> get iterator { 848 Iterator<int> get iterator {
859 return new _TypedListIterator<int>(this); 849 return new _TypedListIterator<int>(this);
860 } 850 }
861 851
862 852
863 // Method(s) implementing the TypedData interface. 853 // Method(s) implementing the TypedData interface.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 Int32List.BYTES_PER_ELEMENT; 893 Int32List.BYTES_PER_ELEMENT;
904 } 894 }
905 return new _Int32ArrayView(buffer, offsetInBytes, length); 895 return new _Int32ArrayView(buffer, offsetInBytes, length);
906 } 896 }
907 897
908 898
909 // Method(s) implementing the List interface. 899 // Method(s) implementing the List interface.
910 900
911 int operator[](int index) { 901 int operator[](int index) {
912 if (index < 0 || index >= length) { 902 if (index < 0 || index >= length) {
913 String message = "$index must be in the range [0..$length)"; 903 _throwRangeError(index, length);
914 throw new RangeError(message);
915 } 904 }
916 return _getIndexedInt32(index); 905 return _getIndexedInt32(index);
917 } 906 }
918 907
919 void operator[]=(int index, int value) { 908 void operator[]=(int index, int value) {
920 if (index < 0 || index >= length) { 909 if (index < 0 || index >= length) {
921 String message = "$index must be in the range [0..$length)"; 910 _throwRangeError(index, length);
922 throw new RangeError(message);
923 } 911 }
924 _setIndexedInt32(index, _toInt32(value)); 912 _setIndexedInt32(index, _toInt32(value));
925 } 913 }
926 914
927 Iterator<int> get iterator { 915 Iterator<int> get iterator {
928 return new _TypedListIterator<int>(this); 916 return new _TypedListIterator<int>(this);
929 } 917 }
930 918
931 919
932 // Method(s) implementing TypedData interface. 920 // Method(s) implementing TypedData interface.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 Uint32List.BYTES_PER_ELEMENT; 960 Uint32List.BYTES_PER_ELEMENT;
973 } 961 }
974 return new _Uint32ArrayView(buffer, offsetInBytes, length); 962 return new _Uint32ArrayView(buffer, offsetInBytes, length);
975 } 963 }
976 964
977 965
978 // Method(s) implementing the List interface. 966 // Method(s) implementing the List interface.
979 967
980 int operator[](int index) { 968 int operator[](int index) {
981 if (index < 0 || index >= length) { 969 if (index < 0 || index >= length) {
982 String message = "$index must be in the range [0..$length)"; 970 _throwRangeError(index, length);
983 throw new RangeError(message);
984 } 971 }
985 return _getIndexedUint32(index); 972 return _getIndexedUint32(index);
986 } 973 }
987 974
988 void operator[]=(int index, int value) { 975 void operator[]=(int index, int value) {
989 if (index < 0 || index >= length) { 976 if (index < 0 || index >= length) {
990 String message = "$index must be in the range [0..$length)"; 977 _throwRangeError(index, length);
991 throw new RangeError(message);
992 } 978 }
993 _setIndexedUint32(index, _toUint32(value)); 979 _setIndexedUint32(index, _toUint32(value));
994 } 980 }
995 981
996 Iterator<int> get iterator { 982 Iterator<int> get iterator {
997 return new _TypedListIterator<int>(this); 983 return new _TypedListIterator<int>(this);
998 } 984 }
999 985
1000 986
1001 // Method(s) implementing the TypedData interface. 987 // Method(s) implementing the TypedData interface.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 Int32List.BYTES_PER_ELEMENT; 1027 Int32List.BYTES_PER_ELEMENT;
1042 } 1028 }
1043 return new _Int64ArrayView(buffer, offsetInBytes, length); 1029 return new _Int64ArrayView(buffer, offsetInBytes, length);
1044 } 1030 }
1045 1031
1046 1032
1047 // Method(s) implementing the List interface. 1033 // Method(s) implementing the List interface.
1048 1034
1049 int operator[](int index) { 1035 int operator[](int index) {
1050 if (index < 0 || index >= length) { 1036 if (index < 0 || index >= length) {
1051 String message = "$index must be in the range [0..$length)"; 1037 _throwRangeError(index, length);
1052 throw new RangeError(message);
1053 } 1038 }
1054 return _getIndexedInt64(index); 1039 return _getIndexedInt64(index);
1055 } 1040 }
1056 1041
1057 void operator[]=(int index, int value) { 1042 void operator[]=(int index, int value) {
1058 if (index < 0 || index >= length) { 1043 if (index < 0 || index >= length) {
1059 String message = "$index must be in the range [0..$length)"; 1044 _throwRangeError(index, length);
1060 throw new RangeError(message);
1061 } 1045 }
1062 _setIndexedInt64(index, _toInt64(value)); 1046 _setIndexedInt64(index, _toInt64(value));
1063 } 1047 }
1064 1048
1065 Iterator<int> get iterator { 1049 Iterator<int> get iterator {
1066 return new _TypedListIterator<int>(this); 1050 return new _TypedListIterator<int>(this);
1067 } 1051 }
1068 1052
1069 1053
1070 // Method(s) implementing the TypedData interface. 1054 // Method(s) implementing the TypedData interface.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 Uint64List.BYTES_PER_ELEMENT; 1094 Uint64List.BYTES_PER_ELEMENT;
1111 } 1095 }
1112 return new _Uint64ArrayView(buffer, offsetInBytes, length); 1096 return new _Uint64ArrayView(buffer, offsetInBytes, length);
1113 } 1097 }
1114 1098
1115 1099
1116 // Method(s) implementing the List interface. 1100 // Method(s) implementing the List interface.
1117 1101
1118 int operator[](int index) { 1102 int operator[](int index) {
1119 if (index < 0 || index >= length) { 1103 if (index < 0 || index >= length) {
1120 String message = "$index must be in the range [0..$length)"; 1104 _throwRangeError(index, length);
1121 throw new RangeError(message);
1122 } 1105 }
1123 return _getIndexedUint64(index); 1106 return _getIndexedUint64(index);
1124 } 1107 }
1125 1108
1126 void operator[]=(int index, int value) { 1109 void operator[]=(int index, int value) {
1127 if (index < 0 || index >= length) { 1110 if (index < 0 || index >= length) {
1128 String message = "$index must be in the range [0..$length)"; 1111 _throwRangeError(index, length);
1129 throw new RangeError(message);
1130 } 1112 }
1131 _setIndexedUint64(index, _toUint64(value)); 1113 _setIndexedUint64(index, _toUint64(value));
1132 } 1114 }
1133 1115
1134 Iterator<int> get iterator { 1116 Iterator<int> get iterator {
1135 return new _TypedListIterator<int>(this); 1117 return new _TypedListIterator<int>(this);
1136 } 1118 }
1137 1119
1138 1120
1139 // Method(s) implementing the TypedData interface. 1121 // Method(s) implementing the TypedData interface.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 Float32List.BYTES_PER_ELEMENT; 1161 Float32List.BYTES_PER_ELEMENT;
1180 } 1162 }
1181 return new _Float32ArrayView(buffer, offsetInBytes, length); 1163 return new _Float32ArrayView(buffer, offsetInBytes, length);
1182 } 1164 }
1183 1165
1184 1166
1185 // Method(s) implementing the List interface. 1167 // Method(s) implementing the List interface.
1186 1168
1187 double operator[](int index) { 1169 double operator[](int index) {
1188 if (index < 0 || index >= length) { 1170 if (index < 0 || index >= length) {
1189 String message = "$index must be in the range [0..$length)"; 1171 _throwRangeError(index, length);
1190 throw new RangeError(message);
1191 } 1172 }
1192 return _getIndexedFloat32(index); 1173 return _getIndexedFloat32(index);
1193 } 1174 }
1194 1175
1195 void operator[]=(int index, double value) { 1176 void operator[]=(int index, double value) {
1196 if (index < 0 || index >= length) { 1177 if (index < 0 || index >= length) {
1197 String message = "$index must be in the range [0..$length)"; 1178 _throwRangeError(index, length);
1198 throw new RangeError(message);
1199 } 1179 }
1200 _setIndexedFloat32(index, value); 1180 _setIndexedFloat32(index, value);
1201 } 1181 }
1202 1182
1203 Iterator<double> get iterator { 1183 Iterator<double> get iterator {
1204 return new _TypedListIterator<double>(this); 1184 return new _TypedListIterator<double>(this);
1205 } 1185 }
1206 1186
1207 1187
1208 // Method(s) implementing the TypedData interface. 1188 // Method(s) implementing the TypedData interface.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 Float64List.BYTES_PER_ELEMENT; 1228 Float64List.BYTES_PER_ELEMENT;
1249 } 1229 }
1250 return new _Float64ArrayView(buffer, offsetInBytes, length); 1230 return new _Float64ArrayView(buffer, offsetInBytes, length);
1251 } 1231 }
1252 1232
1253 1233
1254 // Method(s) implementing the List interface. 1234 // Method(s) implementing the List interface.
1255 1235
1256 double operator[](int index) { 1236 double operator[](int index) {
1257 if (index < 0 || index >= length) { 1237 if (index < 0 || index >= length) {
1258 String message = "$index must be in the range [0..$length)"; 1238 _throwRangeError(index, length);
1259 throw new RangeError(message);
1260 } 1239 }
1261 return _getIndexedFloat64(index); 1240 return _getIndexedFloat64(index);
1262 } 1241 }
1263 1242
1264 void operator[]=(int index, double value) { 1243 void operator[]=(int index, double value) {
1265 if (index < 0 || index >= length) { 1244 if (index < 0 || index >= length) {
1266 String message = "$index must be in the range [0..$length)"; 1245 _throwRangeError(index, length);
1267 throw new RangeError(message);
1268 } 1246 }
1269 _setIndexedFloat64(index, value); 1247 _setIndexedFloat64(index, value);
1270 } 1248 }
1271 1249
1272 Iterator<double> get iterator { 1250 Iterator<double> get iterator {
1273 return new _TypedListIterator<double>(this); 1251 return new _TypedListIterator<double>(this);
1274 } 1252 }
1275 1253
1276 1254
1277 // Method(s) implementing the TypedData interface. 1255 // Method(s) implementing the TypedData interface.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 if (length == null) { 1292 if (length == null) {
1315 length = (buffer.lengthInBytes - offsetInBytes) ~/ 1293 length = (buffer.lengthInBytes - offsetInBytes) ~/
1316 Float32x4List.BYTES_PER_ELEMENT; 1294 Float32x4List.BYTES_PER_ELEMENT;
1317 } 1295 }
1318 return new _Float32x4ArrayView(buffer, offsetInBytes, length); 1296 return new _Float32x4ArrayView(buffer, offsetInBytes, length);
1319 } 1297 }
1320 1298
1321 1299
1322 Float32x4 operator[](int index) { 1300 Float32x4 operator[](int index) {
1323 if (index < 0 || index >= length) { 1301 if (index < 0 || index >= length) {
1324 String message = "$index must be in the range [0..$length)"; 1302 _throwRangeError(index, length);
1325 throw new RangeError(message);
1326 } 1303 }
1327 return _getIndexedFloat32x4(index); 1304 return _getIndexedFloat32x4(index);
1328 } 1305 }
1329 1306
1330 void operator[]=(int index, Float32x4 value) { 1307 void operator[]=(int index, Float32x4 value) {
1331 if (index < 0 || index >= length) { 1308 if (index < 0 || index >= length) {
1332 String message = "$index must be in the range [0..$length)"; 1309 _throwRangeError(index, length);
1333 throw new RangeError(message);
1334 } 1310 }
1335 _setIndexedFloat32x4(index, value); 1311 _setIndexedFloat32x4(index, value);
1336 } 1312 }
1337 1313
1338 Iterator<Float32x4> get iterator { 1314 Iterator<Float32x4> get iterator {
1339 return new _TypedListIterator<Float32x4>(this); 1315 return new _TypedListIterator<Float32x4>(this);
1340 } 1316 }
1341 1317
1342 1318
1343 // Method(s) implementing the TypedData interface. 1319 // Method(s) implementing the TypedData interface.
(...skipping 29 matching lines...) Expand all
1373 String message = "$length must be greater than 0"; 1349 String message = "$length must be greater than 0";
1374 throw new ArgumentError(message); 1350 throw new ArgumentError(message);
1375 } 1351 }
1376 return _new(length); 1352 return _new(length);
1377 } 1353 }
1378 1354
1379 1355
1380 // Method(s) implementing the List interface. 1356 // Method(s) implementing the List interface.
1381 int operator[](int index) { 1357 int operator[](int index) {
1382 if (index < 0 || index >= length) { 1358 if (index < 0 || index >= length) {
1383 String message = "$index must be in the range [0..$length)"; 1359 _throwRangeError(index, length);
1384 throw new RangeError(message);
1385 } 1360 }
1386 return _getInt8(index); 1361 return _getInt8(index);
1387 } 1362 }
1388 1363
1389 void operator[]=(int index, int value) { 1364 void operator[]=(int index, int value) {
1390 if (index < 0 || index >= length) { 1365 if (index < 0 || index >= length) {
1391 String message = "$index must be in the range [0..$length)"; 1366 _throwRangeError(index, length);
1392 throw new RangeError(message);
1393 } 1367 }
1394 _setInt8(index, value); 1368 _setInt8(index, value);
1395 } 1369 }
1396 1370
1397 Iterator<int> get iterator { 1371 Iterator<int> get iterator {
1398 return new _TypedListIterator<int>(this); 1372 return new _TypedListIterator<int>(this);
1399 } 1373 }
1400 1374
1401 1375
1402 // Method(s) implementing the TypedData interface. 1376 // Method(s) implementing the TypedData interface.
(...skipping 23 matching lines...) Expand all
1426 throw new ArgumentError(message); 1400 throw new ArgumentError(message);
1427 } 1401 }
1428 return _new(length); 1402 return _new(length);
1429 } 1403 }
1430 1404
1431 1405
1432 // Method(s) implementing the List interface. 1406 // Method(s) implementing the List interface.
1433 1407
1434 int operator[](int index) { 1408 int operator[](int index) {
1435 if (index < 0 || index >= length) { 1409 if (index < 0 || index >= length) {
1436 String message = "$index must be in the range [0..$length)"; 1410 _throwRangeError(index, length);
1437 throw new RangeError(message);
1438 } 1411 }
1439 return _getUint8(index); 1412 return _getUint8(index);
1440 } 1413 }
1441 1414
1442 void operator[]=(int index, int value) { 1415 void operator[]=(int index, int value) {
1443 if (index < 0 || index >= length) { 1416 if (index < 0 || index >= length) {
1444 String message = "$index must be in the range [0..$length)"; 1417 _throwRangeError(index, length);
1445 throw new RangeError(message);
1446 } 1418 }
1447 _setUint8(index, _toUint8(value)); 1419 _setUint8(index, _toUint8(value));
1448 } 1420 }
1449 1421
1450 Iterator<int> get iterator { 1422 Iterator<int> get iterator {
1451 return new _TypedListIterator<int>(this); 1423 return new _TypedListIterator<int>(this);
1452 } 1424 }
1453 1425
1454 1426
1455 // Method(s) implementing the TypedData interface. 1427 // Method(s) implementing the TypedData interface.
(...skipping 23 matching lines...) Expand all
1479 throw new ArgumentError(message); 1451 throw new ArgumentError(message);
1480 } 1452 }
1481 return _new(length); 1453 return _new(length);
1482 } 1454 }
1483 1455
1484 1456
1485 // Method(s) implementing the List interface. 1457 // Method(s) implementing the List interface.
1486 1458
1487 int operator[](int index) { 1459 int operator[](int index) {
1488 if (index < 0 || index >= length) { 1460 if (index < 0 || index >= length) {
1489 String message = "$index must be in the range [0..$length)"; 1461 _throwRangeError(index, length);
1490 throw new RangeError(message);
1491 } 1462 }
1492 return _getUint8(index); 1463 return _getUint8(index);
1493 } 1464 }
1494 1465
1495 void operator[]=(int index, int value) { 1466 void operator[]=(int index, int value) {
1496 if (index < 0 || index >= length) { 1467 if (index < 0 || index >= length) {
1497 String message = "$index must be in the range [0..$length)"; 1468 _throwRangeError(index, length);
1498 throw new RangeError(message);
1499 } 1469 }
1500 _setUint8(index, _toClampedUint8(value)); 1470 _setUint8(index, _toClampedUint8(value));
1501 } 1471 }
1502 1472
1503 Iterator<int> get iterator { 1473 Iterator<int> get iterator {
1504 return new _TypedListIterator<int>(this); 1474 return new _TypedListIterator<int>(this);
1505 } 1475 }
1506 1476
1507 1477
1508 // Method(s) implementing the TypedData interface. 1478 // Method(s) implementing the TypedData interface.
(...skipping 23 matching lines...) Expand all
1532 throw new ArgumentError(message); 1502 throw new ArgumentError(message);
1533 } 1503 }
1534 return _new(length); 1504 return _new(length);
1535 } 1505 }
1536 1506
1537 1507
1538 // Method(s) implementing the List interface. 1508 // Method(s) implementing the List interface.
1539 1509
1540 int operator[](int index) { 1510 int operator[](int index) {
1541 if (index < 0 || index >= length) { 1511 if (index < 0 || index >= length) {
1542 String message = "$index must be in the range [0..$length)"; 1512 _throwRangeError(index, length);
1543 throw new RangeError(message);
1544 } 1513 }
1545 return _getIndexedInt16(index); 1514 return _getIndexedInt16(index);
1546 } 1515 }
1547 1516
1548 void operator[]=(int index, int value) { 1517 void operator[]=(int index, int value) {
1549 if (index < 0 || index >= length) { 1518 if (index < 0 || index >= length) {
1550 String message = "$index must be in the range [0..$length)"; 1519 _throwRangeError(index, length);
1551 throw new RangeError(message);
1552 } 1520 }
1553 _setIndexedInt16(index, _toInt16(value)); 1521 _setIndexedInt16(index, _toInt16(value));
1554 } 1522 }
1555 1523
1556 Iterator<int> get iterator { 1524 Iterator<int> get iterator {
1557 return new _TypedListIterator<int>(this); 1525 return new _TypedListIterator<int>(this);
1558 } 1526 }
1559 1527
1560 1528
1561 // Method(s) implementing the TypedData interface. 1529 // Method(s) implementing the TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 throw new ArgumentError(message); 1561 throw new ArgumentError(message);
1594 } 1562 }
1595 return _new(length); 1563 return _new(length);
1596 } 1564 }
1597 1565
1598 1566
1599 // Method(s) implementing the List interface. 1567 // Method(s) implementing the List interface.
1600 1568
1601 int operator[](int index) { 1569 int operator[](int index) {
1602 if (index < 0 || index >= length) { 1570 if (index < 0 || index >= length) {
1603 String message = "$index must be in the range [0..$length)"; 1571 _throwRangeError(index, length);
1604 throw new RangeError(message);
1605 } 1572 }
1606 return _getIndexedUint16(index); 1573 return _getIndexedUint16(index);
1607 } 1574 }
1608 1575
1609 void operator[]=(int index, int value) { 1576 void operator[]=(int index, int value) {
1610 if (index < 0 || index >= length) { 1577 if (index < 0 || index >= length) {
1611 String message = "$index must be in the range [0..$length)"; 1578 _throwRangeError(index, length);
1612 throw new RangeError(message);
1613 } 1579 }
1614 _setIndexedUint16(index, _toUint16(value)); 1580 _setIndexedUint16(index, _toUint16(value));
1615 } 1581 }
1616 1582
1617 Iterator<int> get iterator { 1583 Iterator<int> get iterator {
1618 return new _TypedListIterator<int>(this); 1584 return new _TypedListIterator<int>(this);
1619 } 1585 }
1620 1586
1621 1587
1622 // Method(s) implementing the TypedData interface. 1588 // Method(s) implementing the TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 throw new ArgumentError(message); 1620 throw new ArgumentError(message);
1655 } 1621 }
1656 return _new(length); 1622 return _new(length);
1657 } 1623 }
1658 1624
1659 1625
1660 // Method(s) implementing the List interface. 1626 // Method(s) implementing the List interface.
1661 1627
1662 int operator[](int index) { 1628 int operator[](int index) {
1663 if (index < 0 || index >= length) { 1629 if (index < 0 || index >= length) {
1664 String message = "$index must be in the range [0..$length)"; 1630 _throwRangeError(index, length);
1665 throw new RangeError(message);
1666 } 1631 }
1667 return _getIndexedInt32(index); 1632 return _getIndexedInt32(index);
1668 } 1633 }
1669 1634
1670 void operator[]=(int index, int value) { 1635 void operator[]=(int index, int value) {
1671 if (index < 0 || index >= length) { 1636 if (index < 0 || index >= length) {
1672 String message = "$index must be in the range [0..$length)"; 1637 _throwRangeError(index, length);
1673 throw new RangeError(message);
1674 } 1638 }
1675 _setIndexedInt32(index, _toInt32(value)); 1639 _setIndexedInt32(index, _toInt32(value));
1676 } 1640 }
1677 1641
1678 Iterator<int> get iterator { 1642 Iterator<int> get iterator {
1679 return new _TypedListIterator<int>(this); 1643 return new _TypedListIterator<int>(this);
1680 } 1644 }
1681 1645
1682 1646
1683 // Method(s) implementing the TypedData interface. 1647 // Method(s) implementing the TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 throw new ArgumentError(message); 1679 throw new ArgumentError(message);
1716 } 1680 }
1717 return _new(length); 1681 return _new(length);
1718 } 1682 }
1719 1683
1720 1684
1721 // Method(s) implementing the List interface. 1685 // Method(s) implementing the List interface.
1722 1686
1723 int operator[](int index) { 1687 int operator[](int index) {
1724 if (index < 0 || index >= length) { 1688 if (index < 0 || index >= length) {
1725 String message = "$index must be in the range [0..$length)"; 1689 _throwRangeError(index, length);
1726 throw new RangeError(message);
1727 } 1690 }
1728 return _getIndexedUint32(index); 1691 return _getIndexedUint32(index);
1729 } 1692 }
1730 1693
1731 void operator[]=(int index, int value) { 1694 void operator[]=(int index, int value) {
1732 if (index < 0 || index >= length) { 1695 if (index < 0 || index >= length) {
1733 String message = "$index must be in the range [0..$length)"; 1696 _throwRangeError(index, length);
1734 throw new RangeError(message);
1735 } 1697 }
1736 _setIndexedUint32(index, _toUint32(value)); 1698 _setIndexedUint32(index, _toUint32(value));
1737 } 1699 }
1738 1700
1739 Iterator<int> get iterator { 1701 Iterator<int> get iterator {
1740 return new _TypedListIterator<int>(this); 1702 return new _TypedListIterator<int>(this);
1741 } 1703 }
1742 1704
1743 1705
1744 // Method(s) implementing the TypedData interface. 1706 // Method(s) implementing the TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 throw new ArgumentError(message); 1738 throw new ArgumentError(message);
1777 } 1739 }
1778 return _new(length); 1740 return _new(length);
1779 } 1741 }
1780 1742
1781 1743
1782 // Method(s) implementing the List interface. 1744 // Method(s) implementing the List interface.
1783 1745
1784 int operator[](int index) { 1746 int operator[](int index) {
1785 if (index < 0 || index >= length) { 1747 if (index < 0 || index >= length) {
1786 String message = "$index must be in the range [0..$length)"; 1748 _throwRangeError(index, length);
1787 throw new RangeError(message);
1788 } 1749 }
1789 return _getIndexedInt64(index); 1750 return _getIndexedInt64(index);
1790 } 1751 }
1791 1752
1792 void operator[]=(int index, int value) { 1753 void operator[]=(int index, int value) {
1793 if (index < 0 || index >= length) { 1754 if (index < 0 || index >= length) {
1794 String message = "$index must be in the range [0..$length)"; 1755 _throwRangeError(index, length);
1795 throw new RangeError(message);
1796 } 1756 }
1797 _setIndexedInt64(index, _toInt64(value)); 1757 _setIndexedInt64(index, _toInt64(value));
1798 } 1758 }
1799 1759
1800 Iterator<int> get iterator { 1760 Iterator<int> get iterator {
1801 return new _TypedListIterator<int>(this); 1761 return new _TypedListIterator<int>(this);
1802 } 1762 }
1803 1763
1804 1764
1805 // Method(s) implementing the TypedData interface. 1765 // Method(s) implementing the TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 throw new ArgumentError(message); 1797 throw new ArgumentError(message);
1838 } 1798 }
1839 return _new(length); 1799 return _new(length);
1840 } 1800 }
1841 1801
1842 1802
1843 // Method(s) implementing the List interface. 1803 // Method(s) implementing the List interface.
1844 1804
1845 int operator[](int index) { 1805 int operator[](int index) {
1846 if (index < 0 || index >= length) { 1806 if (index < 0 || index >= length) {
1847 String message = "$index must be in the range [0..$length)"; 1807 _throwRangeError(index, length);
1848 throw new RangeError(message);
1849 } 1808 }
1850 return _getIndexedUint64(index); 1809 return _getIndexedUint64(index);
1851 } 1810 }
1852 1811
1853 void operator[]=(int index, int value) { 1812 void operator[]=(int index, int value) {
1854 if (index < 0 || index >= length) { 1813 if (index < 0 || index >= length) {
1855 String message = "$index must be in the range [0..$length)"; 1814 _throwRangeError(index, length);
1856 throw new RangeError(message);
1857 } 1815 }
1858 _setIndexedUint64(index, _toUint64(value)); 1816 _setIndexedUint64(index, _toUint64(value));
1859 } 1817 }
1860 1818
1861 Iterator<int> get iterator { 1819 Iterator<int> get iterator {
1862 return new _TypedListIterator<int>(this); 1820 return new _TypedListIterator<int>(this);
1863 } 1821 }
1864 1822
1865 1823
1866 // Method(s) implementing the TypedData interface. 1824 // Method(s) implementing the TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 throw new ArgumentError(message); 1856 throw new ArgumentError(message);
1899 } 1857 }
1900 return _new(length); 1858 return _new(length);
1901 } 1859 }
1902 1860
1903 1861
1904 // Method(s) implementing the List interface. 1862 // Method(s) implementing the List interface.
1905 1863
1906 double operator[](int index) { 1864 double operator[](int index) {
1907 if (index < 0 || index >= length) { 1865 if (index < 0 || index >= length) {
1908 String message = "$index must be in the range [0..$length)"; 1866 _throwRangeError(index, length);
1909 throw new RangeError(message);
1910 } 1867 }
1911 return _getIndexedFloat32(index); 1868 return _getIndexedFloat32(index);
1912 } 1869 }
1913 1870
1914 void operator[]=(int index, double value) { 1871 void operator[]=(int index, double value) {
1915 if (index < 0 || index >= length) { 1872 if (index < 0 || index >= length) {
1916 String message = "$index must be in the range [0..$length)"; 1873 _throwRangeError(index, length);
1917 throw new RangeError(message);
1918 } 1874 }
1919 _setIndexedFloat32(index, value); 1875 _setIndexedFloat32(index, value);
1920 } 1876 }
1921 1877
1922 Iterator<double> get iterator { 1878 Iterator<double> get iterator {
1923 return new _TypedListIterator<double>(this); 1879 return new _TypedListIterator<double>(this);
1924 } 1880 }
1925 1881
1926 1882
1927 // Method(s) implementing the TypedData interface. 1883 // Method(s) implementing the TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 throw new ArgumentError(message); 1915 throw new ArgumentError(message);
1960 } 1916 }
1961 return _new(length); 1917 return _new(length);
1962 } 1918 }
1963 1919
1964 1920
1965 // Method(s) implementing the List interface. 1921 // Method(s) implementing the List interface.
1966 1922
1967 double operator[](int index) { 1923 double operator[](int index) {
1968 if (index < 0 || index >= length) { 1924 if (index < 0 || index >= length) {
1969 String message = "$index must be in the range [0..$length)"; 1925 _throwRangeError(index, length);
1970 throw new RangeError(message);
1971 } 1926 }
1972 return _getIndexedFloat64(index); 1927 return _getIndexedFloat64(index);
1973 } 1928 }
1974 1929
1975 void operator[]=(int index, double value) { 1930 void operator[]=(int index, double value) {
1976 if (index < 0 || index >= length) { 1931 if (index < 0 || index >= length) {
1977 String message = "$index must be in the range [0..$length)"; 1932 _throwRangeError(index, length);
1978 throw new RangeError(message);
1979 } 1933 }
1980 _setIndexedFloat64(index, value); 1934 _setIndexedFloat64(index, value);
1981 } 1935 }
1982 1936
1983 Iterator<double> get iterator { 1937 Iterator<double> get iterator {
1984 return new _TypedListIterator<double>(this); 1938 return new _TypedListIterator<double>(this);
1985 } 1939 }
1986 1940
1987 1941
1988 // Method(s) implementing the TypedData interface. 1942 // Method(s) implementing the TypedData interface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 throw new ArgumentError(message); 1974 throw new ArgumentError(message);
2021 } 1975 }
2022 return _new(length); 1976 return _new(length);
2023 } 1977 }
2024 1978
2025 1979
2026 // Method(s) implementing the List interface. 1980 // Method(s) implementing the List interface.
2027 1981
2028 Float32x4 operator[](int index) { 1982 Float32x4 operator[](int index) {
2029 if (index < 0 || index >= length) { 1983 if (index < 0 || index >= length) {
2030 String message = "$index must be in the range [0..$length)"; 1984 _throwRangeError(index, length);
2031 throw new RangeError(message);
2032 } 1985 }
2033 return _getIndexedFloat32x4(index); 1986 return _getIndexedFloat32x4(index);
2034 } 1987 }
2035 1988
2036 void operator[]=(int index, Float32x4 value) { 1989 void operator[]=(int index, Float32x4 value) {
2037 if (index < 0 || index >= length) { 1990 if (index < 0 || index >= length) {
2038 String message = "$index must be in the range [0..$length)"; 1991 _throwRangeError(index, length);
2039 throw new RangeError(message);
2040 } 1992 }
2041 _setIndexedFloat32x4(index, value); 1993 _setIndexedFloat32x4(index, value);
2042 } 1994 }
2043 1995
2044 Iterator<Float32x4> get iterator { 1996 Iterator<Float32x4> get iterator {
2045 return new _TypedListIterator<Float32x4>(this); 1997 return new _TypedListIterator<Float32x4>(this);
2046 } 1998 }
2047 1999
2048 2000
2049 // Method(s) implementing the TypedData interface. 2001 // Method(s) implementing the TypedData interface.
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 2227
2276 class _Int8ArrayView extends _TypedListView implements Int8List { 2228 class _Int8ArrayView extends _TypedListView implements Int8List {
2277 // Constructor. 2229 // Constructor.
2278 _Int8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2230 _Int8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2279 : super(buffer, _offsetInBytes, 2231 : super(buffer, _offsetInBytes,
2280 _defaultIfNull(_length, 2232 _defaultIfNull(_length,
2281 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2233 ((buffer.lengthInBytes - _offsetInBytes) ~/
2282 Int8List.BYTES_PER_ELEMENT))) { 2234 Int8List.BYTES_PER_ELEMENT))) {
2283 _rangeCheck(buffer.lengthInBytes, 2235 _rangeCheck(buffer.lengthInBytes,
2284 _offsetInBytes, 2236 _offsetInBytes,
2285 _length * Int8List.BYTES_PER_ELEMENT); 2237 length * Int8List.BYTES_PER_ELEMENT);
2286 } 2238 }
2287 2239
2288 2240
2289 // Method(s) implementing List interface. 2241 // Method(s) implementing List interface.
2290 2242
2291 int operator[](int index) { 2243 int operator[](int index) {
2292 if (index < 0 || index >= length) { 2244 if (index < 0 || index >= length) {
2293 String message = "$index must be in the range [0..$length)"; 2245 _throwRangeError(index, length);
2294 throw new RangeError(message);
2295 } 2246 }
2296 return _typeddata._getInt8(offsetInBytes + 2247 return _typeddata._getInt8(offsetInBytes +
2297 (index * Int8List.BYTES_PER_ELEMENT)); 2248 (index * Int8List.BYTES_PER_ELEMENT));
2298 } 2249 }
2299 2250
2300 void operator[]=(int index, int value) { 2251 void operator[]=(int index, int value) {
2301 if (index < 0 || index >= length) { 2252 if (index < 0 || index >= length) {
2302 String message = "$index must be in the range [0..$length)"; 2253 _throwRangeError(index, length);
2303 throw new RangeError(message);
2304 } 2254 }
2305 _typeddata._setInt8(offsetInBytes + (index * Int8List.BYTES_PER_ELEMENT), 2255 _typeddata._setInt8(offsetInBytes + (index * Int8List.BYTES_PER_ELEMENT),
2306 _toInt8(value)); 2256 _toInt8(value));
2307 } 2257 }
2308 2258
2309 Iterator<int> get iterator { 2259 Iterator<int> get iterator {
2310 return new _TypedListIterator<int>(this); 2260 return new _TypedListIterator<int>(this);
2311 } 2261 }
2312 2262
2313 2263
2314 // Method(s) implementing TypedData interface. 2264 // Method(s) implementing TypedData interface.
2315 2265
2316 int get elementSizeInBytes { 2266 int get elementSizeInBytes {
2317 return Int8List.BYTES_PER_ELEMENT; 2267 return Int8List.BYTES_PER_ELEMENT;
2318 } 2268 }
2269
2270
2271 // Internal utility methods.
2272
2273 Int8List _createList(int length) {
2274 return new Int8List(length);
2275 }
2319 } 2276 }
2320 2277
2321 2278
2322 class _Uint8ArrayView extends _TypedListView implements Uint8List { 2279 class _Uint8ArrayView extends _TypedListView implements Uint8List {
2323 // Constructor. 2280 // Constructor.
2324 _Uint8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2281 _Uint8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2325 : super(buffer, _offsetInBytes, 2282 : super(buffer, _offsetInBytes,
2326 _defaultIfNull(_length, 2283 _defaultIfNull(_length,
2327 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2284 ((buffer.lengthInBytes - _offsetInBytes) ~/
2328 Uint8List.BYTES_PER_ELEMENT))) { 2285 Uint8List.BYTES_PER_ELEMENT))) {
2329 _rangeCheck(buffer.lengthInBytes, 2286 _rangeCheck(buffer.lengthInBytes,
2330 _offsetInBytes, 2287 _offsetInBytes,
2331 _length * Uint8List.BYTES_PER_ELEMENT); 2288 length * Uint8List.BYTES_PER_ELEMENT);
2332 } 2289 }
2333 2290
2334 2291
2335 // Method(s) implementing List interface. 2292 // Method(s) implementing List interface.
2336 2293
2337 int operator[](int index) { 2294 int operator[](int index) {
2338 if (index < 0 || index >= length) { 2295 if (index < 0 || index >= length) {
2339 String message = "$index must be in the range [0..$length)"; 2296 _throwRangeError(index, length);
2340 throw new RangeError(message);
2341 } 2297 }
2342 return _typeddata._getUint8(offsetInBytes + 2298 return _typeddata._getUint8(offsetInBytes +
2343 (index * Uint8List.BYTES_PER_ELEMENT)); 2299 (index * Uint8List.BYTES_PER_ELEMENT));
2344 } 2300 }
2345 2301
2346 void operator[]=(int index, int value) { 2302 void operator[]=(int index, int value) {
2347 if (index < 0 || index >= length) { 2303 if (index < 0 || index >= length) {
2348 String message = "$index must be in the range [0..$length)"; 2304 _throwRangeError(index, length);
2349 throw new RangeError(message);
2350 } 2305 }
2351 _typeddata._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), 2306 _typeddata._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT),
2352 _toUint8(value)); 2307 _toUint8(value));
2353 } 2308 }
2354 2309
2355 Iterator<int> get iterator { 2310 Iterator<int> get iterator {
2356 return new _TypedListIterator<int>(this); 2311 return new _TypedListIterator<int>(this);
2357 } 2312 }
2358 2313
2359 2314
2360 // Method(s) implementing TypedData interface. 2315 // Method(s) implementing TypedData interface.
2361 2316
2362 int get elementSizeInBytes { 2317 int get elementSizeInBytes {
2363 return Uint8List.BYTES_PER_ELEMENT; 2318 return Uint8List.BYTES_PER_ELEMENT;
2364 } 2319 }
2320
2321
2322 // Internal utility methods.
2323
2324 Uint8List _createList(int length) {
2325 return new Uint8List(length);
2326 }
2365 } 2327 }
2366 2328
2367 2329
2368 class _Uint8ClampedArrayView extends _TypedListView implements Uint8List { 2330 class _Uint8ClampedArrayView extends _TypedListView implements Uint8List {
2369 // Constructor. 2331 // Constructor.
2370 _Uint8ClampedArrayView(ByteBuffer buffer, 2332 _Uint8ClampedArrayView(ByteBuffer buffer,
2371 [int _offsetInBytes = 0, int _length]) 2333 [int _offsetInBytes = 0, int _length])
2372 : super(buffer, _offsetInBytes, 2334 : super(buffer, _offsetInBytes,
2373 _defaultIfNull(_length, 2335 _defaultIfNull(_length,
2374 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2336 ((buffer.lengthInBytes - _offsetInBytes) ~/
2375 Uint8List.BYTES_PER_ELEMENT))) { 2337 Uint8List.BYTES_PER_ELEMENT))) {
2376 _rangeCheck(buffer.lengthInBytes, 2338 _rangeCheck(buffer.lengthInBytes,
2377 offsetInBytes, 2339 offsetInBytes,
2378 length * Uint8List.BYTES_PER_ELEMENT); 2340 length * Uint8List.BYTES_PER_ELEMENT);
2379 } 2341 }
2380 2342
2381 2343
2382 // Method(s) implementing List interface. 2344 // Method(s) implementing List interface.
2383 2345
2384 int operator[](int index) { 2346 int operator[](int index) {
2385 if (index < 0 || index >= length) { 2347 if (index < 0 || index >= length) {
2386 String message = "$index must be in the range [0..$length)"; 2348 _throwRangeError(index, length);
2387 throw new RangeError(message);
2388 } 2349 }
2389 return _typeddata._getUint8(offsetInBytes + 2350 return _typeddata._getUint8(offsetInBytes +
2390 (index * Uint8List.BYTES_PER_ELEMENT)); 2351 (index * Uint8List.BYTES_PER_ELEMENT));
2391 } 2352 }
2392 2353
2393 void operator[]=(int index, int value) { 2354 void operator[]=(int index, int value) {
2394 if (index < 0 || index >= length) { 2355 if (index < 0 || index >= length) {
2395 String message = "$index must be in the range [0..$length)"; 2356 _throwRangeError(index, length);
2396 throw new RangeError(message);
2397 } 2357 }
2398 _typeddata._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), 2358 _typeddata._setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT),
2399 _toClampedUint8(value)); 2359 _toClampedUint8(value));
2400 } 2360 }
2401 2361
2402 Iterator<int> get iterator { 2362 Iterator<int> get iterator {
2403 return new _TypedListIterator<int>(this); 2363 return new _TypedListIterator<int>(this);
2404 } 2364 }
2405 2365
2406 2366
2407 // Method(s) implementing TypedData interface. 2367 // Method(s) implementing TypedData interface.
2408 2368
2409 int get elementSizeInBytes { 2369 int get elementSizeInBytes {
2410 return Uint8List.BYTES_PER_ELEMENT; 2370 return Uint8List.BYTES_PER_ELEMENT;
2411 } 2371 }
2372
2373
2374 // Internal utility methods.
2375
2376 Uint8ClampedList _createList(int length) {
2377 return new Uint8ClampedList(length);
2378 }
2412 } 2379 }
2413 2380
2414 2381
2415 class _Int16ArrayView extends _TypedListView implements Int16List { 2382 class _Int16ArrayView extends _TypedListView implements Int16List {
2416 // Constructor. 2383 // Constructor.
2417 _Int16ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2384 _Int16ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2418 : super(buffer, _offsetInBytes, 2385 : super(buffer, _offsetInBytes,
2419 _defaultIfNull(_length, 2386 _defaultIfNull(_length,
2420 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2387 ((buffer.lengthInBytes - _offsetInBytes) ~/
2421 Int16List.BYTES_PER_ELEMENT))) { 2388 Int16List.BYTES_PER_ELEMENT))) {
2422 _rangeCheck(buffer.lengthInBytes, 2389 _rangeCheck(buffer.lengthInBytes,
2423 offsetInBytes, 2390 offsetInBytes,
2424 length * Int16List.BYTES_PER_ELEMENT); 2391 length * Int16List.BYTES_PER_ELEMENT);
2425 } 2392 }
2426 2393
2427 2394
2428 // Method(s) implementing List interface. 2395 // Method(s) implementing List interface.
2429 2396
2430 int operator[](int index) { 2397 int operator[](int index) {
2431 if (index < 0 || index >= length) { 2398 if (index < 0 || index >= length) {
2432 String message = "$index must be in the range [0..$length)"; 2399 _throwRangeError(index, length);
2433 throw new RangeError(message);
2434 } 2400 }
2435 return _typeddata._getInt16(offsetInBytes + 2401 return _typeddata._getInt16(offsetInBytes +
2436 (index * Int16List.BYTES_PER_ELEMENT)); 2402 (index * Int16List.BYTES_PER_ELEMENT));
2437 } 2403 }
2438 2404
2439 void operator[]=(int index, int value) { 2405 void operator[]=(int index, int value) {
2440 if (index < 0 || index >= length) { 2406 if (index < 0 || index >= length) {
2441 String message = "$index must be in the range [0..$length)"; 2407 _throwRangeError(index, length);
2442 throw new RangeError(message);
2443 } 2408 }
2444 _typeddata._setInt16(offsetInBytes + (index * Int16List.BYTES_PER_ELEMENT), 2409 _typeddata._setInt16(offsetInBytes + (index * Int16List.BYTES_PER_ELEMENT),
2445 _toInt16(value)); 2410 _toInt16(value));
2446 } 2411 }
2447 2412
2448 Iterator<int> get iterator { 2413 Iterator<int> get iterator {
2449 return new _TypedListIterator<int>(this); 2414 return new _TypedListIterator<int>(this);
2450 } 2415 }
2451 2416
2452 2417
2453 // Method(s) implementing TypedData interface. 2418 // Method(s) implementing TypedData interface.
2454 2419
2455 int get elementSizeInBytes { 2420 int get elementSizeInBytes {
2456 return Int16List.BYTES_PER_ELEMENT; 2421 return Int16List.BYTES_PER_ELEMENT;
2457 } 2422 }
2423
2424
2425 // Internal utility methods.
2426
2427 Int16List _createList(int length) {
2428 return new Int16List(length);
2429 }
2458 } 2430 }
2459 2431
2460 2432
2461 class _Uint16ArrayView extends _TypedListView implements Uint16List { 2433 class _Uint16ArrayView extends _TypedListView implements Uint16List {
2462 // Constructor. 2434 // Constructor.
2463 _Uint16ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2435 _Uint16ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2464 : super(buffer, _offsetInBytes, 2436 : super(buffer, _offsetInBytes,
2465 _defaultIfNull(_length, 2437 _defaultIfNull(_length,
2466 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2438 ((buffer.lengthInBytes - _offsetInBytes) ~/
2467 Uint16List.BYTES_PER_ELEMENT))) { 2439 Uint16List.BYTES_PER_ELEMENT))) {
2468 _rangeCheck(buffer.lengthInBytes, 2440 _rangeCheck(buffer.lengthInBytes,
2469 offsetInBytes, 2441 offsetInBytes,
2470 length * Uint16List.BYTES_PER_ELEMENT); 2442 length * Uint16List.BYTES_PER_ELEMENT);
2471 } 2443 }
2472 2444
2473 2445
2474 // Method(s) implementing List interface. 2446 // Method(s) implementing List interface.
2475 2447
2476 int operator[](int index) { 2448 int operator[](int index) {
2477 if (index < 0 || index >= length) { 2449 if (index < 0 || index >= length) {
2478 String message = "$index must be in the range [0..$length)"; 2450 _throwRangeError(index, length);
2479 throw new RangeError(message);
2480 } 2451 }
2481 return _typeddata._getUint16(offsetInBytes + 2452 return _typeddata._getUint16(offsetInBytes +
2482 (index * Uint16List.BYTES_PER_ELEMENT)); 2453 (index * Uint16List.BYTES_PER_ELEMENT));
2483 } 2454 }
2484 2455
2485 void operator[]=(int index, int value) { 2456 void operator[]=(int index, int value) {
2486 if (index < 0 || index >= length) { 2457 if (index < 0 || index >= length) {
2487 String message = "$index must be in the range [0..$length)"; 2458 _throwRangeError(index, length);
2488 throw new RangeError(message);
2489 } 2459 }
2490 _typeddata._setUint16(offsetInBytes + (index * Uint16List.BYTES_PER_ELEMENT) , 2460 _typeddata._setUint16(offsetInBytes + (index * Uint16List.BYTES_PER_ELEMENT) ,
2491 _toUint16(value)); 2461 _toUint16(value));
2492 } 2462 }
2493 2463
2494 Iterator<int> get iterator { 2464 Iterator<int> get iterator {
2495 return new _TypedListIterator<int>(this); 2465 return new _TypedListIterator<int>(this);
2496 } 2466 }
2497 2467
2498 2468
2499 // Method(s) implementing TypedData interface. 2469 // Method(s) implementing TypedData interface.
2500 2470
2501 int get elementSizeInBytes { 2471 int get elementSizeInBytes {
2502 return Uint16List.BYTES_PER_ELEMENT; 2472 return Uint16List.BYTES_PER_ELEMENT;
2503 } 2473 }
2474
2475
2476 // Internal utility methods.
2477
2478 Uint16List _createList(int length) {
2479 return new Uint16List(length);
2480 }
2504 } 2481 }
2505 2482
2506 2483
2507 class _Int32ArrayView extends _TypedListView implements Int32List { 2484 class _Int32ArrayView extends _TypedListView implements Int32List {
2508 // Constructor. 2485 // Constructor.
2509 _Int32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2486 _Int32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2510 : super(buffer, _offsetInBytes, 2487 : super(buffer, _offsetInBytes,
2511 _defaultIfNull(_length, 2488 _defaultIfNull(_length,
2512 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2489 ((buffer.lengthInBytes - _offsetInBytes) ~/
2513 Int32List.BYTES_PER_ELEMENT))) { 2490 Int32List.BYTES_PER_ELEMENT))) {
2514 _rangeCheck(buffer.lengthInBytes, 2491 _rangeCheck(buffer.lengthInBytes,
2515 offsetInBytes, 2492 offsetInBytes,
2516 length * Int32List.BYTES_PER_ELEMENT); 2493 length * Int32List.BYTES_PER_ELEMENT);
2517 } 2494 }
2518 2495
2519 2496
2520 // Method(s) implementing List interface. 2497 // Method(s) implementing List interface.
2521 2498
2522 int operator[](int index) { 2499 int operator[](int index) {
2523 if (index < 0 || index >= length) { 2500 if (index < 0 || index >= length) {
2524 String message = "$index must be in the range [0..$length)"; 2501 _throwRangeError(index, length);
2525 throw new RangeError(message);
2526 } 2502 }
2527 return _typeddata._getInt32(offsetInBytes + 2503 return _typeddata._getInt32(offsetInBytes +
2528 (index * Int32List.BYTES_PER_ELEMENT)); 2504 (index * Int32List.BYTES_PER_ELEMENT));
2529 } 2505 }
2530 2506
2531 void operator[]=(int index, int value) { 2507 void operator[]=(int index, int value) {
2532 if (index < 0 || index >= length) { 2508 if (index < 0 || index >= length) {
2533 String message = "$index must be in the range [0..$length)"; 2509 _throwRangeError(index, length);
2534 throw new RangeError(message);
2535 } 2510 }
2536 _typeddata._setInt32(offsetInBytes + (index * Int32List.BYTES_PER_ELEMENT), 2511 _typeddata._setInt32(offsetInBytes + (index * Int32List.BYTES_PER_ELEMENT),
2537 _toInt32(value)); 2512 _toInt32(value));
2538 } 2513 }
2539 2514
2540 Iterator<int> get iterator { 2515 Iterator<int> get iterator {
2541 return new _TypedListIterator<int>(this); 2516 return new _TypedListIterator<int>(this);
2542 } 2517 }
2543 2518
2544 2519
2545 // Method(s) implementing TypedData interface. 2520 // Method(s) implementing TypedData interface.
2546 2521
2547 int get elementSizeInBytes { 2522 int get elementSizeInBytes {
2548 return Int32List.BYTES_PER_ELEMENT; 2523 return Int32List.BYTES_PER_ELEMENT;
2549 } 2524 }
2525
2526
2527 // Internal utility methods.
2528
2529 Int32List _createList(int length) {
2530 return new Int32List(length);
2531 }
2550 } 2532 }
2551 2533
2552 2534
2553 class _Uint32ArrayView extends _TypedListView implements Uint32List { 2535 class _Uint32ArrayView extends _TypedListView implements Uint32List {
2554 // Constructor. 2536 // Constructor.
2555 _Uint32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2537 _Uint32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2556 : super(buffer, _offsetInBytes, 2538 : super(buffer, _offsetInBytes,
2557 _defaultIfNull(_length, 2539 _defaultIfNull(_length,
2558 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2540 ((buffer.lengthInBytes - _offsetInBytes) ~/
2559 Uint32List.BYTES_PER_ELEMENT))) { 2541 Uint32List.BYTES_PER_ELEMENT))) {
2560 _rangeCheck(buffer.lengthInBytes, 2542 _rangeCheck(buffer.lengthInBytes,
2561 offsetInBytes, 2543 offsetInBytes,
2562 length * Uint32List.BYTES_PER_ELEMENT); 2544 length * Uint32List.BYTES_PER_ELEMENT);
2563 } 2545 }
2564 2546
2565 2547
2566 // Method(s) implementing List interface. 2548 // Method(s) implementing List interface.
2567 2549
2568 int operator[](int index) { 2550 int operator[](int index) {
2569 if (index < 0 || index >= length) { 2551 if (index < 0 || index >= length) {
2570 String message = "$index must be in the range [0..$length)"; 2552 _throwRangeError(index, length);
2571 throw new RangeError(message);
2572 } 2553 }
2573 return _typeddata._getUint32(offsetInBytes + 2554 return _typeddata._getUint32(offsetInBytes +
2574 (index * Uint32List.BYTES_PER_ELEMENT)); 2555 (index * Uint32List.BYTES_PER_ELEMENT));
2575 } 2556 }
2576 2557
2577 void operator[]=(int index, int value) { 2558 void operator[]=(int index, int value) {
2578 if (index < 0 || index >= length) { 2559 if (index < 0 || index >= length) {
2579 String message = "$index must be in the range [0..$length)"; 2560 _throwRangeError(index, length);
2580 throw new RangeError(message);
2581 } 2561 }
2582 _typeddata._setUint32(offsetInBytes + (index * Uint32List.BYTES_PER_ELEMENT) , 2562 _typeddata._setUint32(offsetInBytes + (index * Uint32List.BYTES_PER_ELEMENT) ,
2583 _toUint32(value)); 2563 _toUint32(value));
2584 } 2564 }
2585 2565
2586 Iterator<int> get iterator { 2566 Iterator<int> get iterator {
2587 return new _TypedListIterator<int>(this); 2567 return new _TypedListIterator<int>(this);
2588 } 2568 }
2589 2569
2590 2570
2591 // Method(s) implementing TypedData interface. 2571 // Method(s) implementing TypedData interface.
2592 2572
2593 int get elementSizeInBytes { 2573 int get elementSizeInBytes {
2594 return Uint32List.BYTES_PER_ELEMENT; 2574 return Uint32List.BYTES_PER_ELEMENT;
2595 } 2575 }
2576
2577
2578 // Internal utility methods.
2579
2580 Uint32List _createList(int length) {
2581 return new Uint32List(length);
2582 }
2596 } 2583 }
2597 2584
2598 2585
2599 class _Int64ArrayView extends _TypedListView implements Int64List { 2586 class _Int64ArrayView extends _TypedListView implements Int64List {
2600 // Constructor. 2587 // Constructor.
2601 _Int64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2588 _Int64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2602 : super(buffer, _offsetInBytes, 2589 : super(buffer, _offsetInBytes,
2603 _defaultIfNull(_length, 2590 _defaultIfNull(_length,
2604 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2591 ((buffer.lengthInBytes - _offsetInBytes) ~/
2605 Int64List.BYTES_PER_ELEMENT))) { 2592 Int64List.BYTES_PER_ELEMENT))) {
2606 _rangeCheck(buffer.lengthInBytes, 2593 _rangeCheck(buffer.lengthInBytes,
2607 offsetInBytes, 2594 offsetInBytes,
2608 length * Int64List.BYTES_PER_ELEMENT); 2595 length * Int64List.BYTES_PER_ELEMENT);
2609 } 2596 }
2610 2597
2611 2598
2612 // Method(s) implementing List interface. 2599 // Method(s) implementing List interface.
2613 2600
2614 int operator[](int index) { 2601 int operator[](int index) {
2615 if (index < 0 || index >= length) { 2602 if (index < 0 || index >= length) {
2616 String message = "$index must be in the range [0..$length)"; 2603 _throwRangeError(index, length);
2617 throw new RangeError(message);
2618 } 2604 }
2619 return _typeddata._getInt64(offsetInBytes + 2605 return _typeddata._getInt64(offsetInBytes +
2620 (index * Int64List.BYTES_PER_ELEMENT)); 2606 (index * Int64List.BYTES_PER_ELEMENT));
2621 } 2607 }
2622 2608
2623 void operator[]=(int index, int value) { 2609 void operator[]=(int index, int value) {
2624 if (index < 0 || index >= length) { 2610 if (index < 0 || index >= length) {
2625 String message = "$index must be in the range [0..$length)"; 2611 _throwRangeError(index, length);
2626 throw new RangeError(message);
2627 } 2612 }
2628 _typeddata._setInt64(offsetInBytes + (index * Int64List.BYTES_PER_ELEMENT), 2613 _typeddata._setInt64(offsetInBytes + (index * Int64List.BYTES_PER_ELEMENT),
2629 _toInt64(value)); 2614 _toInt64(value));
2630 } 2615 }
2631 2616
2632 Iterator<int> get iterator { 2617 Iterator<int> get iterator {
2633 return new _TypedListIterator<int>(this); 2618 return new _TypedListIterator<int>(this);
2634 } 2619 }
2635 2620
2636 2621
2637 // Method(s) implementing TypedData interface. 2622 // Method(s) implementing TypedData interface.
2638 2623
2639 int get elementSizeInBytes { 2624 int get elementSizeInBytes {
2640 return Int64List.BYTES_PER_ELEMENT; 2625 return Int64List.BYTES_PER_ELEMENT;
2641 } 2626 }
2627
2628
2629 // Internal utility methods.
2630
2631 Int64List _createList(int length) {
2632 return new Int64List(length);
2633 }
2642 } 2634 }
2643 2635
2644 2636
2645 class _Uint64ArrayView extends _TypedListView implements Uint64List { 2637 class _Uint64ArrayView extends _TypedListView implements Uint64List {
2646 // Constructor. 2638 // Constructor.
2647 _Uint64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2639 _Uint64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2648 : super(buffer, _offsetInBytes, 2640 : super(buffer, _offsetInBytes,
2649 _defaultIfNull(_length, 2641 _defaultIfNull(_length,
2650 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2642 ((buffer.lengthInBytes - _offsetInBytes) ~/
2651 Uint64List.BYTES_PER_ELEMENT))) { 2643 Uint64List.BYTES_PER_ELEMENT))) {
2652 _rangeCheck(buffer.lengthInBytes, 2644 _rangeCheck(buffer.lengthInBytes,
2653 offsetInBytes, 2645 offsetInBytes,
2654 length * Uint64List.BYTES_PER_ELEMENT); 2646 length * Uint64List.BYTES_PER_ELEMENT);
2655 } 2647 }
2656 2648
2657 2649
2658 // Method(s) implementing List interface. 2650 // Method(s) implementing List interface.
2659 2651
2660 int operator[](int index) { 2652 int operator[](int index) {
2661 if (index < 0 || index >= length) { 2653 if (index < 0 || index >= length) {
2662 String message = "$index must be in the range [0..$length)"; 2654 _throwRangeError(index, length);
2663 throw new RangeError(message);
2664 } 2655 }
2665 return _typeddata._getUint64(offsetInBytes + 2656 return _typeddata._getUint64(offsetInBytes +
2666 (index * Uint64List.BYTES_PER_ELEMENT)); 2657 (index * Uint64List.BYTES_PER_ELEMENT));
2667 } 2658 }
2668 2659
2669 void operator[]=(int index, int value) { 2660 void operator[]=(int index, int value) {
2670 if (index < 0 || index >= length) { 2661 if (index < 0 || index >= length) {
2671 String message = "$index must be in the range [0..$length)"; 2662 _throwRangeError(index, length);
2672 throw new RangeError(message);
2673 } 2663 }
2674 _typeddata._setUint64(offsetInBytes + (index * Uint64List.BYTES_PER_ELEMENT) , 2664 _typeddata._setUint64(offsetInBytes + (index * Uint64List.BYTES_PER_ELEMENT) ,
2675 _toUint64(value)); 2665 _toUint64(value));
2676 } 2666 }
2677 2667
2678 Iterator<int> get iterator { 2668 Iterator<int> get iterator {
2679 return new _TypedListIterator<int>(this); 2669 return new _TypedListIterator<int>(this);
2680 } 2670 }
2681 2671
2682 2672
2683 // Method(s) implementing TypedData interface. 2673 // Method(s) implementing TypedData interface.
2684 2674
2685 int get elementSizeInBytes { 2675 int get elementSizeInBytes {
2686 return Uint64List.BYTES_PER_ELEMENT; 2676 return Uint64List.BYTES_PER_ELEMENT;
2687 } 2677 }
2678
2679
2680 // Internal utility methods.
2681
2682 Uint64List _createList(int length) {
2683 return new Uint64List(length);
2684 }
2688 } 2685 }
2689 2686
2690 2687
2691 class _Float32ArrayView extends _TypedListView implements Float32List { 2688 class _Float32ArrayView extends _TypedListView implements Float32List {
2692 // Constructor. 2689 // Constructor.
2693 _Float32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2690 _Float32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2694 : super(buffer, _offsetInBytes, 2691 : super(buffer, _offsetInBytes,
2695 _defaultIfNull(_length, 2692 _defaultIfNull(_length,
2696 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2693 ((buffer.lengthInBytes - _offsetInBytes) ~/
2697 Float32List.BYTES_PER_ELEMENT))) { 2694 Float32List.BYTES_PER_ELEMENT))) {
2698 _rangeCheck(buffer.lengthInBytes, 2695 _rangeCheck(buffer.lengthInBytes,
2699 offsetInBytes, 2696 offsetInBytes,
2700 length * Float32List.BYTES_PER_ELEMENT); 2697 length * Float32List.BYTES_PER_ELEMENT);
2701 } 2698 }
2702 2699
2703 2700
2704 // Method(s) implementing List interface. 2701 // Method(s) implementing List interface.
2705 2702
2706 double operator[](int index) { 2703 double operator[](int index) {
2707 if (index < 0 || index >= length) { 2704 if (index < 0 || index >= length) {
2708 String message = "$index must be in the range [0..$length)"; 2705 _throwRangeError(index, length);
2709 throw new RangeError(message);
2710 } 2706 }
2711 return _typeddata._getFloat32(offsetInBytes + 2707 return _typeddata._getFloat32(offsetInBytes +
2712 (index * Float32List.BYTES_PER_ELEMENT)); 2708 (index * Float32List.BYTES_PER_ELEMENT));
2713 } 2709 }
2714 2710
2715 void operator[]=(int index, double value) { 2711 void operator[]=(int index, double value) {
2716 if (index < 0 || index >= length) { 2712 if (index < 0 || index >= length) {
2717 String message = "$index must be in the range [0..$length)"; 2713 _throwRangeError(index, length);
2718 throw new RangeError(message);
2719 } 2714 }
2720 _typeddata._setFloat32(offsetInBytes + 2715 _typeddata._setFloat32(offsetInBytes +
2721 (index * Float32List.BYTES_PER_ELEMENT), value); 2716 (index * Float32List.BYTES_PER_ELEMENT), value);
2722 } 2717 }
2723 2718
2724 Iterator<double> get iterator { 2719 Iterator<double> get iterator {
2725 return new _TypedListIterator<double>(this); 2720 return new _TypedListIterator<double>(this);
2726 } 2721 }
2727 2722
2728 2723
2729 // Method(s) implementing TypedData interface. 2724 // Method(s) implementing TypedData interface.
2730 2725
2731 int get elementSizeInBytes { 2726 int get elementSizeInBytes {
2732 return Float32List.BYTES_PER_ELEMENT; 2727 return Float32List.BYTES_PER_ELEMENT;
2733 } 2728 }
2729
2730
2731 // Internal utility methods.
2732
2733 Float32List _createList(int length) {
2734 return new Float32List(length);
2735 }
2734 } 2736 }
2735 2737
2736 2738
2737 class _Float64ArrayView extends _TypedListView implements Float64List { 2739 class _Float64ArrayView extends _TypedListView implements Float64List {
2738 // Constructor. 2740 // Constructor.
2739 _Float64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2741 _Float64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2740 : super(buffer, _offsetInBytes, 2742 : super(buffer, _offsetInBytes,
2741 _defaultIfNull(_length, 2743 _defaultIfNull(_length,
2742 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2744 ((buffer.lengthInBytes - _offsetInBytes) ~/
2743 Float64List.BYTES_PER_ELEMENT))) { 2745 Float64List.BYTES_PER_ELEMENT))) {
2744 _rangeCheck(buffer.lengthInBytes, 2746 _rangeCheck(buffer.lengthInBytes,
2745 offsetInBytes, 2747 offsetInBytes,
2746 length * Float64List.BYTES_PER_ELEMENT); 2748 length * Float64List.BYTES_PER_ELEMENT);
2747 } 2749 }
2748 2750
2749 2751
2750 // Method(s) implementing List interface. 2752 // Method(s) implementing List interface.
2751 2753
2752 double operator[](int index) { 2754 double operator[](int index) {
2753 if (index < 0 || index >= length) { 2755 if (index < 0 || index >= length) {
2754 String message = "$index must be in the range [0..$length)"; 2756 _throwRangeError(index, length);
2755 throw new RangeError(message);
2756 } 2757 }
2757 return _typeddata._getFloat64(offsetInBytes + 2758 return _typeddata._getFloat64(offsetInBytes +
2758 (index * Float64List.BYTES_PER_ELEMENT)); 2759 (index * Float64List.BYTES_PER_ELEMENT));
2759 } 2760 }
2760 2761
2761 void operator[]=(int index, double value) { 2762 void operator[]=(int index, double value) {
2762 if (index < 0 || index >= length) { 2763 if (index < 0 || index >= length) {
2763 String message = "$index must be in the range [0..$length)"; 2764 _throwRangeError(index, length);
2764 throw new RangeError(message);
2765 } 2765 }
2766 _typeddata._setFloat64(offsetInBytes + 2766 _typeddata._setFloat64(offsetInBytes +
2767 (index * Float64List.BYTES_PER_ELEMENT), value); 2767 (index * Float64List.BYTES_PER_ELEMENT), value);
2768 } 2768 }
2769 2769
2770 Iterator<double> get iterator { 2770 Iterator<double> get iterator {
2771 return new _TypedListIterator<double>(this); 2771 return new _TypedListIterator<double>(this);
2772 } 2772 }
2773 2773
2774 2774
2775 // Method(s) implementing TypedData interface. 2775 // Method(s) implementing TypedData interface.
2776 2776
2777 int get elementSizeInBytes { 2777 int get elementSizeInBytes {
2778 return Float64List.BYTES_PER_ELEMENT; 2778 return Float64List.BYTES_PER_ELEMENT;
2779 } 2779 }
2780
2781
2782 // Internal utility methods.
2783
2784 Float64List _createList(int length) {
2785 return new Float64List(length);
2786 }
2780 } 2787 }
2781 2788
2782 2789
2783 class _Float32x4ArrayView extends _TypedListView implements Float32x4List { 2790 class _Float32x4ArrayView extends _TypedListView implements Float32x4List {
2784 // Constructor. 2791 // Constructor.
2785 _Float32x4ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) 2792 _Float32x4ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length])
2786 : super(buffer, _offsetInBytes, 2793 : super(buffer, _offsetInBytes,
2787 _defaultIfNull(_length, 2794 _defaultIfNull(_length,
2788 ((buffer.lengthInBytes - _offsetInBytes) ~/ 2795 ((buffer.lengthInBytes - _offsetInBytes) ~/
2789 Float32x4List.BYTES_PER_ELEMENT))) { 2796 Float32x4List.BYTES_PER_ELEMENT))) {
2790 _rangeCheck(buffer.lengthInBytes, 2797 _rangeCheck(buffer.lengthInBytes,
2791 offsetInBytes, 2798 offsetInBytes,
2792 length * Float32x4List.BYTES_PER_ELEMENT); 2799 length * Float32x4List.BYTES_PER_ELEMENT);
2793 } 2800 }
2794 2801
2795 2802
2796 // Method(s) implementing List interface. 2803 // Method(s) implementing List interface.
2797 2804
2798 Float32x4 operator[](int index) { 2805 Float32x4 operator[](int index) {
2799 if (index < 0 || index >= length) { 2806 if (index < 0 || index >= length) {
2800 String message = "$index must be in the range [0..$length)"; 2807 _throwRangeError(index, length);
2801 throw new RangeError(message);
2802 } 2808 }
2803 return _typeddata._getFloat32x4(offsetInBytes + 2809 return _typeddata._getFloat32x4(offsetInBytes +
2804 (index * Float32x4List.BYTES_PER_ELEMENT)); 2810 (index * Float32x4List.BYTES_PER_ELEMENT));
2805 } 2811 }
2806 2812
2807 void operator[]=(int index, Float32x4 value) { 2813 void operator[]=(int index, Float32x4 value) {
2808 if (index < 0 || index >= length) { 2814 if (index < 0 || index >= length) {
2809 String message = "$index must be in the range [0..$length)"; 2815 _throwRangeError(index, length);
2810 throw new RangeError(message);
2811 } 2816 }
2812 _typeddata._setFloat32x4(offsetInBytes + 2817 _typeddata._setFloat32x4(offsetInBytes +
2813 (index * Float32x4List.BYTES_PER_ELEMENT), value); 2818 (index * Float32x4List.BYTES_PER_ELEMENT), value);
2814 } 2819 }
2815 2820
2816 Iterator<Float32x4> get iterator { 2821 Iterator<Float32x4> get iterator {
2817 return new _TypedListIterator<Float32x4>(this); 2822 return new _TypedListIterator<Float32x4>(this);
2818 } 2823 }
2819 2824
2820 2825
2821 // Method(s) implementing TypedData interface. 2826 // Method(s) implementing TypedData interface.
2822 2827
2823 int get elementSizeInBytes { 2828 int get elementSizeInBytes {
2824 return Float32x4List.BYTES_PER_ELEMENT; 2829 return Float32x4List.BYTES_PER_ELEMENT;
2825 } 2830 }
2831
2832
2833 // Internal utility methods.
2834
2835 Float32x4List _createList(int length) {
2836 return new Float32x4List(length);
2837 }
2826 } 2838 }
2827 2839
2828 2840
2829 class _ByteDataView implements ByteData { 2841 class _ByteDataView implements ByteData {
2830 _ByteDataView(ByteBuffer _buffer, int _offsetInBytes, int _lengthInBytes) 2842 _ByteDataView(ByteBuffer _buffer, int _offsetInBytes, int _lengthInBytes)
2831 : _typeddata = _buffer as TypedData, 2843 : _typeddata = _buffer, // _buffer is guaranteed to be a TypedData here.
2832 _offset = _offsetInBytes, 2844 _offset = _offsetInBytes,
2833 length = _lengthInBytes { 2845 length = _lengthInBytes {
2834 _rangeCheck(_buffer.lengthInBytes, _offset, length); 2846 _rangeCheck(_buffer.lengthInBytes, _offset, length);
2835 } 2847 }
2836 2848
2837 2849
2838 // Method(s) implementing TypedData interface. 2850 // Method(s) implementing TypedData interface.
2839 2851
2840 ByteBuffer get buffer { 2852 ByteBuffer get buffer {
2841 return _typeddata.buffer; 2853 return _typeddata.buffer;
2842 } 2854 }
2843 2855
2844 int get lengthInBytes { 2856 int get lengthInBytes {
2845 return length; 2857 return length;
2846 } 2858 }
2847 2859
2848 int get offsetInBytes { 2860 int get offsetInBytes {
2849 return _offset; 2861 return _offset;
2850 } 2862 }
2851 2863
2852 // Method(s) implementing ByteData interface. 2864 // Method(s) implementing ByteData interface.
2853 2865
2854 int getInt8(int byteOffset) { 2866 int getInt8(int byteOffset) {
2867 if (byteOffset < 0 || byteOffset >= length) {
2868 _throwRangeError(byteOffset, length);
2869 }
2855 return _typeddata._getInt8(_offset + byteOffset); 2870 return _typeddata._getInt8(_offset + byteOffset);
2856 } 2871 }
2857 void setInt8(int byteOffset, int value) { 2872 void setInt8(int byteOffset, int value) {
2873 if (byteOffset < 0 || byteOffset >= length) {
2874 _throwRangeError(byteOffset, length);
2875 }
2858 _typeddata._setInt8(_offset + byteOffset, value); 2876 _typeddata._setInt8(_offset + byteOffset, value);
2859 } 2877 }
2860 2878
2861 int getUint8(int byteOffset) { 2879 int getUint8(int byteOffset) {
2880 if (byteOffset < 0 || byteOffset >= length) {
2881 _throwRangeError(byteOffset, length);
2882 }
2862 return _typeddata._getUint8(_offset + byteOffset); 2883 return _typeddata._getUint8(_offset + byteOffset);
2863 } 2884 }
2864 void setUint8(int byteOffset, int value) { 2885 void setUint8(int byteOffset, int value) {
2886 if (byteOffset < 0 || byteOffset >= length) {
2887 _throwRangeError(byteOffset, length);
2888 }
2865 _typeddata._setUint8(_offset + byteOffset, value); 2889 _typeddata._setUint8(_offset + byteOffset, value);
2866 } 2890 }
2867 2891
2868 int getInt16(int byteOffset) { 2892 int getInt16(int byteOffset) {
2893 if (byteOffset < 0 || byteOffset >= length) {
2894 _throwRangeError(byteOffset, length);
2895 }
2869 return _typeddata._getInt16(_offset + byteOffset); 2896 return _typeddata._getInt16(_offset + byteOffset);
2870 } 2897 }
2871 void setInt16(int byteOffset, int value) { 2898 void setInt16(int byteOffset, int value) {
2899 if (byteOffset < 0 || byteOffset >= length) {
2900 _throwRangeError(byteOffset, length);
2901 }
2872 _typeddata._setInt16(_offset + byteOffset, value); 2902 _typeddata._setInt16(_offset + byteOffset, value);
2873 } 2903 }
2874 2904
2875 int getUint16(int byteOffset) { 2905 int getUint16(int byteOffset) {
2906 if (byteOffset < 0 || byteOffset >= length) {
2907 _throwRangeError(byteOffset, length);
2908 }
2876 return _typeddata._getUint16(_offset + byteOffset); 2909 return _typeddata._getUint16(_offset + byteOffset);
2877 } 2910 }
2878 void setUint16(int byteOffset, int value) { 2911 void setUint16(int byteOffset, int value) {
2912 if (byteOffset < 0 || byteOffset >= length) {
2913 _throwRangeError(byteOffset, length);
2914 }
2879 _typeddata._setUint16(_offset + byteOffset, value); 2915 _typeddata._setUint16(_offset + byteOffset, value);
2880 } 2916 }
2881 2917
2882 int getInt32(int byteOffset) { 2918 int getInt32(int byteOffset) {
2919 if (byteOffset < 0 || byteOffset >= length) {
2920 _throwRangeError(byteOffset, length);
2921 }
2883 return _typeddata._getInt32(_offset + byteOffset); 2922 return _typeddata._getInt32(_offset + byteOffset);
2884 } 2923 }
2885 void setInt32(int byteOffset, int value) { 2924 void setInt32(int byteOffset, int value) {
2925 if (byteOffset < 0 || byteOffset >= length) {
2926 _throwRangeError(byteOffset, length);
2927 }
2886 _typeddata._setInt32(_offset + byteOffset, value); 2928 _typeddata._setInt32(_offset + byteOffset, value);
2887 } 2929 }
2888 2930
2889 int getUint32(int byteOffset) { 2931 int getUint32(int byteOffset) {
2932 if (byteOffset < 0 || byteOffset >= length) {
2933 _throwRangeError(byteOffset, length);
2934 }
2890 return _typeddata._getUint32(_offset + byteOffset); 2935 return _typeddata._getUint32(_offset + byteOffset);
2891 } 2936 }
2892 void setUint32(int byteOffset, int value) { 2937 void setUint32(int byteOffset, int value) {
2938 if (byteOffset < 0 || byteOffset >= length) {
2939 _throwRangeError(byteOffset, length);
2940 }
2893 _typeddata._setUint32(_offset + byteOffset, value); 2941 _typeddata._setUint32(_offset + byteOffset, value);
2894 } 2942 }
2895 2943
2896 int getInt64(int byteOffset) { 2944 int getInt64(int byteOffset) {
2945 if (byteOffset < 0 || byteOffset >= length) {
2946 _throwRangeError(byteOffset, length);
2947 }
2897 return _typeddata._getInt64(_offset + byteOffset); 2948 return _typeddata._getInt64(_offset + byteOffset);
2898 } 2949 }
2899 void setInt64(int byteOffset, int value) { 2950 void setInt64(int byteOffset, int value) {
2951 if (byteOffset < 0 || byteOffset >= length) {
2952 _throwRangeError(byteOffset, length);
2953 }
2900 _typeddata._setInt64(_offset + byteOffset, value); 2954 _typeddata._setInt64(_offset + byteOffset, value);
2901 } 2955 }
2902 2956
2903 int getUint64(int byteOffset) { 2957 int getUint64(int byteOffset) {
2958 if (byteOffset < 0 || byteOffset >= length) {
2959 _throwRangeError(byteOffset, length);
2960 }
2904 return _typeddata._getUint64(_offset + byteOffset); 2961 return _typeddata._getUint64(_offset + byteOffset);
2905 } 2962 }
2906 void setUint64(int byteOffset, int value) { 2963 void setUint64(int byteOffset, int value) {
2964 if (byteOffset < 0 || byteOffset >= length) {
2965 _throwRangeError(byteOffset, length);
2966 }
2907 _typeddata._setUint64(_offset + byteOffset, value); 2967 _typeddata._setUint64(_offset + byteOffset, value);
2908 } 2968 }
2909 2969
2910 double getFloat32(int byteOffset) { 2970 double getFloat32(int byteOffset) {
2971 if (byteOffset < 0 || byteOffset >= length) {
2972 _throwRangeError(byteOffset, length);
2973 }
2911 return _typeddata._getFloat32(_offset + byteOffset); 2974 return _typeddata._getFloat32(_offset + byteOffset);
2912 } 2975 }
2913 void setFloat32(int byteOffset, double value) { 2976 void setFloat32(int byteOffset, double value) {
2977 if (byteOffset < 0 || byteOffset >= length) {
2978 _throwRangeError(byteOffset, length);
2979 }
2914 _typeddata._setFloat32(_offset + byteOffset, value); 2980 _typeddata._setFloat32(_offset + byteOffset, value);
2915 } 2981 }
2916 2982
2917 double getFloat64(int byteOffset) { 2983 double getFloat64(int byteOffset) {
2984 if (byteOffset < 0 || byteOffset >= length) {
2985 _throwRangeError(byteOffset, length);
2986 }
2918 return _typeddata._getFloat64(_offset + byteOffset); 2987 return _typeddata._getFloat64(_offset + byteOffset);
2919 } 2988 }
2920 void setFloat64(int byteOffset, double value) { 2989 void setFloat64(int byteOffset, double value) {
2990 if (byteOffset < 0 || byteOffset >= length) {
2991 _throwRangeError(byteOffset, length);
2992 }
2921 _typeddata._setFloat64(_offset + byteOffset, value); 2993 _typeddata._setFloat64(_offset + byteOffset, value);
2922 } 2994 }
2923 2995
2924 Float32x4 getFloat32x4(int byteOffset) { 2996 Float32x4 getFloat32x4(int byteOffset) {
2997 if (byteOffset < 0 || byteOffset >= length) {
2998 _throwRangeError(byteOffset, length);
2999 }
2925 return _typeddata._getFloat32x4(_offset + byteOffset); 3000 return _typeddata._getFloat32x4(_offset + byteOffset);
2926 } 3001 }
2927 void setFloat32x4(int byteOffset, Float32x4 value) { 3002 void setFloat32x4(int byteOffset, Float32x4 value) {
3003 if (byteOffset < 0 || byteOffset >= length) {
3004 _throwRangeError(byteOffset, length);
3005 }
2928 _typeddata._setFloat32x4(_offset + byteOffset, value); 3006 _typeddata._setFloat32x4(_offset + byteOffset, value);
2929 3007
2930 } 3008 }
2931 3009
2932 final TypedData _typeddata; 3010 final TypedData _typeddata;
2933 final int _offset; 3011 final int _offset;
2934 final int length; 3012 final int length;
2935 } 3013 }
2936 3014
2937 3015
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 } 3080 }
3003 } 3081 }
3004 3082
3005 3083
3006 int _defaultIfNull(object, value) { 3084 int _defaultIfNull(object, value) {
3007 if (object == null) { 3085 if (object == null) {
3008 return value; 3086 return value;
3009 } 3087 }
3010 return object; 3088 return object;
3011 } 3089 }
3090
3091
3092 void _throwRangeError(int index, int length) {
3093 String message = "$index must be in the range [0..$length)";
3094 throw new RangeError(message);
3095 }
OLDNEW
« no previous file with comments | « no previous file | runtime/tests/vm/dart/byte_array_optimized_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698