Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Commit 89eea8d

Browse files
committed
Clarify comments and code.
More firmly establish the convention of converting from boolean to integer.
1 parent 2782a23 commit 89eea8d

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/ecmascript_simd.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,19 @@ SIMD.int32x4 = function(x, y, z, w) {
263263
}
264264

265265
/**
266-
* Construct a new instance of int32x4 number with 0xFFFFFFFF or 0x0 in each
267-
* lane, depending on the truth value in x, y, z, and w.
266+
* Construct a new instance of int32x4 number with either true or false in each
267+
* lane, depending on the truth values in x, y, z, and w.
268268
* @param {boolean} flag used for x lane.
269269
* @param {boolean} flag used for y lane.
270270
* @param {boolean} flag used for z lane.
271271
* @param {boolean} flag used for w lane.
272272
* @constructor
273273
*/
274274
SIMD.int32x4.bool = function(x, y, z, w) {
275-
return SIMD.int32x4(x ? -1 : 0x0,
276-
y ? -1 : 0x0,
277-
z ? -1 : 0x0,
278-
w ? -1 : 0x0);
275+
return SIMD.int32x4(_PRIVATE.frombool(x),
276+
_PRIVATE.frombool(y),
277+
_PRIVATE.frombool(z),
278+
_PRIVATE.frombool(w));
279279
}
280280

281281
/**
@@ -579,7 +579,7 @@ SIMD.float32x4.withW = function(t, w) {
579579
/**
580580
* @param {float32x4} t An instance of float32x4.
581581
* @param {float32x4} other An instance of float32x4.
582-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
582+
* @return {int32x4} true or false in each lane depending on
583583
* the result of t < other.
584584
*/
585585
SIMD.float32x4.lessThan = function(t, other) {
@@ -595,7 +595,7 @@ SIMD.float32x4.lessThan = function(t, other) {
595595
/**
596596
* @param {float32x4} t An instance of float32x4.
597597
* @param {float32x4} other An instance of float32x4.
598-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
598+
* @return {int32x4} true or false in each lane depending on
599599
* the result of t <= other.
600600
*/
601601
SIMD.float32x4.lessThanOrEqual = function(t, other) {
@@ -611,7 +611,7 @@ SIMD.float32x4.lessThanOrEqual = function(t, other) {
611611
/**
612612
* @param {float32x4} t An instance of float32x4.
613613
* @param {float32x4} other An instance of float32x4.
614-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
614+
* @return {int32x4} true or false in each lane depending on
615615
* the result of t == other.
616616
*/
617617
SIMD.float32x4.equal = function(t, other) {
@@ -627,7 +627,7 @@ SIMD.float32x4.equal = function(t, other) {
627627
/**
628628
* @param {float32x4} t An instance of float32x4.
629629
* @param {float32x4} other An instance of float32x4.
630-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
630+
* @return {int32x4} true or false in each lane depending on
631631
* the result of t != other.
632632
*/
633633
SIMD.float32x4.notEqual = function(t, other) {
@@ -643,7 +643,7 @@ SIMD.float32x4.notEqual = function(t, other) {
643643
/**
644644
* @param {float32x4} t An instance of float32x4.
645645
* @param {float32x4} other An instance of float32x4.
646-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
646+
* @return {int32x4} true or false in each lane depending on
647647
* the result of t >= other.
648648
*/
649649
SIMD.float32x4.greaterThanOrEqual = function(t, other) {
@@ -659,7 +659,7 @@ SIMD.float32x4.greaterThanOrEqual = function(t, other) {
659659
/**
660660
* @param {float32x4} t An instance of float32x4.
661661
* @param {float32x4} other An instance of float32x4.
662-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
662+
* @return {int32x4} true or false in each lane depending on
663663
* the result of t > other.
664664
*/
665665
SIMD.float32x4.greaterThan = function(t, other) {
@@ -1156,7 +1156,7 @@ SIMD.float64x2.withY = function(t, y) {
11561156
/**
11571157
* @param {float64x2} t An instance of float64x2.
11581158
* @param {float64x2} other An instance of float64x2.
1159-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1159+
* @return {int32x4} true or false in each lane depending on
11601160
* the result of t < other.
11611161
*/
11621162
SIMD.float64x2.lessThan = function(t, other) {
@@ -1170,7 +1170,7 @@ SIMD.float64x2.lessThan = function(t, other) {
11701170
/**
11711171
* @param {float64x2} t An instance of float64x2.
11721172
* @param {float64x2} other An instance of float64x2.
1173-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1173+
* @return {int32x4} true or false in each lane depending on
11741174
* the result of t <= other.
11751175
*/
11761176
SIMD.float64x2.lessThanOrEqual = function(t, other) {
@@ -1184,7 +1184,7 @@ SIMD.float64x2.lessThanOrEqual = function(t, other) {
11841184
/**
11851185
* @param {float64x2} t An instance of float64x2.
11861186
* @param {float64x2} other An instance of float64x2.
1187-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1187+
* @return {int32x4} true or false in each lane depending on
11881188
* the result of t == other.
11891189
*/
11901190
SIMD.float64x2.equal = function(t, other) {
@@ -1198,7 +1198,7 @@ SIMD.float64x2.equal = function(t, other) {
11981198
/**
11991199
* @param {float64x2} t An instance of float64x2.
12001200
* @param {float64x2} other An instance of float64x2.
1201-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1201+
* @return {int32x4} true or false in each lane depending on
12021202
* the result of t != other.
12031203
*/
12041204
SIMD.float64x2.notEqual = function(t, other) {
@@ -1212,7 +1212,7 @@ SIMD.float64x2.notEqual = function(t, other) {
12121212
/**
12131213
* @param {float64x2} t An instance of float64x2.
12141214
* @param {float64x2} other An instance of float64x2.
1215-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1215+
* @return {int32x4} true or false in each lane depending on
12161216
* the result of t >= other.
12171217
*/
12181218
SIMD.float64x2.greaterThanOrEqual = function(t, other) {
@@ -1226,7 +1226,7 @@ SIMD.float64x2.greaterThanOrEqual = function(t, other) {
12261226
/**
12271227
* @param {float64x2} t An instance of float64x2.
12281228
* @param {float64x2} other An instance of float64x2.
1229-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1229+
* @return {int32x4} true or false in each lane depending on
12301230
* the result of t > other.
12311231
*/
12321232
SIMD.float64x2.greaterThan = function(t, other) {
@@ -1550,7 +1550,7 @@ SIMD.int32x4.withW = function(t, w) {
15501550
/**
15511551
* @param {int32x4} t An instance of int32x4.
15521552
* @param {int32x4} other An instance of int32x4.
1553-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1553+
* @return {int32x4} true or false in each lane depending on
15541554
* the result of t == other.
15551555
*/
15561556
SIMD.int32x4.equal = function(t, other) {
@@ -1566,7 +1566,7 @@ SIMD.int32x4.equal = function(t, other) {
15661566
/**
15671567
* @param {int32x4} t An instance of int32x4.
15681568
* @param {int32x4} other An instance of int32x4.
1569-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1569+
* @return {int32x4} true or false in each lane depending on
15701570
* the result of t > other.
15711571
*/
15721572
SIMD.int32x4.greaterThan = function(t, other) {
@@ -1582,7 +1582,7 @@ SIMD.int32x4.greaterThan = function(t, other) {
15821582
/**
15831583
* @param {int32x4} t An instance of int32x4.
15841584
* @param {int32x4} other An instance of int32x4.
1585-
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
1585+
* @return {int32x4} true or false in each lane depending on
15861586
* the result of t < other.
15871587
*/
15881588
SIMD.int32x4.lessThan = function(t, other) {

0 commit comments

Comments
 (0)