spellIntrinsic
On this page

spellIntrinsic()

Function in Backends

Spells a call for one target.

import { spellIntrinsic } from 'typeshade'

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

Syntax

function spellIntrinsic(
target: IntrinsicTarget,
name: string,
args: readonly string[],
): string

Parameters

target IntrinsicTarget

The target to spell for, 'wgsl' or 'glsl'.

name string

The builtin id or function name.

args readonly string[]

The argument expressions, already rendered as source text.

Return value

string

The call as source text for target.

Description

When name has an INTRINSICS entry, returns that entry’s spelling for target applied to args; otherwise returns name(args) with the arguments joined by , , which covers portable builtins and user-defined function calls alike.

Examples

Example

spellIntrinsic('glsl', 'atan2', ['y', 'x']) // 'atan(y, x)'
spellIntrinsic('wgsl', 'dot', ['a', 'b']) // 'dot(a, b)'

See also

Source

src/core/intrinsics.ts, line 1026, at commit 26de7be8

Edit this page Report a problem