i32()
Function in Values
An i32 literal node.
import { i32 } from 'typeshade/core/ir'
This export returns an IR node. A "use typeshade" file calls the builtin itself: i32()
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
function i32(v: number): Node<'i32'>;function i32(x: ReadonlyNode<ScalarCastSource>): Node<'i32'>;Parameters
vnumber
Return value
Node<'i32'>
Exceptions
Description
Use it over the f32 default wherever a value must type-check as a
signed integer: array and loop indices, matchExpr and matchEnum scrutinees, texture
layer arguments.
A Node argument is a cast instead: i32(x) converts, the free-function twin of x.i32().
It builds what toI32 builds, and its operand is bounded to a scalar.
Examples
Example
import { i32 } from 'typeshade/core/ir'
const zero = i32(0) // Node<'i32'>Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| CPU oracle | Supported | Evaluated in |
In the guide
See also
Source
src/core/ir/node.ts, line 805, at commit af54ddad5