Add documentation, tests and better parameter names to Float32x4.

The same should happen for `Int32x4` and `Float64x2`,
but this is a start.

The existing class was basically uncommented and you had
to guess or explore to find out what, fx, the returned
values for the relational operators means.

I've tried to discover and document the current behavior,
but I had to fall back on "it's implementation specific"
in some places where platforms behave differently.
(For example it seems VM on Mac treats `.reciprocalSqrt()`
as doing `.sqrt().reciprocal()` where the other platforms do
`.reciprocal().sqrt()`, which makes a difference for exactly
one value.)

CoreLibraryReviewExempt: Doc and parameter name changes only.
Tested: Added more tests to float32x4_test.dart.
Change-Id: I3f8804f842d8a5d95e1d378a7edb9438a2f3ed2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415000
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Lasse R.H. Nielsen
2025-03-14 06:22:42 -07:00
committed by Commit Queue
parent b9b77058a9
commit 13df9529fd
10 changed files with 2296 additions and 658 deletions
@@ -156,14 +156,14 @@ class Float32x4 {
@patch
factory Float32x4(double x, double y, double z, double w) = NativeFloat32x4;
@patch
factory Float32x4.splat(double v) = NativeFloat32x4.splat;
factory Float32x4.splat(double value) = NativeFloat32x4.splat;
@patch
factory Float32x4.zero() = NativeFloat32x4.zero;
@patch
factory Float32x4.fromInt32x4Bits(Int32x4 x) =
factory Float32x4.fromInt32x4Bits(Int32x4 bits) =
NativeFloat32x4.fromInt32x4Bits;
@patch
factory Float32x4.fromFloat64x2(Float64x2 v) = NativeFloat32x4.fromFloat64x2;
factory Float32x4.fromFloat64x2(Float64x2 xy) = NativeFloat32x4.fromFloat64x2;
}
@patch
@@ -1219,20 +1219,20 @@ final class NativeFloat32x4 implements Float32x4 {
if (w is! num) throw ArgumentError(w);
}
NativeFloat32x4.splat(double v) : this(v, v, v, v);
NativeFloat32x4.splat(double value) : this(value, value, value, value);
NativeFloat32x4.zero() : this._truncated(0.0, 0.0, 0.0, 0.0);
/// Returns a bit-wise copy of [i] as a Float32x4.
factory NativeFloat32x4.fromInt32x4Bits(Int32x4 i) {
_uint32view[0] = i.x;
_uint32view[1] = i.y;
_uint32view[2] = i.z;
_uint32view[3] = i.w;
/// Returns a bit-wise copy of [bits] as a Float32x4.
factory NativeFloat32x4.fromInt32x4Bits(Int32x4 bits) {
_uint32view[0] = bits.x;
_uint32view[1] = bits.y;
_uint32view[2] = bits.z;
_uint32view[3] = bits.w;
return NativeFloat32x4._truncated(_list[0], _list[1], _list[2], _list[3]);
}
NativeFloat32x4.fromFloat64x2(Float64x2 v)
: this._truncated(_truncate(v.x), _truncate(v.y), 0.0, 0.0);
NativeFloat32x4.fromFloat64x2(Float64x2 xy)
: this._truncated(_truncate(xy.x), _truncate(xy.y), 0.0, 0.0);
/// Creates a new NativeFloat32x4.
///
@@ -1380,11 +1380,11 @@ final class NativeFloat32x4 implements Float32x4 {
}
/// Returns a copy of this [Float32x4] each lane being scaled by [s].
Float32x4 scale(double s) {
double _x = s * x;
double _y = s * y;
double _z = s * z;
double _w = s * w;
Float32x4 scale(double scale) {
double _x = scale * x;
double _y = scale * y;
double _z = scale * z;
double _w = scale * w;
return NativeFloat32x4._doubles(_x, _y, _z, _w);
}
@@ -46,8 +46,10 @@ final class NativeByteBuffer extends JavaScriptObject
return NativeInt8List.view(this, offsetInBytes, length);
}
NativeUint8ClampedList asUint8ClampedList(
[int offsetInBytes = 0, int? length]) {
NativeUint8ClampedList asUint8ClampedList([
int offsetInBytes = 0,
int? length,
]) {
return NativeUint8ClampedList.view(this, offsetInBytes, length);
}
@@ -121,7 +123,7 @@ final class NativeFloat32x4List extends Object
NativeFloat32x4List._externalStorage(this._storage);
NativeFloat32x4List._slowFromList(List<Float32x4> list)
: _storage = NativeFloat32List(list.length * 4) {
: _storage = NativeFloat32List(list.length * 4) {
for (int i = 0; i < list.length; i++) {
var e = list[i];
_storage[(i * 4) + 0] = e.x;
@@ -138,7 +140,8 @@ final class NativeFloat32x4List extends Object
factory NativeFloat32x4List.fromList(List<Float32x4> list) {
if (list is NativeFloat32x4List) {
return NativeFloat32x4List._externalStorage(
NativeFloat32List.fromList(list._storage));
NativeFloat32List.fromList(list._storage),
);
} else {
return NativeFloat32x4List._slowFromList(list);
}
@@ -177,7 +180,8 @@ final class NativeFloat32x4List extends Object
Float32x4List sublist(int start, [int? end]) {
var stop = _checkValidRange(start, end, this.length);
return NativeFloat32x4List._externalStorage(
_storage.sublist(start * 4, stop * 4));
_storage.sublist(start * 4, stop * 4),
);
}
}
@@ -207,7 +211,7 @@ final class NativeInt32x4List extends Object
NativeInt32x4List._externalStorage(this._storage);
NativeInt32x4List._slowFromList(List<Int32x4> list)
: _storage = NativeInt32List(list.length * 4) {
: _storage = NativeInt32List(list.length * 4) {
for (int i = 0; i < list.length; i++) {
var e = list[i];
_storage[(i * 4) + 0] = e.x;
@@ -224,7 +228,8 @@ final class NativeInt32x4List extends Object
factory NativeInt32x4List.fromList(List<Int32x4> list) {
if (list is NativeInt32x4List) {
return NativeInt32x4List._externalStorage(
NativeInt32List.fromList(list._storage));
NativeInt32List.fromList(list._storage),
);
} else {
return NativeInt32x4List._slowFromList(list);
}
@@ -262,7 +267,8 @@ final class NativeInt32x4List extends Object
Int32x4List sublist(int start, [int? end]) {
var stop = _checkValidRange(start, end, this.length);
return NativeInt32x4List._externalStorage(
_storage.sublist(start * 4, stop * 4));
_storage.sublist(start * 4, stop * 4),
);
}
}
@@ -292,7 +298,7 @@ final class NativeFloat64x2List extends Object
NativeFloat64x2List._externalStorage(this._storage);
NativeFloat64x2List._slowFromList(List<Float64x2> list)
: _storage = NativeFloat64List(list.length * 2) {
: _storage = NativeFloat64List(list.length * 2) {
for (int i = 0; i < list.length; i++) {
var e = list[i];
_storage[(i * 2) + 0] = e.x;
@@ -305,7 +311,8 @@ final class NativeFloat64x2List extends Object
factory NativeFloat64x2List.fromList(List<Float64x2> list) {
if (list is NativeFloat64x2List) {
return NativeFloat64x2List._externalStorage(
NativeFloat64List.fromList(list._storage));
NativeFloat64List.fromList(list._storage),
);
} else {
return NativeFloat64x2List._slowFromList(list);
}
@@ -342,7 +349,8 @@ final class NativeFloat64x2List extends Object
Float64x2List sublist(int start, [int? end]) {
var stop = _checkValidRange(start, end, this.length);
return NativeFloat64x2List._externalStorage(
_storage.sublist(start * 2, stop * 2));
_storage.sublist(start * 2, stop * 2),
);
}
}
@@ -412,7 +420,11 @@ final class NativeTypedData extends JavaScriptObject implements TypedData {
@pragma('dart2js:prefer-inline')
void _checkMutable(String operation) {
HArrayFlagsCheck(
this, HArrayFlagsGet(this), ArrayFlags.unmodifiableCheck, operation);
this,
HArrayFlagsGet(this),
ArrayFlags.unmodifiableCheck,
operation,
);
}
}
@@ -552,7 +564,10 @@ final class NativeByteData extends NativeTypedData
/// [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
/// equal to the length of [buffer].
factory NativeByteData.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
return length == null
? _create2(buffer, offsetInBytes)
@@ -565,8 +580,10 @@ final class NativeByteData extends NativeTypedData
ByteData asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, lengthInBytes),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, lengthInBytes),
ArrayFlags.unmodifiable,
);
}
/// Returns the floating point number represented by the four bytes at
@@ -864,9 +881,10 @@ final class NativeByteData extends NativeTypedData
void _setUint8(int byteOffset, int value) native;
static NativeByteData _create1(arg) => JS(
'returns:NativeByteData;effects:none;depends:none;new:true',
'new DataView(new ArrayBuffer(#))',
arg);
'returns:NativeByteData;effects:none;depends:none;new:true',
'new DataView(new ArrayBuffer(#))',
arg,
);
static NativeByteData _create2(arg1, arg2) =>
JS('NativeByteData', 'new DataView(#, #)', arg1, arg2);
@@ -880,7 +898,11 @@ abstract final class NativeTypedArray<E> extends NativeTypedData
int get length => JS('JSUInt32', '#.length', this);
void _setRangeFast(
int start, int end, NativeTypedArray source, int skipCount) {
int start,
int end,
NativeTypedArray source,
int skipCount,
) {
int targetLength = this.length;
_checkPosition(start, targetLength, 'start');
_checkPosition(end, targetLength, 'end');
@@ -915,8 +937,12 @@ abstract final class NativeTypedArrayOfDouble extends NativeTypedArray<double>
JS('void', '#[#] = #', this, index, value);
}
void setRange(int start, int end, Iterable<double> iterable,
[int skipCount = 0]) {
void setRange(
int start,
int end,
Iterable<double> iterable, [
int skipCount = 0,
]) {
_checkMutable('setRange');
if (iterable is NativeTypedArrayOfDouble) {
_setRangeFast(start, end, iterable, skipCount);
@@ -938,8 +964,12 @@ abstract final class NativeTypedArrayOfInt extends NativeTypedArray<int>
JS('void', '#[#] = #', this, index, value);
}
void setRange(int start, int end, Iterable<int> iterable,
[int skipCount = 0]) {
void setRange(
int start,
int end,
Iterable<int> iterable, [
int skipCount = 0,
]) {
_checkMutable('setRange');
if (iterable is NativeTypedArrayOfInt) {
_setRangeFast(start, end, iterable, skipCount);
@@ -958,7 +988,10 @@ final class NativeFloat32List extends NativeTypedArrayOfDouble
_create1(_ensureNativeList(elements));
factory NativeFloat32List.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
length ??=
(buffer.lengthInBytes - offsetInBytes) ~/ Float32List.bytesPerElement;
@@ -969,8 +1002,10 @@ final class NativeFloat32List extends NativeTypedArrayOfDouble
Float32List asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeFloat32List sublist(int start, [int? end]) {
@@ -980,9 +1015,10 @@ final class NativeFloat32List extends NativeTypedArrayOfDouble
}
static NativeFloat32List _createLength(int arg) => JS(
'returns:NativeFloat32List;effects:none;depends:none;new:true',
'new Float32Array(#)',
arg);
'returns:NativeFloat32List;effects:none;depends:none;new:true',
'new Float32Array(#)',
arg,
);
static NativeFloat32List _create1(arg) =>
JS('NativeFloat32List', 'new Float32Array(#)', arg);
@@ -1000,7 +1036,10 @@ final class NativeFloat64List extends NativeTypedArrayOfDouble
_create1(_ensureNativeList(elements));
factory NativeFloat64List.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
length ??=
(buffer.lengthInBytes - offsetInBytes) ~/ Float64List.bytesPerElement;
@@ -1011,8 +1050,10 @@ final class NativeFloat64List extends NativeTypedArrayOfDouble
Float64List asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeFloat64List sublist(int start, [int? end]) {
@@ -1022,9 +1063,10 @@ final class NativeFloat64List extends NativeTypedArrayOfDouble
}
static NativeFloat64List _createLength(int arg) => JS(
'returns:NativeFloat64List;effects:none;depends:none;new:true',
'new Float64Array(#)',
arg);
'returns:NativeFloat64List;effects:none;depends:none;new:true',
'new Float64Array(#)',
arg,
);
static NativeFloat64List _create1(arg) =>
JS('NativeFloat64List', 'new Float64Array(#)', arg);
@@ -1042,7 +1084,10 @@ final class NativeInt16List extends NativeTypedArrayOfInt
_create1(_ensureNativeList(elements));
factory NativeInt16List.view(
NativeByteBuffer buffer, int offsetInBytes, int? length) {
NativeByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
length ??=
(buffer.lengthInBytes - offsetInBytes) ~/ Int16List.bytesPerElement;
@@ -1058,8 +1103,10 @@ final class NativeInt16List extends NativeTypedArrayOfInt
Int16List asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeInt16List sublist(int start, [int? end]) {
@@ -1069,9 +1116,10 @@ final class NativeInt16List extends NativeTypedArrayOfInt
}
static NativeInt16List _createLength(int arg) => JS(
'returns:NativeInt16List;effects:none;depends:none;new:true',
'new Int16Array(#)',
arg);
'returns:NativeInt16List;effects:none;depends:none;new:true',
'new Int16Array(#)',
arg,
);
static NativeInt16List _create1(arg) =>
JS('NativeInt16List', 'new Int16Array(#)', arg);
@@ -1089,7 +1137,10 @@ final class NativeInt32List extends NativeTypedArrayOfInt
_create1(_ensureNativeList(elements));
factory NativeInt32List.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
length ??=
(buffer.lengthInBytes - offsetInBytes) ~/ Int32List.bytesPerElement;
@@ -1105,8 +1156,10 @@ final class NativeInt32List extends NativeTypedArrayOfInt
Int32List asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeInt32List sublist(int start, [int? end]) {
@@ -1116,9 +1169,10 @@ final class NativeInt32List extends NativeTypedArrayOfInt
}
static NativeInt32List _createLength(int arg) => JS(
'returns:NativeInt32List;effects:none;depends:none;new:true',
'new Int32Array(#)',
arg);
'returns:NativeInt32List;effects:none;depends:none;new:true',
'new Int32Array(#)',
arg,
);
static NativeInt32List _create1(arg) =>
JS('NativeInt32List', 'new Int32Array(#)', arg);
@@ -1136,7 +1190,10 @@ final class NativeInt8List extends NativeTypedArrayOfInt
_create1(_ensureNativeList(elements));
factory NativeInt8List.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
return length == null
? _create2(buffer, offsetInBytes)
@@ -1152,8 +1209,10 @@ final class NativeInt8List extends NativeTypedArrayOfInt
Int8List asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeInt8List sublist(int start, [int? end]) {
@@ -1163,9 +1222,10 @@ final class NativeInt8List extends NativeTypedArrayOfInt
}
static NativeInt8List _createLength(int arg) => JS(
'returns:NativeInt8List;effects:none;depends:none;new:true',
'new Int8Array(#)',
arg);
'returns:NativeInt8List;effects:none;depends:none;new:true',
'new Int8Array(#)',
arg,
);
static NativeInt8List _create1(arg) =>
JS('NativeInt8List', 'new Int8Array(#)', arg);
@@ -1186,7 +1246,10 @@ final class NativeUint16List extends NativeTypedArrayOfInt
_create1(_ensureNativeList(list));
factory NativeUint16List.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
length ??=
(buffer.lengthInBytes - offsetInBytes) ~/ Uint16List.bytesPerElement;
@@ -1202,8 +1265,10 @@ final class NativeUint16List extends NativeTypedArrayOfInt
Uint16List asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeUint16List sublist(int start, [int? end]) {
@@ -1213,9 +1278,10 @@ final class NativeUint16List extends NativeTypedArrayOfInt
}
static NativeUint16List _createLength(int arg) => JS(
'returns:NativeUint16List;effects:none;depends:none;new:true',
'new Uint16Array(#)',
arg);
'returns:NativeUint16List;effects:none;depends:none;new:true',
'new Uint16Array(#)',
arg,
);
static NativeUint16List _create1(arg) =>
JS('NativeUint16List', 'new Uint16Array(#)', arg);
@@ -1233,7 +1299,10 @@ final class NativeUint32List extends NativeTypedArrayOfInt
_create1(_ensureNativeList(elements));
factory NativeUint32List.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
length ??=
(buffer.lengthInBytes - offsetInBytes) ~/ Uint32List.bytesPerElement;
@@ -1249,8 +1318,10 @@ final class NativeUint32List extends NativeTypedArrayOfInt
Uint32List asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeUint32List sublist(int start, [int? end]) {
@@ -1260,9 +1331,10 @@ final class NativeUint32List extends NativeTypedArrayOfInt
}
static NativeUint32List _createLength(int arg) => JS(
'returns:NativeUint32List;effects:none;depends:none;new:true',
'new Uint32Array(#)',
arg);
'returns:NativeUint32List;effects:none;depends:none;new:true',
'new Uint32Array(#)',
arg,
);
static NativeUint32List _create1(arg) =>
JS('NativeUint32List', 'new Uint32Array(#)', arg);
@@ -1281,7 +1353,10 @@ final class NativeUint8ClampedList extends NativeTypedArrayOfInt
_create1(_ensureNativeList(elements));
factory NativeUint8ClampedList.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
return length == null
? _create2(buffer, offsetInBytes)
@@ -1299,21 +1374,29 @@ final class NativeUint8ClampedList extends NativeTypedArrayOfInt
Uint8ClampedList asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeUint8ClampedList sublist(int start, [int? end]) {
var stop = _checkValidRange(start, end, this.length);
var source =
JS('NativeUint8ClampedList', '#.subarray(#, #)', this, start, stop);
var source = JS(
'NativeUint8ClampedList',
'#.subarray(#, #)',
this,
start,
stop,
);
return _create1(source);
}
static NativeUint8ClampedList _createLength(int arg) => JS(
'returns:NativeUint8ClampedList;effects:none;depends:none;new:true',
'new Uint8ClampedArray(#)',
arg);
'returns:NativeUint8ClampedList;effects:none;depends:none;new:true',
'new Uint8ClampedArray(#)',
arg,
);
static NativeUint8ClampedList _create1(arg) =>
JS('NativeUint8ClampedList', 'new Uint8ClampedArray(#)', arg);
@@ -1322,11 +1405,12 @@ final class NativeUint8ClampedList extends NativeTypedArrayOfInt
JS('NativeUint8ClampedList', 'new Uint8ClampedArray(#, #)', arg1, arg2);
static NativeUint8ClampedList _create3(arg1, arg2, arg3) => JS(
'NativeUint8ClampedList',
'new Uint8ClampedArray(#, #, #)',
arg1,
arg2,
arg3);
'NativeUint8ClampedList',
'new Uint8ClampedArray(#, #, #)',
arg1,
arg2,
arg3,
);
}
// On some browsers Uint8ClampedArray is a subtype of Uint8Array. Marking
@@ -1342,7 +1426,10 @@ final class NativeUint8List extends NativeTypedArrayOfInt
_create1(_ensureNativeList(elements));
factory NativeUint8List.view(
ByteBuffer buffer, int offsetInBytes, int? length) {
ByteBuffer buffer,
int offsetInBytes,
int? length,
) {
_checkViewArguments(buffer, offsetInBytes, length);
return length == null
? _create2(buffer, offsetInBytes)
@@ -1360,8 +1447,10 @@ final class NativeUint8List extends NativeTypedArrayOfInt
Uint8List asUnmodifiableView() {
if (_isUnmodifiable()) return this;
return HArrayFlagsSet(_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable);
return HArrayFlagsSet(
_create3(_nativeBuffer, offsetInBytes, length),
ArrayFlags.unmodifiable,
);
}
NativeUint8List sublist(int start, [int? end]) {
@@ -1371,9 +1460,10 @@ final class NativeUint8List extends NativeTypedArrayOfInt
}
static NativeUint8List _createLength(int arg) => JS(
'returns:NativeUint8List;effects:none;depends:none;new:true',
'new Uint8Array(#)',
arg);
'returns:NativeUint8List;effects:none;depends:none;new:true',
'new Uint8Array(#)',
arg,
);
static NativeUint8List _create1(arg) =>
JS('NativeUint8List', 'new Uint8Array(#)', arg);
@@ -1403,10 +1493,10 @@ final class NativeFloat32x4 implements Float32x4 {
}
NativeFloat32x4(double x, double y, double z, double w)
: this.x = _truncate(x),
this.y = _truncate(y),
this.z = _truncate(z),
this.w = _truncate(w) {
: this.x = _truncate(x),
this.y = _truncate(y),
this.z = _truncate(z),
this.w = _truncate(w) {
// We would prefer to check for `double` but in dart2js we can't see the
// difference anyway.
if (x is! num) throw ArgumentError(x);
@@ -1415,29 +1505,29 @@ final class NativeFloat32x4 implements Float32x4 {
if (w is! num) throw ArgumentError(w);
}
NativeFloat32x4.splat(double v) : this(v, v, v, v);
NativeFloat32x4.splat(double value) : this(value, value, value, value);
NativeFloat32x4.zero() : this._truncated(0.0, 0.0, 0.0, 0.0);
/// Returns a bit-wise copy of [i] as a Float32x4.
factory NativeFloat32x4.fromInt32x4Bits(Int32x4 i) {
_uint32view[0] = i.x;
_uint32view[1] = i.y;
_uint32view[2] = i.z;
_uint32view[3] = i.w;
/// Returns a bit-wise copy of [bits] as a Float32x4.
factory NativeFloat32x4.fromInt32x4Bits(Int32x4 bits) {
_uint32view[0] = bits.x;
_uint32view[1] = bits.y;
_uint32view[2] = bits.z;
_uint32view[3] = bits.w;
return NativeFloat32x4._truncated(_list[0], _list[1], _list[2], _list[3]);
}
NativeFloat32x4.fromFloat64x2(Float64x2 v)
: this._truncated(_truncate(v.x), _truncate(v.y), 0.0, 0.0);
NativeFloat32x4.fromFloat64x2(Float64x2 xy)
: this._truncated(_truncate(xy.x), _truncate(xy.y), 0.0, 0.0);
/// Creates a new NativeFloat32x4.
///
/// Does not verify if the given arguments are non-null.
NativeFloat32x4._doubles(double x, double y, double z, double w)
: this.x = _truncate(x),
this.y = _truncate(y),
this.z = _truncate(z),
this.w = _truncate(w);
: this.x = _truncate(x),
this.y = _truncate(y),
this.z = _truncate(z),
this.w = _truncate(w);
/// Creates a new NativeFloat32x4.
///
@@ -1498,7 +1588,11 @@ final class NativeFloat32x4 implements Float32x4 {
bool _cz = z < other.z;
bool _cw = w < other.w;
return NativeInt32x4._truncated(
_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0);
_cx ? -1 : 0,
_cy ? -1 : 0,
_cz ? -1 : 0,
_cw ? -1 : 0,
);
}
/// Relational less than or equal.
@@ -1508,7 +1602,11 @@ final class NativeFloat32x4 implements Float32x4 {
bool _cz = z <= other.z;
bool _cw = w <= other.w;
return NativeInt32x4._truncated(
_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0);
_cx ? -1 : 0,
_cy ? -1 : 0,
_cz ? -1 : 0,
_cw ? -1 : 0,
);
}
/// Relational greater than.
@@ -1518,7 +1616,11 @@ final class NativeFloat32x4 implements Float32x4 {
bool _cz = z > other.z;
bool _cw = w > other.w;
return NativeInt32x4._truncated(
_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0);
_cx ? -1 : 0,
_cy ? -1 : 0,
_cz ? -1 : 0,
_cw ? -1 : 0,
);
}
/// Relational greater than or equal.
@@ -1528,7 +1630,11 @@ final class NativeFloat32x4 implements Float32x4 {
bool _cz = z >= other.z;
bool _cw = w >= other.w;
return NativeInt32x4._truncated(
_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0);
_cx ? -1 : 0,
_cy ? -1 : 0,
_cz ? -1 : 0,
_cw ? -1 : 0,
);
}
/// Relational equal.
@@ -1538,7 +1644,11 @@ final class NativeFloat32x4 implements Float32x4 {
bool _cz = z == other.z;
bool _cw = w == other.w;
return NativeInt32x4._truncated(
_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0);
_cx ? -1 : 0,
_cy ? -1 : 0,
_cz ? -1 : 0,
_cw ? -1 : 0,
);
}
/// Relational not-equal.
@@ -1548,15 +1658,19 @@ final class NativeFloat32x4 implements Float32x4 {
bool _cz = z != other.z;
bool _cw = w != other.w;
return NativeInt32x4._truncated(
_cx ? -1 : 0, _cy ? -1 : 0, _cz ? -1 : 0, _cw ? -1 : 0);
_cx ? -1 : 0,
_cy ? -1 : 0,
_cz ? -1 : 0,
_cw ? -1 : 0,
);
}
/// Returns a copy of this [Float32x4] each lane being scaled by [s].
Float32x4 scale(double s) {
double _x = s * x;
double _y = s * y;
double _z = s * z;
double _w = s * w;
Float32x4 scale(double scale) {
double _x = scale * x;
double _y = scale * y;
double _z = scale * z;
double _w = scale * w;
return NativeFloat32x4._doubles(_x, _y, _z, _w);
}
@@ -1738,10 +1852,10 @@ final class NativeInt32x4 implements Int32x4 {
}
NativeInt32x4(int x, int y, int z, int w)
: this.x = _truncate(x),
this.y = _truncate(y),
this.z = _truncate(z),
this.w = _truncate(w) {
: this.x = _truncate(x),
this.y = _truncate(y),
this.z = _truncate(z),
this.w = _truncate(w) {
if (x != this.x && x is! int) throw ArgumentError(x);
if (y != this.y && y is! int) throw ArgumentError(y);
if (z != this.z && z is! int) throw ArgumentError(z);
@@ -1749,10 +1863,10 @@ final class NativeInt32x4 implements Int32x4 {
}
NativeInt32x4.bool(bool x, bool y, bool z, bool w)
: this.x = x ? -1 : 0,
this.y = y ? -1 : 0,
this.z = z ? -1 : 0,
this.w = w ? -1 : 0;
: this.x = x ? -1 : 0,
this.y = y ? -1 : 0,
this.z = z ? -1 : 0,
this.w = w ? -1 : 0;
/// Returns a bit-wise copy of [f] as a Int32x4.
factory NativeInt32x4.fromFloat32x4Bits(Float32x4 f) {
@@ -1774,10 +1888,11 @@ final class NativeInt32x4 implements Int32x4 {
// Dart2js uses unsigned results for bit-operations.
// We use "JS" to fall back to the signed versions.
return NativeInt32x4._truncated(
JS('int', '# | #', x, other.x),
JS('int', '# | #', y, other.y),
JS('int', '# | #', z, other.z),
JS('int', '# | #', w, other.w));
JS('int', '# | #', x, other.x),
JS('int', '# | #', y, other.y),
JS('int', '# | #', z, other.z),
JS('int', '# | #', w, other.w),
);
}
/// The bit-wise and operator.
@@ -1785,10 +1900,11 @@ final class NativeInt32x4 implements Int32x4 {
// Dart2js uses unsigned results for bit-operations.
// We use "JS" to fall back to the signed versions.
return NativeInt32x4._truncated(
JS('int', '# & #', x, other.x),
JS('int', '# & #', y, other.y),
JS('int', '# & #', z, other.z),
JS('int', '# & #', w, other.w));
JS('int', '# & #', x, other.x),
JS('int', '# & #', y, other.y),
JS('int', '# & #', z, other.z),
JS('int', '# & #', w, other.w),
);
}
/// The bit-wise xor operator.
@@ -1796,37 +1912,41 @@ final class NativeInt32x4 implements Int32x4 {
// Dart2js uses unsigned results for bit-operations.
// We use "JS" to fall back to the signed versions.
return NativeInt32x4._truncated(
JS('int', '# ^ #', x, other.x),
JS('int', '# ^ #', y, other.y),
JS('int', '# ^ #', z, other.z),
JS('int', '# ^ #', w, other.w));
JS('int', '# ^ #', x, other.x),
JS('int', '# ^ #', y, other.y),
JS('int', '# ^ #', z, other.z),
JS('int', '# ^ #', w, other.w),
);
}
Int32x4 operator +(Int32x4 other) {
// Avoid going through the typed array by "| 0" the result.
return NativeInt32x4._truncated(
JS('int', '(# + #) | 0', x, other.x),
JS('int', '(# + #) | 0', y, other.y),
JS('int', '(# + #) | 0', z, other.z),
JS('int', '(# + #) | 0', w, other.w));
JS('int', '(# + #) | 0', x, other.x),
JS('int', '(# + #) | 0', y, other.y),
JS('int', '(# + #) | 0', z, other.z),
JS('int', '(# + #) | 0', w, other.w),
);
}
Int32x4 operator -(Int32x4 other) {
// Avoid going through the typed array by "| 0" the result.
return NativeInt32x4._truncated(
JS('int', '(# - #) | 0', x, other.x),
JS('int', '(# - #) | 0', y, other.y),
JS('int', '(# - #) | 0', z, other.z),
JS('int', '(# - #) | 0', w, other.w));
JS('int', '(# - #) | 0', x, other.x),
JS('int', '(# - #) | 0', y, other.y),
JS('int', '(# - #) | 0', z, other.z),
JS('int', '(# - #) | 0', w, other.w),
);
}
Int32x4 operator -() {
// Avoid going through the typed array by "| 0" the result.
return NativeInt32x4._truncated(
JS('int', '(-#) | 0', x),
JS('int', '(-#) | 0', y),
JS('int', '(-#) | 0', z),
JS('int', '(-#) | 0', w));
JS('int', '(-#) | 0', x),
JS('int', '(-#) | 0', y),
JS('int', '(-#) | 0', z),
JS('int', '(-#) | 0', w),
);
}
/// Extract the top bit from each lane return them in the first 4 bits.
@@ -1970,7 +2090,11 @@ final class NativeInt32x4 implements Int32x4 {
intView[2] = _z;
intView[3] = _w;
return NativeFloat32x4._truncated(
floatList[0], floatList[1], floatList[2], floatList[3]);
floatList[0],
floatList[1],
floatList[2],
floatList[3],
);
}
}
@@ -2075,13 +2199,17 @@ final class NativeFloat64x2 implements Float64x2 {
/// Returns the lane-wise minimum value in this [Float64x2] or [other].
Float64x2 min(Float64x2 other) {
return NativeFloat64x2._doubles(
x < other.x ? x : other.x, y < other.y ? y : other.y);
x < other.x ? x : other.x,
y < other.y ? y : other.y,
);
}
/// Returns the lane-wise maximum value in this [Float64x2] or [other].
Float64x2 max(Float64x2 other) {
return NativeFloat64x2._doubles(
x > other.x ? x : other.x, y > other.y ? y : other.y);
x > other.x ? x : other.x,
y > other.y ? y : other.y,
);
}
/// Returns the lane-wise square root of this [Float64x2].
@@ -157,14 +157,14 @@ class Float32x4 {
@patch
factory Float32x4(double x, double y, double z, double w) = NativeFloat32x4;
@patch
factory Float32x4.splat(double v) = NativeFloat32x4.splat;
factory Float32x4.splat(double value) = NativeFloat32x4.splat;
@patch
factory Float32x4.zero() = NativeFloat32x4.zero;
@patch
factory Float32x4.fromInt32x4Bits(Int32x4 x) =
factory Float32x4.fromInt32x4Bits(Int32x4 bits) =
NativeFloat32x4.fromInt32x4Bits;
@patch
factory Float32x4.fromFloat64x2(Float64x2 v) = NativeFloat32x4.fromFloat64x2;
factory Float32x4.fromFloat64x2(Float64x2 xy) = NativeFloat32x4.fromFloat64x2;
}
@patch
+3 -42
View File
@@ -3777,10 +3777,6 @@ class Float32x4 {
@patch
@pragma("vm:prefer-inline")
factory Float32x4(double x, double y, double z, double w) {
_throwIfNull(x, 'x');
_throwIfNull(y, 'y');
_throwIfNull(z, 'z');
_throwIfNull(w, 'w');
return _Float32x4FromDoubles(x, y, z, w);
}
@@ -3796,10 +3792,7 @@ class Float32x4 {
@patch
@pragma("vm:prefer-inline")
factory Float32x4.splat(double v) {
_throwIfNull(v, 'v');
return _Float32x4Splat(v);
}
factory Float32x4.splat(double value) => _Float32x4Splat(value);
@pragma("vm:recognized", "other")
@pragma("vm:exact-result-type", _Float32x4)
@@ -3822,7 +3815,7 @@ class Float32x4 {
@pragma("vm:recognized", "other")
@pragma("vm:exact-result-type", _Float32x4)
@pragma("vm:external-name", "Float32x4_fromFloat64x2")
external factory Float32x4.fromFloat64x2(Float64x2 v);
external factory Float32x4.fromFloat64x2(Float64x2 xy);
}
@pragma('vm:deeply-immutable')
@@ -3874,7 +3867,7 @@ final class _Float32x4 implements Float32x4 {
@pragma("vm:recognized", "other")
@pragma("vm:exact-result-type", _Float32x4)
@pragma("vm:external-name", "Float32x4_scale")
external Float32x4 scale(double s);
external Float32x4 scale(double scale);
@pragma("vm:recognized", "other")
@pragma("vm:exact-result-type", _Float32x4)
@pragma("vm:external-name", "Float32x4_abs")
@@ -3914,7 +3907,6 @@ final class _Float32x4 implements Float32x4 {
@pragma("vm:prefer-inline")
Float32x4 withX(double x) {
_throwIfNull(x, 'x');
return _withX(x);
}
@@ -3925,7 +3917,6 @@ final class _Float32x4 implements Float32x4 {
@pragma("vm:prefer-inline")
Float32x4 withY(double y) {
_throwIfNull(y, 'y');
return _withY(y);
}
@@ -3936,7 +3927,6 @@ final class _Float32x4 implements Float32x4 {
@pragma("vm:prefer-inline")
Float32x4 withZ(double z) {
_throwIfNull(z, 'z');
return _withZ(z);
}
@@ -3947,7 +3937,6 @@ final class _Float32x4 implements Float32x4 {
@pragma("vm:prefer-inline")
Float32x4 withW(double w) {
_throwIfNull(w, 'w');
return _withW(w);
}
@@ -3984,10 +3973,6 @@ class Int32x4 {
@patch
@pragma("vm:prefer-inline")
factory Int32x4(int x, int y, int z, int w) {
_throwIfNull(x, 'x');
_throwIfNull(y, 'y');
_throwIfNull(z, 'z');
_throwIfNull(w, 'w');
return _Int32x4FromInts(x, y, z, w);
}
@@ -3999,10 +3984,6 @@ class Int32x4 {
@patch
@pragma("vm:prefer-inline")
factory Int32x4.bool(bool x, bool y, bool z, bool w) {
_throwIfNull(x, 'x');
_throwIfNull(y, 'y');
_throwIfNull(z, 'z');
_throwIfNull(w, 'w');
return _Int32x4FromBools(x, y, z, w);
}
@@ -4053,7 +4034,6 @@ final class _Int32x4 implements Int32x4 {
@pragma("vm:prefer-inline")
Int32x4 withX(int x) {
_throwIfNull(x, 'x');
return _withX(x);
}
@@ -4063,7 +4043,6 @@ final class _Int32x4 implements Int32x4 {
@pragma("vm:prefer-inline")
Int32x4 withY(int y) {
_throwIfNull(y, 'y');
return _withY(y);
}
@@ -4073,7 +4052,6 @@ final class _Int32x4 implements Int32x4 {
@pragma("vm:prefer-inline")
Int32x4 withZ(int z) {
_throwIfNull(z, 'z');
return _withZ(z);
}
@@ -4083,7 +4061,6 @@ final class _Int32x4 implements Int32x4 {
@pragma("vm:prefer-inline")
Int32x4 withW(int w) {
_throwIfNull(w, 'w');
return _withW(w);
}
@@ -4110,7 +4087,6 @@ final class _Int32x4 implements Int32x4 {
@pragma("vm:prefer-inline", _Int32x4)
Int32x4 withFlagX(bool x) {
_throwIfNull(x, 'x');
return _withFlagX(x);
}
@@ -4121,7 +4097,6 @@ final class _Int32x4 implements Int32x4 {
@pragma("vm:prefer-inline", _Int32x4)
Int32x4 withFlagY(bool y) {
_throwIfNull(y, 'y');
return _withFlagY(y);
}
@@ -4132,7 +4107,6 @@ final class _Int32x4 implements Int32x4 {
@pragma("vm:prefer-inline", _Int32x4)
Int32x4 withFlagZ(bool z) {
_throwIfNull(z, 'z');
return _withFlagZ(z);
}
@@ -4143,7 +4117,6 @@ final class _Int32x4 implements Int32x4 {
@pragma("vm:prefer-inline", _Int32x4)
Int32x4 withFlagW(bool w) {
_throwIfNull(w, 'w');
return _withFlagW(w);
}
@@ -4164,8 +4137,6 @@ class Float64x2 {
@patch
@pragma("vm:prefer-inline")
factory Float64x2(double x, double y) {
_throwIfNull(x, 'x');
_throwIfNull(y, 'y');
return _Float64x2FromDoubles(x, y);
}
@@ -4177,7 +4148,6 @@ class Float64x2 {
@patch
@pragma("vm:prefer-inline")
factory Float64x2.splat(double v) {
_throwIfNull(v, 'v');
return _Float64x2Splat(v);
}
@@ -4244,7 +4214,6 @@ final class _Float64x2 implements Float64x2 {
@pragma("vm:prefer-inline")
Float64x2 withX(double x) {
_throwIfNull(x, 'x');
return _withX(x);
}
@@ -4255,7 +4224,6 @@ final class _Float64x2 implements Float64x2 {
@pragma("vm:prefer-inline")
Float64x2 withY(double y) {
_throwIfNull(y, 'y');
return _withY(y);
}
@@ -5435,13 +5403,6 @@ int _toClampedUint8(int value) {
return value;
}
@pragma("vm:prefer-inline")
void _throwIfNull(val, String name) {
if (val == null) {
throw ArgumentError.notNull(name);
}
}
// Length should be non-negative.
@pragma("vm:recognized", "other")
@pragma("vm:prefer-inline")
+13 -13
View File
@@ -343,19 +343,19 @@ final class NaiveFloat32x4 extends WasmTypedDataBase implements Float32x4 {
this.z = _truncate(z),
this.w = _truncate(w);
NaiveFloat32x4.splat(double v) : this(v, v, v, v);
NaiveFloat32x4.splat(double value) : this(value, value, value, value);
NaiveFloat32x4.zero() : this._truncated(0.0, 0.0, 0.0, 0.0);
factory NaiveFloat32x4.fromInt32x4Bits(Int32x4 i) {
_uint32view[0] = i.x;
_uint32view[1] = i.y;
_uint32view[2] = i.z;
_uint32view[3] = i.w;
factory NaiveFloat32x4.fromInt32x4Bits(Int32x4 bits) {
_uint32view[0] = bits.x;
_uint32view[1] = bits.y;
_uint32view[2] = bits.z;
_uint32view[3] = bits.w;
return NaiveFloat32x4._truncated(_list[0], _list[1], _list[2], _list[3]);
}
NaiveFloat32x4.fromFloat64x2(Float64x2 v)
: this._truncated(_truncate(v.x), _truncate(v.y), 0.0, 0.0);
NaiveFloat32x4.fromFloat64x2(Float64x2 xy)
: this._truncated(_truncate(xy.x), _truncate(xy.y), 0.0, 0.0);
NaiveFloat32x4._doubles(double x, double y, double z, double w)
: this.x = _truncate(x),
@@ -487,11 +487,11 @@ final class NaiveFloat32x4 extends WasmTypedDataBase implements Float32x4 {
);
}
Float32x4 scale(double s) {
double _x = s * x;
double _y = s * y;
double _z = s * z;
double _w = s * w;
Float32x4 scale(double scale) {
double _x = scale * x;
double _y = scale * y;
double _z = scale * z;
double _w = scale * w;
return NaiveFloat32x4._doubles(_x, _y, _z, _w);
}
+4 -3
View File
@@ -28,16 +28,17 @@ class Float32x4 {
factory Float32x4(double x, double y, double z, double w) = NaiveFloat32x4;
@patch
factory Float32x4.splat(double v) = NaiveFloat32x4.splat;
factory Float32x4.splat(double value) = NaiveFloat32x4.splat;
@patch
factory Float32x4.zero() = NaiveFloat32x4.zero;
@patch
factory Float32x4.fromInt32x4Bits(Int32x4 x) = NaiveFloat32x4.fromInt32x4Bits;
factory Float32x4.fromInt32x4Bits(Int32x4 bits) =
NaiveFloat32x4.fromInt32x4Bits;
@patch
factory Float32x4.fromFloat64x2(Float64x2 v) = NaiveFloat32x4.fromFloat64x2;
factory Float32x4.fromFloat64x2(Float64x2 xy) = NaiveFloat32x4.fromFloat64x2;
}
@patch
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+88
View File
@@ -81,9 +81,97 @@ void testBigArguments() {
}
}
// TODO: Maybe move to `int32x4_arithmetic_test.dart`.
void testBitOperators() {
var m = Int32x4(0xAAAAAAA, 0xAAAAAAA, 0xAAAAAAA, 0xAAAAAAA);
var n = Int32x4(0x5555555, 0x5555555, 0x5555555, 0x5555555);
Expect.equals(0xAAAAAAA, m.x);
Expect.equals(0xAAAAAAA, m.y);
Expect.equals(0xAAAAAAA, m.z);
Expect.equals(0xAAAAAAA, m.w);
Expect.equals(0x5555555, n.x);
Expect.equals(0x5555555, n.y);
Expect.equals(0x5555555, n.z);
Expect.equals(0x5555555, n.w);
Expect.equals(true, n.flagX);
Expect.equals(true, n.flagY);
Expect.equals(true, n.flagZ);
Expect.equals(true, n.flagW);
var o = m | n; // or
Expect.equals(0xFFFFFFF, o.x);
Expect.equals(0xFFFFFFF, o.y);
Expect.equals(0xFFFFFFF, o.z);
Expect.equals(0xFFFFFFF, o.w);
Expect.equals(true, o.flagX);
Expect.equals(true, o.flagY);
Expect.equals(true, o.flagZ);
Expect.equals(true, o.flagW);
o = m & n; // and
Expect.equals(0x0, o.x);
Expect.equals(0x0, o.y);
Expect.equals(0x0, o.z);
Expect.equals(0x0, o.w);
n = n.withX(0xAAAAAAA);
n = n.withY(0xAAAAAAA);
n = n.withZ(0xAAAAAAA);
n = n.withW(0xAAAAAAA);
Expect.equals(0xAAAAAAA, n.x);
Expect.equals(0xAAAAAAA, n.y);
Expect.equals(0xAAAAAAA, n.z);
Expect.equals(0xAAAAAAA, n.w);
o = m ^ n; // xor
Expect.equals(0x0, o.x);
Expect.equals(0x0, o.y);
Expect.equals(0x0, o.z);
Expect.equals(0x0, o.w);
Expect.equals(false, o.flagX);
Expect.equals(false, o.flagY);
Expect.equals(false, o.flagZ);
Expect.equals(false, o.flagW);
}
void testSetters() {
var m = Int32x4.bool(false, false, false, false);
Expect.equals(false, m.flagX);
Expect.equals(false, m.flagY);
Expect.equals(false, m.flagZ);
Expect.equals(false, m.flagW);
m = m.withFlagX(true);
Expect.equals(true, m.flagX);
Expect.equals(false, m.flagY);
Expect.equals(false, m.flagZ);
Expect.equals(false, m.flagW);
m = m.withFlagY(true);
Expect.equals(true, m.flagX);
Expect.equals(true, m.flagY);
Expect.equals(false, m.flagZ);
Expect.equals(false, m.flagW);
m = m.withFlagZ(true);
Expect.equals(true, m.flagX);
Expect.equals(true, m.flagY);
Expect.equals(true, m.flagZ);
Expect.equals(false, m.flagW);
m = m.withFlagW(true);
Expect.equals(true, m.flagX);
Expect.equals(true, m.flagY);
Expect.equals(true, m.flagZ);
Expect.equals(true, m.flagW);
}
void testGetters() {
var m = Int32x4.bool(false, true, true, false);
Expect.equals(false, m.flagX);
Expect.equals(true, m.flagY);
Expect.equals(true, m.flagZ);
Expect.equals(false, m.flagW);
}
main() {
for (int i = 0; i < 20; i++) {
testBigArguments();
testBadArguments();
testBitOperators();
testSetters();
testGetters();
}
}