autoVars
이 페이지에서

autoVars()

함수, 출력 분류

Turns every value that is later assigned to into a WGSL var.

import { autoVars } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

function autoVars(m: ModuleDecl): ModuleDecl

매개변수

m ModuleDecl

The module to process.

반환값

ModuleDecl

A new module with the rewritten functions; m itself is unchanged.

설명

A shader author writes a mutable value as a plain const x = expr and then calls x.assign(...) or a compound assignment such as += on it; nothing marks x as a variable up front. This pass finds each such value in every function of m, declares a var for it just before the first statement that uses it, and rewrites every reference to that value, including the assignment targets themselves, to read and write the new var. An assignment through a member or index access (c.a, m[i]) declares the var for the base value c or m. Values that already have a name (function parameters, constants, override constants and existing var or let bindings) are left alone.

소스

src/core/passes/opt/auto-vars.ts, 188행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고