Node
On this page

Node

Class in IR

The write-capable node.

import { Node } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

class Node<K extends string = string> extends ReadonlyNode<K>

Description

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.

Instance methods

assign (value: ArithArg<K>): void

this = value;, the one mutation method (the same shape as three.js TSL’s .assign()). JS cannot overload =: x = v would rebind the JS variable and emit nothing, so mutation is a method. For a compound update write x.assign(x.add(v)); add is the pure expression. The value lifts to this node’s scalar kind.

addAssign (value: ArithArg<K>): void

this += value; — the compound assignment, emitted as x += v on both targets. The same statement the "use typeshade" surface’s x += v lowers to, so a helper ported between the two authoring surfaces keeps its emit.

this.assign(this.add(value)) is the other spelling and emits x = (x + v). Both are correct; this one is shorter and is the one the seam is defined on.

subAssign (value: ArithArg<K>): void

this -= value;, the subtracting Node.addAssign.

mulAssign (value: ArithArg<K>): void

this *= value;, the multiplying Node.addAssign.

divAssign (value: ArithArg<K>): void

this /= value;, the dividing Node.addAssign.

In the guide

See also

Source

src/core/ir/node.ts, line 822, at commit 26de7be8

Edit this page Report a problem