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

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

Issue 14383016: Move negative length checks from Dart into the native. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | « runtime/lib/typed_data.cc ('k') | runtime/vm/flow_graph_builder.h » ('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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 Float32x4 _getFloat32x4(int offsetInBytes) native "TypedData_GetFloat32x4"; 572 Float32x4 _getFloat32x4(int offsetInBytes) native "TypedData_GetFloat32x4";
573 void _setFloat32x4(int offsetInBytes, Float32x4 value) 573 void _setFloat32x4(int offsetInBytes, Float32x4 value)
574 native "TypedData_SetFloat32x4"; 574 native "TypedData_SetFloat32x4";
575 } 575 }
576 576
577 577
578 class _Int8Array extends _TypedList implements Int8List { 578 class _Int8Array extends _TypedList implements Int8List {
579 // Factory constructors. 579 // Factory constructors.
580 580
581 factory _Int8Array(int length) { 581 factory _Int8Array(int length) {
582 if (length < 0) {
583 String message = "$length must be greater than 0";
584 throw new ArgumentError(message);
585 }
586 return _new(length); 582 return _new(length);
587 } 583 }
588 584
589 factory _Int8Array.view(ByteBuffer buffer, 585 factory _Int8Array.view(ByteBuffer buffer,
590 [int offsetInBytes = 0, int length]) { 586 [int offsetInBytes = 0, int length]) {
591 if (length == null) { 587 if (length == null) {
592 length = buffer.lengthInBytes - offsetInBytes; 588 length = buffer.lengthInBytes - offsetInBytes;
593 } 589 }
594 return new _Int8ArrayView(buffer, offsetInBytes, length); 590 return new _Int8ArrayView(buffer, offsetInBytes, length);
595 } 591 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 626 }
631 627
632 static _Int8Array _new(int length) native "TypedData_Int8Array_new"; 628 static _Int8Array _new(int length) native "TypedData_Int8Array_new";
633 } 629 }
634 630
635 631
636 class _Uint8Array extends _TypedList implements Uint8List { 632 class _Uint8Array extends _TypedList implements Uint8List {
637 // Factory constructors. 633 // Factory constructors.
638 634
639 factory _Uint8Array(int length) { 635 factory _Uint8Array(int length) {
640 if (length < 0) {
641 String message = "$length must be greater than 0";
642 throw new ArgumentError(message);
643 }
644 return _new(length); 636 return _new(length);
645 } 637 }
646 638
647 factory _Uint8Array.view(ByteBuffer buffer, 639 factory _Uint8Array.view(ByteBuffer buffer,
648 [int offsetInBytes = 0, int length]) { 640 [int offsetInBytes = 0, int length]) {
649 if (length == null) { 641 if (length == null) {
650 length = buffer.lengthInBytes - offsetInBytes; 642 length = buffer.lengthInBytes - offsetInBytes;
651 } 643 }
652 return new _Uint8ArrayView(buffer, offsetInBytes, length); 644 return new _Uint8ArrayView(buffer, offsetInBytes, length);
653 } 645 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 } 678 }
687 679
688 static _Uint8Array _new(int length) native "TypedData_Uint8Array_new"; 680 static _Uint8Array _new(int length) native "TypedData_Uint8Array_new";
689 } 681 }
690 682
691 683
692 class _Uint8ClampedArray extends _TypedList implements Uint8ClampedList { 684 class _Uint8ClampedArray extends _TypedList implements Uint8ClampedList {
693 // Factory constructors. 685 // Factory constructors.
694 686
695 factory _Uint8ClampedArray(int length) { 687 factory _Uint8ClampedArray(int length) {
696 if (length < 0) {
697 String message = "$length must be greater than 0";
698 throw new ArgumentError(message);
699 }
700 return _new(length); 688 return _new(length);
701 } 689 }
702 690
703 factory _Uint8ClampedArray.view(ByteBuffer buffer, 691 factory _Uint8ClampedArray.view(ByteBuffer buffer,
704 [int offsetInBytes = 0, int length]) { 692 [int offsetInBytes = 0, int length]) {
705 if (length == null) { 693 if (length == null) {
706 length = buffer.lengthInBytes - offsetInBytes; 694 length = buffer.lengthInBytes - offsetInBytes;
707 } 695 }
708 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); 696 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length);
709 } 697 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 732
745 static _Uint8ClampedArray _new(int length) 733 static _Uint8ClampedArray _new(int length)
746 native "TypedData_Uint8ClampedArray_new"; 734 native "TypedData_Uint8ClampedArray_new";
747 } 735 }
748 736
749 737
750 class _Int16Array extends _TypedList implements Int16List { 738 class _Int16Array extends _TypedList implements Int16List {
751 // Factory constructors. 739 // Factory constructors.
752 740
753 factory _Int16Array(int length) { 741 factory _Int16Array(int length) {
754 if (length < 0) {
755 String message = "$length must be greater than 0";
756 throw new ArgumentError(message);
757 }
758 return _new(length); 742 return _new(length);
759 } 743 }
760 744
761 factory _Int16Array.view(ByteBuffer buffer, 745 factory _Int16Array.view(ByteBuffer buffer,
762 [int offsetInBytes = 0, int length]) { 746 [int offsetInBytes = 0, int length]) {
763 if (length == null) { 747 if (length == null) {
764 length = (buffer.lengthInBytes - offsetInBytes) ~/ 748 length = (buffer.lengthInBytes - offsetInBytes) ~/
765 Int16List.BYTES_PER_ELEMENT; 749 Int16List.BYTES_PER_ELEMENT;
766 } 750 }
767 return new _Int16ArrayView(buffer, offsetInBytes, length); 751 return new _Int16ArrayView(buffer, offsetInBytes, length);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 795 }
812 796
813 static _Int16Array _new(int length) native "TypedData_Int16Array_new"; 797 static _Int16Array _new(int length) native "TypedData_Int16Array_new";
814 } 798 }
815 799
816 800
817 class _Uint16Array extends _TypedList implements Uint16List { 801 class _Uint16Array extends _TypedList implements Uint16List {
818 // Factory constructors. 802 // Factory constructors.
819 803
820 factory _Uint16Array(int length) { 804 factory _Uint16Array(int length) {
821 if (length < 0) {
822 String message = "$length must be greater than 0";
823 throw new ArgumentError(message);
824 }
825 return _new(length); 805 return _new(length);
826 } 806 }
827 807
828 factory _Uint16Array.view(ByteBuffer buffer, 808 factory _Uint16Array.view(ByteBuffer buffer,
829 [int offsetInBytes = 0, int length]) { 809 [int offsetInBytes = 0, int length]) {
830 if (length == null) { 810 if (length == null) {
831 length = (buffer.lengthInBytes - offsetInBytes) ~/ 811 length = (buffer.lengthInBytes - offsetInBytes) ~/
832 Uint16List.BYTES_PER_ELEMENT; 812 Uint16List.BYTES_PER_ELEMENT;
833 } 813 }
834 return new _Uint16ArrayView(buffer, offsetInBytes, length); 814 return new _Uint16ArrayView(buffer, offsetInBytes, length);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 } 858 }
879 859
880 static _Uint16Array _new(int length) native "TypedData_Uint16Array_new"; 860 static _Uint16Array _new(int length) native "TypedData_Uint16Array_new";
881 } 861 }
882 862
883 863
884 class _Int32Array extends _TypedList implements Int32List { 864 class _Int32Array extends _TypedList implements Int32List {
885 // Factory constructors. 865 // Factory constructors.
886 866
887 factory _Int32Array(int length) { 867 factory _Int32Array(int length) {
888 if (length < 0) {
889 String message = "$length must be greater than 0";
890 throw new ArgumentError(message);
891 }
892 return _new(length); 868 return _new(length);
893 } 869 }
894 870
895 factory _Int32Array.view(ByteBuffer buffer, 871 factory _Int32Array.view(ByteBuffer buffer,
896 [int offsetInBytes = 0, int length]) { 872 [int offsetInBytes = 0, int length]) {
897 if (length == null) { 873 if (length == null) {
898 length = (buffer.lengthInBytes - offsetInBytes) ~/ 874 length = (buffer.lengthInBytes - offsetInBytes) ~/
899 Int32List.BYTES_PER_ELEMENT; 875 Int32List.BYTES_PER_ELEMENT;
900 } 876 }
901 return new _Int32ArrayView(buffer, offsetInBytes, length); 877 return new _Int32ArrayView(buffer, offsetInBytes, length);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 } 921 }
946 922
947 static _Int32Array _new(int length) native "TypedData_Int32Array_new"; 923 static _Int32Array _new(int length) native "TypedData_Int32Array_new";
948 } 924 }
949 925
950 926
951 class _Uint32Array extends _TypedList implements Uint32List { 927 class _Uint32Array extends _TypedList implements Uint32List {
952 // Factory constructors. 928 // Factory constructors.
953 929
954 factory _Uint32Array(int length) { 930 factory _Uint32Array(int length) {
955 if (length < 0) {
956 String message = "$length must be greater than 0";
957 throw new ArgumentError(message);
958 }
959 return _new(length); 931 return _new(length);
960 } 932 }
961 933
962 factory _Uint32Array.view(ByteBuffer buffer, 934 factory _Uint32Array.view(ByteBuffer buffer,
963 [int offsetInBytes = 0, int length]) { 935 [int offsetInBytes = 0, int length]) {
964 if (length == null) { 936 if (length == null) {
965 length = (buffer.lengthInBytes - offsetInBytes) ~/ 937 length = (buffer.lengthInBytes - offsetInBytes) ~/
966 Uint32List.BYTES_PER_ELEMENT; 938 Uint32List.BYTES_PER_ELEMENT;
967 } 939 }
968 return new _Uint32ArrayView(buffer, offsetInBytes, length); 940 return new _Uint32ArrayView(buffer, offsetInBytes, length);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 } 984 }
1013 985
1014 static _Uint32Array _new(int length) native "TypedData_Uint32Array_new"; 986 static _Uint32Array _new(int length) native "TypedData_Uint32Array_new";
1015 } 987 }
1016 988
1017 989
1018 class _Int64Array extends _TypedList implements Int64List { 990 class _Int64Array extends _TypedList implements Int64List {
1019 // Factory constructors. 991 // Factory constructors.
1020 992
1021 factory _Int64Array(int length) { 993 factory _Int64Array(int length) {
1022 if (length < 0) {
1023 String message = "$length must be greater than 0";
1024 throw new ArgumentError(message);
1025 }
1026 return _new(length); 994 return _new(length);
1027 } 995 }
1028 996
1029 factory _Int64Array.view(ByteBuffer buffer, 997 factory _Int64Array.view(ByteBuffer buffer,
1030 [int offsetInBytes = 0, int length]) { 998 [int offsetInBytes = 0, int length]) {
1031 if (length == null) { 999 if (length == null) {
1032 length = (buffer.lengthInBytes - offsetInBytes) ~/ 1000 length = (buffer.lengthInBytes - offsetInBytes) ~/
1033 Int32List.BYTES_PER_ELEMENT; 1001 Int32List.BYTES_PER_ELEMENT;
1034 } 1002 }
1035 return new _Int64ArrayView(buffer, offsetInBytes, length); 1003 return new _Int64ArrayView(buffer, offsetInBytes, length);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 } 1047 }
1080 1048
1081 static _Int64Array _new(int length) native "TypedData_Int64Array_new"; 1049 static _Int64Array _new(int length) native "TypedData_Int64Array_new";
1082 } 1050 }
1083 1051
1084 1052
1085 class _Uint64Array extends _TypedList implements Uint64List { 1053 class _Uint64Array extends _TypedList implements Uint64List {
1086 // Factory constructors. 1054 // Factory constructors.
1087 1055
1088 factory _Uint64Array(int length) { 1056 factory _Uint64Array(int length) {
1089 if (length < 0) {
1090 String message = "$length must be greater than 0";
1091 throw new ArgumentError(message);
1092 }
1093 return _new(length); 1057 return _new(length);
1094 } 1058 }
1095 1059
1096 factory _Uint64Array.view(ByteBuffer buffer, 1060 factory _Uint64Array.view(ByteBuffer buffer,
1097 [int offsetInBytes = 0, int length]) { 1061 [int offsetInBytes = 0, int length]) {
1098 if (length == null) { 1062 if (length == null) {
1099 length = (buffer.lengthInBytes - offsetInBytes) ~/ 1063 length = (buffer.lengthInBytes - offsetInBytes) ~/
1100 Uint64List.BYTES_PER_ELEMENT; 1064 Uint64List.BYTES_PER_ELEMENT;
1101 } 1065 }
1102 return new _Uint64ArrayView(buffer, offsetInBytes, length); 1066 return new _Uint64ArrayView(buffer, offsetInBytes, length);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 } 1110 }
1147 1111
1148 static _Uint64Array _new(int length) native "TypedData_Uint64Array_new"; 1112 static _Uint64Array _new(int length) native "TypedData_Uint64Array_new";
1149 } 1113 }
1150 1114
1151 1115
1152 class _Float32Array extends _TypedList implements Float32List { 1116 class _Float32Array extends _TypedList implements Float32List {
1153 // Factory constructors. 1117 // Factory constructors.
1154 1118
1155 factory _Float32Array(int length) { 1119 factory _Float32Array(int length) {
1156 if (length < 0) {
1157 String message = "$length must be greater than 0";
1158 throw new ArgumentError(message);
1159 }
1160 return _new(length); 1120 return _new(length);
1161 } 1121 }
1162 1122
1163 factory _Float32Array.view(ByteBuffer buffer, 1123 factory _Float32Array.view(ByteBuffer buffer,
1164 [int offsetInBytes = 0, int length]) { 1124 [int offsetInBytes = 0, int length]) {
1165 if (length == null) { 1125 if (length == null) {
1166 length = (buffer.lengthInBytes - offsetInBytes) ~/ 1126 length = (buffer.lengthInBytes - offsetInBytes) ~/
1167 Float32List.BYTES_PER_ELEMENT; 1127 Float32List.BYTES_PER_ELEMENT;
1168 } 1128 }
1169 return new _Float32ArrayView(buffer, offsetInBytes, length); 1129 return new _Float32ArrayView(buffer, offsetInBytes, length);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 } 1173 }
1214 1174
1215 static _Float32Array _new(int length) native "TypedData_Float32Array_new"; 1175 static _Float32Array _new(int length) native "TypedData_Float32Array_new";
1216 } 1176 }
1217 1177
1218 1178
1219 class _Float64Array extends _TypedList implements Float64List { 1179 class _Float64Array extends _TypedList implements Float64List {
1220 // Factory constructors. 1180 // Factory constructors.
1221 1181
1222 factory _Float64Array(int length) { 1182 factory _Float64Array(int length) {
1223 if (length < 0) {
1224 String message = "$length must be greater than 0";
1225 throw new ArgumentError(message);
1226 }
1227 return _new(length); 1183 return _new(length);
1228 } 1184 }
1229 1185
1230 factory _Float64Array.view(ByteBuffer buffer, 1186 factory _Float64Array.view(ByteBuffer buffer,
1231 [int offsetInBytes = 0, int length]) { 1187 [int offsetInBytes = 0, int length]) {
1232 if (length == null) { 1188 if (length == null) {
1233 length = (buffer.lengthInBytes - offsetInBytes) ~/ 1189 length = (buffer.lengthInBytes - offsetInBytes) ~/
1234 Float64List.BYTES_PER_ELEMENT; 1190 Float64List.BYTES_PER_ELEMENT;
1235 } 1191 }
1236 return new _Float64ArrayView(buffer, offsetInBytes, length); 1192 return new _Float64ArrayView(buffer, offsetInBytes, length);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 _setFloat64(index * Float64List.BYTES_PER_ELEMENT, value); 1235 _setFloat64(index * Float64List.BYTES_PER_ELEMENT, value);
1280 } 1236 }
1281 1237
1282 static _Float64Array _new(int length) native "TypedData_Float64Array_new"; 1238 static _Float64Array _new(int length) native "TypedData_Float64Array_new";
1283 } 1239 }
1284 1240
1285 class _Float32x4Array extends _TypedList implements Float32x4List { 1241 class _Float32x4Array extends _TypedList implements Float32x4List {
1286 // Factory constructors. 1242 // Factory constructors.
1287 1243
1288 factory _Float32x4Array(int length) { 1244 factory _Float32x4Array(int length) {
1289 if (length < 0) {
1290 String message = "$length must be greater than 0";
1291 throw new ArgumentError(message);
1292 }
1293 return _new(length); 1245 return _new(length);
1294 } 1246 }
1295 1247
1296 factory _Float32x4Array.view(ByteBuffer buffer, 1248 factory _Float32x4Array.view(ByteBuffer buffer,
1297 [int offsetInBytes = 0, int length]) { 1249 [int offsetInBytes = 0, int length]) {
1298 if (length == null) { 1250 if (length == null) {
1299 length = (buffer.lengthInBytes - offsetInBytes) ~/ 1251 length = (buffer.lengthInBytes - offsetInBytes) ~/
1300 Float32x4List.BYTES_PER_ELEMENT; 1252 Float32x4List.BYTES_PER_ELEMENT;
1301 } 1253 }
1302 return new _Float32x4ArrayView(buffer, offsetInBytes, length); 1254 return new _Float32x4ArrayView(buffer, offsetInBytes, length);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 } 1296 }
1345 1297
1346 static _Float32x4Array _new(int length) native "TypedData_Float32x4Array_new"; 1298 static _Float32x4Array _new(int length) native "TypedData_Float32x4Array_new";
1347 } 1299 }
1348 1300
1349 1301
1350 class _ExternalInt8Array extends _TypedList implements Int8List { 1302 class _ExternalInt8Array extends _TypedList implements Int8List {
1351 // Factory constructors. 1303 // Factory constructors.
1352 1304
1353 factory _ExternalInt8Array(int length) { 1305 factory _ExternalInt8Array(int length) {
1354 if (length < 0) {
1355 String message = "$length must be greater than 0";
1356 throw new ArgumentError(message);
1357 }
1358 return _new(length); 1306 return _new(length);
1359 } 1307 }
1360 1308
1361 1309
1362 // Method(s) implementing the List interface. 1310 // Method(s) implementing the List interface.
1363 int operator[](int index) { 1311 int operator[](int index) {
1364 if (index < 0 || index >= length) { 1312 if (index < 0 || index >= length) {
1365 _throwRangeError(index, length); 1313 _throwRangeError(index, length);
1366 } 1314 }
1367 return _getInt8(index); 1315 return _getInt8(index);
(...skipping 26 matching lines...) Expand all
1394 1342
1395 static _ExternalInt8Array _new(int length) native 1343 static _ExternalInt8Array _new(int length) native
1396 "ExternalTypedData_Int8Array_new"; 1344 "ExternalTypedData_Int8Array_new";
1397 } 1345 }
1398 1346
1399 1347
1400 class _ExternalUint8Array extends _TypedList implements Uint8List { 1348 class _ExternalUint8Array extends _TypedList implements Uint8List {
1401 // Factory constructors. 1349 // Factory constructors.
1402 1350
1403 factory _ExternalUint8Array(int length) { 1351 factory _ExternalUint8Array(int length) {
1404 if (length < 0) {
1405 String message = "$length must be greater than 0";
1406 throw new ArgumentError(message);
1407 }
1408 return _new(length); 1352 return _new(length);
1409 } 1353 }
1410 1354
1411 1355
1412 // Method(s) implementing the List interface. 1356 // Method(s) implementing the List interface.
1413 1357
1414 int operator[](int index) { 1358 int operator[](int index) {
1415 if (index < 0 || index >= length) { 1359 if (index < 0 || index >= length) {
1416 _throwRangeError(index, length); 1360 _throwRangeError(index, length);
1417 } 1361 }
(...skipping 27 matching lines...) Expand all
1445 1389
1446 static _ExternalUint8Array _new(int length) native 1390 static _ExternalUint8Array _new(int length) native
1447 "ExternalTypedData_Uint8Array_new"; 1391 "ExternalTypedData_Uint8Array_new";
1448 } 1392 }
1449 1393
1450 1394
1451 class _ExternalUint8ClampedArray extends _TypedList implements Uint8ClampedList { 1395 class _ExternalUint8ClampedArray extends _TypedList implements Uint8ClampedList {
1452 // Factory constructors. 1396 // Factory constructors.
1453 1397
1454 factory _ExternalUint8ClampedArray(int length) { 1398 factory _ExternalUint8ClampedArray(int length) {
1455 if (length < 0) {
1456 String message = "$length must be greater than 0";
1457 throw new ArgumentError(message);
1458 }
1459 return _new(length); 1399 return _new(length);
1460 } 1400 }
1461 1401
1462 1402
1463 // Method(s) implementing the List interface. 1403 // Method(s) implementing the List interface.
1464 1404
1465 int operator[](int index) { 1405 int operator[](int index) {
1466 if (index < 0 || index >= length) { 1406 if (index < 0 || index >= length) {
1467 _throwRangeError(index, length); 1407 _throwRangeError(index, length);
1468 } 1408 }
(...skipping 27 matching lines...) Expand all
1496 1436
1497 static _ExternalUint8ClampedArray _new(int length) native 1437 static _ExternalUint8ClampedArray _new(int length) native
1498 "ExternalTypedData_Uint8ClampedArray_new"; 1438 "ExternalTypedData_Uint8ClampedArray_new";
1499 } 1439 }
1500 1440
1501 1441
1502 class _ExternalInt16Array extends _TypedList implements Int16List { 1442 class _ExternalInt16Array extends _TypedList implements Int16List {
1503 // Factory constructors. 1443 // Factory constructors.
1504 1444
1505 factory _ExternalInt16Array(int length) { 1445 factory _ExternalInt16Array(int length) {
1506 if (length < 0) {
1507 String message = "$length must be greater than 0";
1508 throw new ArgumentError(message);
1509 }
1510 return _new(length); 1446 return _new(length);
1511 } 1447 }
1512 1448
1513 1449
1514 // Method(s) implementing the List interface. 1450 // Method(s) implementing the List interface.
1515 1451
1516 int operator[](int index) { 1452 int operator[](int index) {
1517 if (index < 0 || index >= length) { 1453 if (index < 0 || index >= length) {
1518 _throwRangeError(index, length); 1454 _throwRangeError(index, length);
1519 } 1455 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 1491
1556 static _ExternalInt16Array _new(int length) native 1492 static _ExternalInt16Array _new(int length) native
1557 "ExternalTypedData_Int16Array_new"; 1493 "ExternalTypedData_Int16Array_new";
1558 } 1494 }
1559 1495
1560 1496
1561 class _ExternalUint16Array extends _TypedList implements Uint16List { 1497 class _ExternalUint16Array extends _TypedList implements Uint16List {
1562 // Factory constructors. 1498 // Factory constructors.
1563 1499
1564 factory _ExternalUint16Array(int length) { 1500 factory _ExternalUint16Array(int length) {
1565 if (length < 0) {
1566 String message = "$length must be greater than 0";
1567 throw new ArgumentError(message);
1568 }
1569 return _new(length); 1501 return _new(length);
1570 } 1502 }
1571 1503
1572 1504
1573 // Method(s) implementing the List interface. 1505 // Method(s) implementing the List interface.
1574 1506
1575 int operator[](int index) { 1507 int operator[](int index) {
1576 if (index < 0 || index >= length) { 1508 if (index < 0 || index >= length) {
1577 _throwRangeError(index, length); 1509 _throwRangeError(index, length);
1578 } 1510 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 1546
1615 static _ExternalUint16Array _new(int length) native 1547 static _ExternalUint16Array _new(int length) native
1616 "ExternalTypedData_Uint16Array_new"; 1548 "ExternalTypedData_Uint16Array_new";
1617 } 1549 }
1618 1550
1619 1551
1620 class _ExternalInt32Array extends _TypedList implements Int32List { 1552 class _ExternalInt32Array extends _TypedList implements Int32List {
1621 // Factory constructors. 1553 // Factory constructors.
1622 1554
1623 factory _ExternalInt32Array(int length) { 1555 factory _ExternalInt32Array(int length) {
1624 if (length < 0) {
1625 String message = "$length must be greater than 0";
1626 throw new ArgumentError(message);
1627 }
1628 return _new(length); 1556 return _new(length);
1629 } 1557 }
1630 1558
1631 1559
1632 // Method(s) implementing the List interface. 1560 // Method(s) implementing the List interface.
1633 1561
1634 int operator[](int index) { 1562 int operator[](int index) {
1635 if (index < 0 || index >= length) { 1563 if (index < 0 || index >= length) {
1636 _throwRangeError(index, length); 1564 _throwRangeError(index, length);
1637 } 1565 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 1601
1674 static _ExternalInt32Array _new(int length) native 1602 static _ExternalInt32Array _new(int length) native
1675 "ExternalTypedData_Int32Array_new"; 1603 "ExternalTypedData_Int32Array_new";
1676 } 1604 }
1677 1605
1678 1606
1679 class _ExternalUint32Array extends _TypedList implements Uint32List { 1607 class _ExternalUint32Array extends _TypedList implements Uint32List {
1680 // Factory constructors. 1608 // Factory constructors.
1681 1609
1682 factory _ExternalUint32Array(int length) { 1610 factory _ExternalUint32Array(int length) {
1683 if (length < 0) {
1684 String message = "$length must be greater than 0";
1685 throw new ArgumentError(message);
1686 }
1687 return _new(length); 1611 return _new(length);
1688 } 1612 }
1689 1613
1690 1614
1691 // Method(s) implementing the List interface. 1615 // Method(s) implementing the List interface.
1692 1616
1693 int operator[](int index) { 1617 int operator[](int index) {
1694 if (index < 0 || index >= length) { 1618 if (index < 0 || index >= length) {
1695 _throwRangeError(index, length); 1619 _throwRangeError(index, length);
1696 } 1620 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 1656
1733 static _ExternalUint32Array _new(int length) native 1657 static _ExternalUint32Array _new(int length) native
1734 "ExternalTypedData_Uint32Array_new"; 1658 "ExternalTypedData_Uint32Array_new";
1735 } 1659 }
1736 1660
1737 1661
1738 class _ExternalInt64Array extends _TypedList implements Int64List { 1662 class _ExternalInt64Array extends _TypedList implements Int64List {
1739 // Factory constructors. 1663 // Factory constructors.
1740 1664
1741 factory _ExternalInt64Array(int length) { 1665 factory _ExternalInt64Array(int length) {
1742 if (length < 0) {
1743 String message = "$length must be greater than 0";
1744 throw new ArgumentError(message);
1745 }
1746 return _new(length); 1666 return _new(length);
1747 } 1667 }
1748 1668
1749 1669
1750 // Method(s) implementing the List interface. 1670 // Method(s) implementing the List interface.
1751 1671
1752 int operator[](int index) { 1672 int operator[](int index) {
1753 if (index < 0 || index >= length) { 1673 if (index < 0 || index >= length) {
1754 _throwRangeError(index, length); 1674 _throwRangeError(index, length);
1755 } 1675 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 1711
1792 static _ExternalInt64Array _new(int length) native 1712 static _ExternalInt64Array _new(int length) native
1793 "ExternalTypedData_Int64Array_new"; 1713 "ExternalTypedData_Int64Array_new";
1794 } 1714 }
1795 1715
1796 1716
1797 class _ExternalUint64Array extends _TypedList implements Uint64List { 1717 class _ExternalUint64Array extends _TypedList implements Uint64List {
1798 // Factory constructors. 1718 // Factory constructors.
1799 1719
1800 factory _ExternalUint64Array(int length) { 1720 factory _ExternalUint64Array(int length) {
1801 if (length < 0) {
1802 String message = "$length must be greater than 0";
1803 throw new ArgumentError(message);
1804 }
1805 return _new(length); 1721 return _new(length);
1806 } 1722 }
1807 1723
1808 1724
1809 // Method(s) implementing the List interface. 1725 // Method(s) implementing the List interface.
1810 1726
1811 int operator[](int index) { 1727 int operator[](int index) {
1812 if (index < 0 || index >= length) { 1728 if (index < 0 || index >= length) {
1813 _throwRangeError(index, length); 1729 _throwRangeError(index, length);
1814 } 1730 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 1766
1851 static _ExternalUint64Array _new(int length) native 1767 static _ExternalUint64Array _new(int length) native
1852 "ExternalTypedData_Uint64Array_new"; 1768 "ExternalTypedData_Uint64Array_new";
1853 } 1769 }
1854 1770
1855 1771
1856 class _ExternalFloat32Array extends _TypedList implements Float32List { 1772 class _ExternalFloat32Array extends _TypedList implements Float32List {
1857 // Factory constructors. 1773 // Factory constructors.
1858 1774
1859 factory _ExternalFloat32Array(int length) { 1775 factory _ExternalFloat32Array(int length) {
1860 if (length < 0) {
1861 String message = "$length must be greater than 0";
1862 throw new ArgumentError(message);
1863 }
1864 return _new(length); 1776 return _new(length);
1865 } 1777 }
1866 1778
1867 1779
1868 // Method(s) implementing the List interface. 1780 // Method(s) implementing the List interface.
1869 1781
1870 double operator[](int index) { 1782 double operator[](int index) {
1871 if (index < 0 || index >= length) { 1783 if (index < 0 || index >= length) {
1872 _throwRangeError(index, length); 1784 _throwRangeError(index, length);
1873 } 1785 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 1821
1910 static _ExternalFloat32Array _new(int length) native 1822 static _ExternalFloat32Array _new(int length) native
1911 "ExternalTypedData_Float32Array_new"; 1823 "ExternalTypedData_Float32Array_new";
1912 } 1824 }
1913 1825
1914 1826
1915 class _ExternalFloat64Array extends _TypedList implements Float64List { 1827 class _ExternalFloat64Array extends _TypedList implements Float64List {
1916 // Factory constructors. 1828 // Factory constructors.
1917 1829
1918 factory _ExternalFloat64Array(int length) { 1830 factory _ExternalFloat64Array(int length) {
1919 if (length < 0) {
1920 String message = "$length must be greater than 0";
1921 throw new ArgumentError(message);
1922 }
1923 return _new(length); 1831 return _new(length);
1924 } 1832 }
1925 1833
1926 1834
1927 // Method(s) implementing the List interface. 1835 // Method(s) implementing the List interface.
1928 1836
1929 double operator[](int index) { 1837 double operator[](int index) {
1930 if (index < 0 || index >= length) { 1838 if (index < 0 || index >= length) {
1931 _throwRangeError(index, length); 1839 _throwRangeError(index, length);
1932 } 1840 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 1876
1969 static _ExternalFloat64Array _new(int length) native 1877 static _ExternalFloat64Array _new(int length) native
1970 "ExternalTypedData_Float64Array_new"; 1878 "ExternalTypedData_Float64Array_new";
1971 } 1879 }
1972 1880
1973 1881
1974 class _ExternalFloat32x4Array extends _TypedList implements Float32x4List { 1882 class _ExternalFloat32x4Array extends _TypedList implements Float32x4List {
1975 // Factory constructors. 1883 // Factory constructors.
1976 1884
1977 factory _ExternalFloat32x4Array(int length) { 1885 factory _ExternalFloat32x4Array(int length) {
1978 if (length < 0) {
1979 String message = "$length must be greater than 0";
1980 throw new ArgumentError(message);
1981 }
1982 return _new(length); 1886 return _new(length);
1983 } 1887 }
1984 1888
1985 1889
1986 // Method(s) implementing the List interface. 1890 // Method(s) implementing the List interface.
1987 1891
1988 Float32x4 operator[](int index) { 1892 Float32x4 operator[](int index) {
1989 if (index < 0 || index >= length) { 1893 if (index < 0 || index >= length) {
1990 _throwRangeError(index, length); 1894 _throwRangeError(index, length);
1991 } 1895 }
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3201 return value; 3105 return value;
3202 } 3106 }
3203 return object; 3107 return object;
3204 } 3108 }
3205 3109
3206 3110
3207 void _throwRangeError(int index, int length) { 3111 void _throwRangeError(int index, int length) {
3208 String message = "$index must be in the range [0..$length)"; 3112 String message = "$index must be in the range [0..$length)";
3209 throw new RangeError(message); 3113 throw new RangeError(message);
3210 } 3114 }
OLDNEW
« no previous file with comments | « runtime/lib/typed_data.cc ('k') | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698