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

Commit 2782a23

Browse files
committed
Make the flag properties use '< 0'.
When interpreting the truth value of an integer in a SIMD value, use the '< 0' convention.
1 parent b85f7aa commit 2782a23

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/ecmascript_simd.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ _PRIVATE.maxNum = function(x, y) {
5454
return x != x ? y :
5555
y != y ? x :
5656
Math.max(x, y);
57+
58+
_PRIVATE.tobool = function(x) {
59+
return x < 0;
60+
}
61+
62+
_PRIVATE.frombool = function(x) {
63+
return !x - 1;
5764
}
5865

5966
function checkFloat32x4(t) {
@@ -2171,19 +2178,19 @@ Object.defineProperty(SIMD.int32x4.prototype, 'w', {
21712178
});
21722179

21732180
Object.defineProperty(SIMD.int32x4.prototype, 'flagX', {
2174-
get: function() { return this.x_ != 0x0; }
2181+
get: function() { return _PRIVATE.tobool(this.x_); }
21752182
});
21762183

21772184
Object.defineProperty(SIMD.int32x4.prototype, 'flagY', {
2178-
get: function() { return this.y_ != 0x0; }
2185+
get: function() { return _PRIVATE.tobool(this.y_); }
21792186
});
21802187

21812188
Object.defineProperty(SIMD.int32x4.prototype, 'flagZ', {
2182-
get: function() { return this.z_ != 0x0; }
2189+
get: function() { return _PRIVATE.tobool(this.z_); }
21832190
});
21842191

21852192
Object.defineProperty(SIMD.int32x4.prototype, 'flagW', {
2186-
get: function() { return this.w_ != 0x0; }
2193+
get: function() { return _PRIVATE.tobool(this.w_); }
21872194
});
21882195

21892196
/**

src/ecmascript_simd_tests.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1937,10 +1937,14 @@ test('int32x4 and', function() {
19371937
equal(0x55555555, n.y);
19381938
equal(0x55555555, n.z);
19391939
equal(0x55555555, n.w);
1940-
equal(true, n.flagX);
1941-
equal(true, n.flagY);
1942-
equal(true, n.flagZ);
1943-
equal(true, n.flagW);
1940+
equal(true, m.flagX);
1941+
equal(true, m.flagY);
1942+
equal(true, m.flagZ);
1943+
equal(true, m.flagW);
1944+
equal(false, n.flagX);
1945+
equal(false, n.flagY);
1946+
equal(false, n.flagZ);
1947+
equal(false, n.flagW);
19441948
var o = SIMD.int32x4.and(m,n); // and
19451949
equal(0x0, o.x);
19461950
equal(0x0, o.y);

0 commit comments

Comments
 (0)