Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

SIMD.Bool32x4

我們的志工尚未將此文章翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The SIMD.Bool32x4 data type is a 128-bit vector divided into 4 lanes storing boolean values.

Syntax

SIMD.Bool32x4(x, y, z, w);

Parameters

x Optional
A boolean specifying the value of the first lane. Defaults to false.
y Optional
A boolean specifying the value of the second lane. Defaults to false.
z Optional
A boolean specifying the value of the third lane. Defaults to false.
w Optional
A boolean specifying the value of the fourth lane. Defaults to false.

Constructor functions

In addition to the simple creator function, the SIMD API provides the following constructor functions.

SIMD.Bool32x4.splat()
Creates an Bool32x4 with all lanes set to a given value.

Note: SIMD types don't work with new, as SIMD values are no "boxed" objects (comparable to String(s) vs. new String(s), which creates a String object).

var v = new SIMD.Bool32x4(true,false,true,false); 
// TypeError: SIMD.Bool32x4 is not a constructor
var w = new SIMD.Bool32x4.splat(true); 
// TypeError: SIMD.Bool32x4.splat is not a constructor

Instead, you just write:

var v = SIMD.Bool32x4(true, false, true, false);
var w = SIMD.Bool32x4.splat(true);

Operations

To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.

Checking SIMD types

SIMD.Bool32x4.check()
Returns a new Bool32x4 if the parameter is a valid Bool32x4 data type. Throws a TypeError otherwise.

Accessing and mutating lanes

SIMD.Bool32x4.extractLane()
Returns the value of the given lane.
SIMD.Bool32x4.replaceLane()
Returns a new Bool16x8 with the given lane value replaced.

Boolean operations

SIMD.Bool32x4.allTrue()
Checks if all lanes hold a true value.
SIMD.Bool32x4.anyTrue()
Checks if any of the lanes hold a true value.

Bitwise logical operations

SIMD.Bool32x4.and()
Returns a new Bool32x4 with the logical AND of the lane values (a & b).
SIMD.Bool32x4.or()
Returns a new Bool32x4 with the logical OR of the lane values (a | b).
SIMD.Bool32x4.xor()
Returns a new Bool32x4 with the logical XOR of the lane values (a ^ b).
SIMD.Bool32x4.not()
Returns a new Bool32x4 with lane with the logical NOT of the lane values (~a).

SIMD prototype

The following methods and properties are installed on the SIMD.Bool32x4.prototype.

SIMD.Bool32x4.prototype.constructor
Specifies the function that creates a SIMD object's prototype.
SIMD.Bool32x4.prototype.toLocaleString()
Returns a localized string representing the SIMD type and its elements. Overrides the Object.prototype.toLocaleString() method.
SIMD.Bool32x4.prototype.toString()
Returns a string representing the SIMD type and its elements. Overrides the Object.prototype.toString() method.
SIMD.Bool32x4.prototype.valueOf()
Returns the primitive value of a SIMD object.
SIMD.Bool32x4.prototype.toSource()
Returns a string representing the source code of the object. Overrides the Object.prototype.toSource() method.

Examples

Constructing a Bool32x4

SIMD.Bool32x4(true, false, true, false); // Bool32x4[true,false,true,false]
SIMD.Bool32x4(true, false);              // Bool32x4[true,false,false,false]
SIMD.Bool32x4();                         // Bool32x4[false,false,false,false]

Specifications

Specification Status Comment
SIMD
The definition of 'Bool32x4' in that specification.
Draft Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support Nightly build No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support Nightly build No support No support No support

See also

文件標籤與貢獻者

 此頁面的貢獻者: fscholz
 最近更新: fscholz,