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

Side by Side Diff: tool/input_sdk/private/native_typed_data.dart

Issue 1348453004: fix some errors in our SDK, mostly around numbers (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « tool/input_sdk/private/js_string.dart ('k') | tool/sdk_expected_errors.txt » ('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 /** 5 /**
6 * Specialized integers and floating point numbers, 6 * Specialized integers and floating point numbers,
7 * with SIMD support and efficient lists. 7 * with SIMD support and efficient lists.
8 */ 8 */
9 library dart.typed_data.implementation; 9 library dart.typed_data.implementation;
10 10
11 import 'dart:collection'; 11 import 'dart:collection';
12 import 'dart:_internal'; 12 import 'dart:_internal';
13 import 'dart:_interceptors' show JSIndexable, JSUInt32, JSUInt31; 13 import 'dart:_interceptors' show JSIndexable;
14 import 'dart:_js_helper' 14 import 'dart:_js_helper'
15 show Creates, JavaScriptIndexingBehavior, JSName, Native, Null, Returns; 15 show Creates, JavaScriptIndexingBehavior, JSName, Native, Null, Returns;
16 import 'dart:_foreign_helper' show JS; 16 import 'dart:_foreign_helper' show JS;
17 import 'dart:math' as Math; 17 import 'dart:math' as Math;
18 18
19 import 'dart:typed_data'; 19 import 'dart:typed_data';
20 20
21 @Native("ArrayBuffer") 21 @Native("ArrayBuffer")
22 class NativeByteBuffer implements ByteBuffer { 22 class NativeByteBuffer implements ByteBuffer {
23 @JSName('byteLength') 23 @JSName('byteLength')
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 * form. 642 * form.
643 * The return value will be between 0 and 2<sup>16</sup> - 1, inclusive. 643 * The return value will be between 0 and 2<sup>16</sup> - 1, inclusive.
644 * 644 *
645 * Throws [RangeError] if [byteOffset] is negative, or 645 * Throws [RangeError] if [byteOffset] is negative, or
646 * `byteOffset + 2` is greater than the length of this object. 646 * `byteOffset + 2` is greater than the length of this object.
647 */ 647 */
648 int getUint16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => 648 int getUint16(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
649 _getUint16(byteOffset, Endianness.LITTLE_ENDIAN == endian); 649 _getUint16(byteOffset, Endianness.LITTLE_ENDIAN == endian);
650 650
651 @JSName('getUint16') 651 @JSName('getUint16')
652 @Returns('JSUInt31') 652 @Returns('int')
653 int _getUint16(int byteOffset, [bool littleEndian]) native; 653 int _getUint16(int byteOffset, [bool littleEndian]) native;
654 654
655 /** 655 /**
656 * Returns the positive integer represented by the four bytes starting 656 * Returns the positive integer represented by the four bytes starting
657 * at the specified [byteOffset] in this object, in unsigned binary 657 * at the specified [byteOffset] in this object, in unsigned binary
658 * form. 658 * form.
659 * The return value will be between 0 and 2<sup>32</sup> - 1, inclusive. 659 * The return value will be between 0 and 2<sup>32</sup> - 1, inclusive.
660 * 660 *
661 * Throws [RangeError] if [byteOffset] is negative, or 661 * Throws [RangeError] if [byteOffset] is negative, or
662 * `byteOffset + 4` is greater than the length of this object. 662 * `byteOffset + 4` is greater than the length of this object.
663 */ 663 */
664 int getUint32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) => 664 int getUint32(int byteOffset, [Endianness endian=Endianness.BIG_ENDIAN]) =>
665 _getUint32(byteOffset, Endianness.LITTLE_ENDIAN == endian); 665 _getUint32(byteOffset, Endianness.LITTLE_ENDIAN == endian);
666 666
667 @JSName('getUint32') 667 @JSName('getUint32')
668 @Returns('JSUInt32') 668 @Returns('int')
669 int _getUint32(int byteOffset, [bool littleEndian]) native; 669 int _getUint32(int byteOffset, [bool littleEndian]) native;
670 670
671 /** 671 /**
672 * Returns the positive integer represented by the eight bytes starting 672 * Returns the positive integer represented by the eight bytes starting
673 * at the specified [byteOffset] in this object, in unsigned binary 673 * at the specified [byteOffset] in this object, in unsigned binary
674 * form. 674 * form.
675 * The return value will be between 0 and 2<sup>64</sup> - 1, inclusive. 675 * The return value will be between 0 and 2<sup>64</sup> - 1, inclusive.
676 * 676 *
677 * Throws [RangeError] if [byteOffset] is negative, or 677 * Throws [RangeError] if [byteOffset] is negative, or
678 * `byteOffset + 8` is greater than the length of this object. 678 * `byteOffset + 8` is greater than the length of this object.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 source, skipCount, skipCount + count); 881 source, skipCount, skipCount + count);
882 } 882 }
883 JS('void', '#.set(#, #)', this, source, start); 883 JS('void', '#.set(#, #)', this, source, start);
884 } 884 }
885 } 885 }
886 886
887 abstract class NativeTypedArrayOfDouble 887 abstract class NativeTypedArrayOfDouble
888 extends NativeTypedArray 888 extends NativeTypedArray
889 with ListMixin<double>, FixedLengthListMixin<double> { 889 with ListMixin<double>, FixedLengthListMixin<double> {
890 890
891 int get length => JS('JSUInt32', '#.length', this); 891 int get length => JS('int', '#.length', this);
892 892
893 double operator[](int index) { 893 double operator[](int index) {
894 _checkIndex(index, length); 894 _checkIndex(index, length);
895 return JS('double', '#[#]', this, index); 895 return JS('double', '#[#]', this, index);
896 } 896 }
897 897
898 void operator[]=(int index, num value) { 898 void operator[]=(int index, num value) {
899 _checkIndex(index, length); 899 _checkIndex(index, length);
900 JS('void', '#[#] = #', this, index, value); 900 JS('void', '#[#] = #', this, index, value);
901 } 901 }
902 902
903 void setRange(int start, int end, Iterable<double> iterable, 903 void setRange(int start, int end, Iterable<double> iterable,
904 [int skipCount = 0]) { 904 [int skipCount = 0]) {
905 if (iterable is NativeTypedArrayOfDouble) { 905 if (iterable is NativeTypedArrayOfDouble) {
906 _setRangeFast(start, end, iterable, skipCount); 906 _setRangeFast(start, end, iterable, skipCount);
907 return; 907 return;
908 } 908 }
909 super.setRange(start, end, iterable, skipCount); 909 super.setRange(start, end, iterable, skipCount);
910 } 910 }
911 } 911 }
912 912
913 abstract class NativeTypedArrayOfInt 913 abstract class NativeTypedArrayOfInt
914 extends NativeTypedArray 914 extends NativeTypedArray
915 with ListMixin<int>, FixedLengthListMixin<int> 915 with ListMixin<int>, FixedLengthListMixin<int>
916 implements List<int> { 916 implements List<int> {
917 917
918 int get length => JS('JSUInt32', '#.length', this); 918 int get length => JS('int', '#.length', this);
919 919
920 // operator[]() is not here since different versions have different return 920 // operator[]() is not here since different versions have different return
921 // types 921 // types
922 922
923 void operator[]=(int index, int value) { 923 void operator[]=(int index, int value) {
924 _checkIndex(index, length); 924 _checkIndex(index, length);
925 JS('void', '#[#] = #', this, index, value); 925 JS('void', '#[#] = #', this, index, value);
926 } 926 }
927 927
928 void setRange(int start, int end, Iterable<int> iterable, 928 void setRange(int start, int end, Iterable<int> iterable,
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 _checkViewArguments(buffer, offsetInBytes, length); 1145 _checkViewArguments(buffer, offsetInBytes, length);
1146 return length == null 1146 return length == null
1147 ? _create2(buffer, offsetInBytes) 1147 ? _create2(buffer, offsetInBytes)
1148 : _create3(buffer, offsetInBytes, length); 1148 : _create3(buffer, offsetInBytes, length);
1149 } 1149 }
1150 1150
1151 Type get runtimeType => Uint16List; 1151 Type get runtimeType => Uint16List;
1152 1152
1153 int operator[](int index) { 1153 int operator[](int index) {
1154 _checkIndex(index, length); 1154 _checkIndex(index, length);
1155 return JS('JSUInt31', '#[#]', this, index); 1155 return JS('int', '#[#]', this, index);
1156 } 1156 }
1157 1157
1158 List<int> sublist(int start, [int end]) { 1158 List<int> sublist(int start, [int end]) {
1159 end = _checkSublistArguments(start, end, length); 1159 end = _checkSublistArguments(start, end, length);
1160 var source = JS('NativeUint16List', '#.subarray(#, #)', this, start, end); 1160 var source = JS('NativeUint16List', '#.subarray(#, #)', this, start, end);
1161 return _create1(source); 1161 return _create1(source);
1162 } 1162 }
1163 1163
1164 static NativeUint16List _create1(arg) => 1164 static NativeUint16List _create1(arg) =>
1165 JS('NativeUint16List', 'new Uint16Array(#)', arg); 1165 JS('NativeUint16List', 'new Uint16Array(#)', arg);
(...skipping 19 matching lines...) Expand all
1185 _checkViewArguments(buffer, offsetInBytes, length); 1185 _checkViewArguments(buffer, offsetInBytes, length);
1186 return length == null 1186 return length == null
1187 ? _create2(buffer, offsetInBytes) 1187 ? _create2(buffer, offsetInBytes)
1188 : _create3(buffer, offsetInBytes, length); 1188 : _create3(buffer, offsetInBytes, length);
1189 } 1189 }
1190 1190
1191 Type get runtimeType => Uint32List; 1191 Type get runtimeType => Uint32List;
1192 1192
1193 int operator[](int index) { 1193 int operator[](int index) {
1194 _checkIndex(index, length); 1194 _checkIndex(index, length);
1195 return JS('JSUInt32', '#[#]', this, index); 1195 return JS('int', '#[#]', this, index);
1196 } 1196 }
1197 1197
1198 List<int> sublist(int start, [int end]) { 1198 List<int> sublist(int start, [int end]) {
1199 end = _checkSublistArguments(start, end, length); 1199 end = _checkSublistArguments(start, end, length);
1200 var source = JS('NativeUint32List', '#.subarray(#, #)', this, start, end); 1200 var source = JS('NativeUint32List', '#.subarray(#, #)', this, start, end);
1201 return _create1(source); 1201 return _create1(source);
1202 } 1202 }
1203 1203
1204 static NativeUint32List _create1(arg) => 1204 static NativeUint32List _create1(arg) =>
1205 JS('NativeUint32List', 'new Uint32Array(#)', arg); 1205 JS('NativeUint32List', 'new Uint32Array(#)', arg);
(...skipping 19 matching lines...) Expand all
1225 factory NativeUint8ClampedList.view(ByteBuffer buffer, 1225 factory NativeUint8ClampedList.view(ByteBuffer buffer,
1226 int offsetInBytes, int length) { 1226 int offsetInBytes, int length) {
1227 _checkViewArguments(buffer, offsetInBytes, length); 1227 _checkViewArguments(buffer, offsetInBytes, length);
1228 return length == null 1228 return length == null
1229 ? _create2(buffer, offsetInBytes) 1229 ? _create2(buffer, offsetInBytes)
1230 : _create3(buffer, offsetInBytes, length); 1230 : _create3(buffer, offsetInBytes, length);
1231 } 1231 }
1232 1232
1233 Type get runtimeType => Uint8ClampedList; 1233 Type get runtimeType => Uint8ClampedList;
1234 1234
1235 int get length => JS('JSUInt32', '#.length', this); 1235 int get length => JS('int', '#.length', this);
1236 1236
1237 int operator[](int index) { 1237 int operator[](int index) {
1238 _checkIndex(index, length); 1238 _checkIndex(index, length);
1239 return JS('JSUInt31', '#[#]', this, index); 1239 return JS('int', '#[#]', this, index);
1240 } 1240 }
1241 1241
1242 List<int> sublist(int start, [int end]) { 1242 List<int> sublist(int start, [int end]) {
1243 end = _checkSublistArguments(start, end, length); 1243 end = _checkSublistArguments(start, end, length);
1244 var source = JS('NativeUint8ClampedList', '#.subarray(#, #)', 1244 var source = JS('NativeUint8ClampedList', '#.subarray(#, #)',
1245 this, start, end); 1245 this, start, end);
1246 return _create1(source); 1246 return _create1(source);
1247 } 1247 }
1248 1248
1249 static NativeUint8ClampedList _create1(arg) => 1249 static NativeUint8ClampedList _create1(arg) =>
(...skipping 23 matching lines...) Expand all
1273 factory NativeUint8List.view(ByteBuffer buffer, 1273 factory NativeUint8List.view(ByteBuffer buffer,
1274 int offsetInBytes, int length) { 1274 int offsetInBytes, int length) {
1275 _checkViewArguments(buffer, offsetInBytes, length); 1275 _checkViewArguments(buffer, offsetInBytes, length);
1276 return length == null 1276 return length == null
1277 ? _create2(buffer, offsetInBytes) 1277 ? _create2(buffer, offsetInBytes)
1278 : _create3(buffer, offsetInBytes, length); 1278 : _create3(buffer, offsetInBytes, length);
1279 } 1279 }
1280 1280
1281 Type get runtimeType => Uint8List; 1281 Type get runtimeType => Uint8List;
1282 1282
1283 int get length => JS('JSUInt32', '#.length', this); 1283 int get length => JS('int', '#.length', this);
1284 1284
1285 int operator[](int index) { 1285 int operator[](int index) {
1286 _checkIndex(index, length); 1286 _checkIndex(index, length);
1287 return JS('JSUInt31', '#[#]', this, index); 1287 return JS('int', '#[#]', this, index);
1288 } 1288 }
1289 1289
1290 List<int> sublist(int start, [int end]) { 1290 List<int> sublist(int start, [int end]) {
1291 end = _checkSublistArguments(start, end, length); 1291 end = _checkSublistArguments(start, end, length);
1292 var source = JS('NativeUint8List', '#.subarray(#, #)', this, start, end); 1292 var source = JS('NativeUint8List', '#.subarray(#, #)', this, start, end);
1293 return _create1(source); 1293 return _create1(source);
1294 } 1294 }
1295 1295
1296 static NativeUint8List _create1(arg) => 1296 static NativeUint8List _create1(arg) =>
1297 JS('NativeUint8List', 'new Uint8Array(#)', arg); 1297 JS('NativeUint8List', 'new Uint8Array(#)', arg);
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 Float64x2 max(Float64x2 other) { 2004 Float64x2 max(Float64x2 other) {
2005 return new NativeFloat64x2._doubles(x > other.x ? x : other.x, 2005 return new NativeFloat64x2._doubles(x > other.x ? x : other.x,
2006 y > other.y ? y : other.y); 2006 y > other.y ? y : other.y);
2007 } 2007 }
2008 2008
2009 /// Returns the lane-wise square root of [this]. 2009 /// Returns the lane-wise square root of [this].
2010 Float64x2 sqrt() { 2010 Float64x2 sqrt() {
2011 return new NativeFloat64x2._doubles(Math.sqrt(x), Math.sqrt(y)); 2011 return new NativeFloat64x2._doubles(Math.sqrt(x), Math.sqrt(y));
2012 } 2012 }
2013 } 2013 }
OLDNEW
« no previous file with comments | « tool/input_sdk/private/js_string.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698