Node
클래스, IR 분류
The write-capable node.
import { Node } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
class Node<K extends string = string> extends ReadonlyNode<K>설명
Every value-producing method and builtin, and Var(), return this
subtype, which adds one method, .assign(), over the read-only ReadonlyNode base. Let(), a function parameter and a module constant are the ReadonlyNode supertype, so
someLet.assign(…) is a tsc error. The split is type-level only: the runtime is one
class, and the emitted WGSL and GLSL do not depend on which type a value carried.
인스턴스 메서드
assign(value: ArithArg<K>): voidthis = value;, the one mutation method (the same shape as three.js TSL’s.assign()). JS cannot overload=:x = vwould rebind the JS variable and emit nothing, so mutation is a method. For a compound update writex.assign(x.add(v));addis the pure expression. The value lifts to this node’s scalar kind.addAssign(value: ArithArg<K>): voidthis += value;— the compound assignment, emitted asx += von both targets. The same statement the"use typeshade"surface’sx += vlowers to, so a helper ported between the two authoring surfaces keeps its emit.this.assign(this.add(value))is the other spelling and emitsx = (x + v). Both are correct; this one is shorter and is the one the seam is defined on.subAssign(value: ArithArg<K>): voidthis -= value;, the subtractingNode.addAssign.mulAssign(value: ArithArg<K>): voidthis *= value;, the multiplyingNode.addAssign.divAssign(value: ArithArg<K>): voidthis /= value;, the dividingNode.addAssign.
관련 가이드
함께 보기
소스
src/core/ir/node.ts, 822행, 커밋 c66579bf 기준