lift()
함수, 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'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function lift(x: NodeLike): ReadonlyNode<string>매개변수
xNodeLike
반환값
ReadonlyNode<string>
설명
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.
예제
예제
import { lift, f32 } from 'typeshade'
lift(2) // Node<'f32'>: 2 lifted to an f32 literallift(f32(2)) // the same node, passed through unchanged함께 보기
소스
src/core/ir/node.ts, 127행, 커밋 c66579bf 기준