UNPKG

typegpu

Version:

A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.

27 lines (26 loc) 1.4 kB
import type { BaseData } from '../../data/wgslTypes.ts'; import { $getNameForward } from '../../shared/symbols.ts'; import type { SelfResolvable } from '../../types.ts'; /** * Shell-less functions are possible because we can infer the signature based solely on the context * around the function. * * ## Arguments * The snippets of the function's arguments are used to infer the types of the function's arguments. * We only care that the arguments are of a concrete type (we concretize them if they're not). We * cache these signatures based on the argument types, so that we can reuse them across calls. * * ## Return type * In shelled functions, the return type is known when generating the body, but in the case of shell-less functions, * we gather candidates for return types when visiting return statement nodes, and try to unify them into one type * before generating the signature. * * TODO: This behavior can be refined by considering the "expected type" of the function call expression. */ export interface ShelllessImpl extends SelfResolvable { readonly resourceType: 'shellless-impl'; readonly argTypes: BaseData[]; readonly [$getNameForward]: unknown; } export declare function isShelllessImpl(value: unknown): value is ShelllessImpl; export declare function createShelllessImpl(argTypes: BaseData[], implementation: (...args: never[]) => unknown): ShelllessImpl;