EmitOptions
Interface in Emit
Options accepted by emitModule and emitGlslModule.
import type { EmitOptions } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
interface EmitOptions { readonly plugins?: readonly EmitPlugin[]; readonly parens?: ParenMode; readonly fp64Flavor?: Fp64Flavor;}Description
Every field is optional; an omitted or empty options object gives the plain emit.
Examples
Example
import { obfuscate } from 'typeshade/emit-prod'
const wgsl = emitModule(MODULE, { plugins: obfuscate(), parens: 'minimal' })Instance properties
pluginsoptionalread onlyreadonly EmitPlugin[]Plugins to run around the assembly, in order. See
EmitPluginfor the hook sequence.parensoptionalread onlyParenModeHow many parentheses the emitted expressions carry.
'full'is the default and wraps every operator.'minimal'omits a paren wherever operator precedence already implies the same parse. Pair it with{ plugins: obfuscate() }for the smallest shipped shader.'minimal'omits a paren only where WGSL and GLSL ES 3.00 define the same precedence:*,/and%over+and-over unary-. The relational, logical, bitwise and shift operators stay wrapped on purpose, because WGSL gives them no chaining precedence at all, so mixing them unparenthesised is a compile error there and ranking them would invent a rule one target lacks. The operands of a bitwise or shift operator are unary in WGSL’s grammar, so an arithmetic one keeps its parens too:a & (b - c).It never reassociates.
a + (b + c)keeps its parens, because in floating point that is a different number froma + b + c.fp64Flavoroptionalread onlyFp64FlavorWhich arithmetic primitives back the emulated-double helper functions that f64 lowering injects.
'float'is the default.'integer'writes the primitives in integer bit arithmetic, which a fast-math compiler pass cannot reassociate, and injects no_fp64guard binding. SeeFp64Flavorfor when to choose each.
See also
Source
src/core/emit.ts, line 690, at commit 26de7be8