lift()
Function in IR
Normalizes a NodeLike operand to a ReadonlyNode: a JS number becomes an f32 literal, and an existing node passes through unchanged.
import { lift } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function lift(x: NodeLike): ReadonlyNode<string>Parameters
xNodeLike
Return value
ReadonlyNode<string>
Description
Every free-function builtin (sin,
min, construct, …) sends its operands through this, which is why sin(1) works without
an explicit f32(1). Call it directly only when writing a new builtin wrapper that needs a
plain node from a NodeLike argument. Method operands take a different path: a bare number
passed to a method lifts to the receiver’s own scalar kind (u32, i32 or f64), so
u32node.add(1) emits an unsigned literal.
Examples
Example
import { lift, f32 } from 'typeshade'
lift(2) // Node<'f32'>: 2 lifted to an f32 literallift(f32(2)) // the same node, passed through unchangedSee also
Source
src/core/ir/node.ts, line 127, at commit 26de7be8