Skip to content

Commit 13df952

Browse files
lrhnCommit Queue
authored andcommitted
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 <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
1 parent b9b7705 commit 13df952

File tree

10 files changed

+2297
-659
lines changed

10 files changed

+2297
-659
lines changed

sdk/lib/_internal/js_dev_runtime/patch/typed_data_patch.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ class Float32x4 {
156156
@patch
157157
factory Float32x4(double x, double y, double z, double w) = NativeFloat32x4;
158158
@patch
159-
factory Float32x4.splat(double v) = NativeFloat32x4.splat;
159+
factory Float32x4.splat(double value) = NativeFloat32x4.splat;
160160
@patch
161161
factory Float32x4.zero() = NativeFloat32x4.zero;
162162
@patch
163-
factory Float32x4.fromInt32x4Bits(Int32x4 x) =
163+
factory Float32x4.fromInt32x4Bits(Int32x4 bits) =
164164
NativeFloat32x4.fromInt32x4Bits;
165165
@patch
166-
factory Float32x4.fromFloat64x2(Float64x2 v) = NativeFloat32x4.fromFloat64x2;
166+
factory Float32x4.fromFloat64x2(Float64x2 xy) = NativeFloat32x4.fromFloat64x2;
167167
}
168168

169169
@patch

sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,20 +1219,20 @@ final class NativeFloat32x4 implements Float32x4 {
12191219
if (w is! num) throw ArgumentError(w);
12201220
}
12211221

1222-
NativeFloat32x4.splat(double v) : this(v, v, v, v);
1222+
NativeFloat32x4.splat(double value) : this(value, value, value, value);
12231223
NativeFloat32x4.zero() : this._truncated(0.0, 0.0, 0.0, 0.0);
12241224

1225-
/// Returns a bit-wise copy of [i] as a Float32x4.
1226-
factory NativeFloat32x4.fromInt32x4Bits(Int32x4 i) {
1227-
_uint32view[0] = i.x;
1228-
_uint32view[1] = i.y;
1229-
_uint32view[2] = i.z;
1230-
_uint32view[3] = i.w;
1225+
/// Returns a bit-wise copy of [bits] as a Float32x4.
1226+
factory NativeFloat32x4.fromInt32x4Bits(Int32x4 bits) {
1227+
_uint32view[0] = bits.x;
1228+
_uint32view[1] = bits.y;
1229+
_uint32view[2] = bits.z;
1230+
_uint32view[3] = bits.w;
12311231
return NativeFloat32x4._truncated(_list[0], _list[1], _list[2], _list[3]);
12321232
}
12331233

1234-
NativeFloat32x4.fromFloat64x2(Float64x2 v)
1235-
: this._truncated(_truncate(v.x), _truncate(v.y), 0.0, 0.0);
1234+
NativeFloat32x4.fromFloat64x2(Float64x2 xy)
1235+
: this._truncated(_truncate(xy.x), _truncate(xy.y), 0.0, 0.0);
12361236

12371237
/// Creates a new NativeFloat32x4.
12381238
///
@@ -1380,11 +1380,11 @@ final class NativeFloat32x4 implements Float32x4 {
13801380
}
13811381

13821382
/// Returns a copy of this [Float32x4] each lane being scaled by [s].
1383-
Float32x4 scale(double s) {
1384-
double _x = s * x;
1385-
double _y = s * y;
1386-
double _z = s * z;
1387-
double _w = s * w;
1383+
Float32x4 scale(double scale) {
1384+
double _x = scale * x;
1385+
double _y = scale * y;
1386+
double _z = scale * z;
1387+
double _w = scale * w;
13881388
return NativeFloat32x4._doubles(_x, _y, _z, _w);
13891389
}
13901390

0 commit comments

Comments
 (0)