renameVarrefsInFunc()
함수, IR 분류
Renames variable references in the body of f.
import { renameVarrefsInFunc } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function renameVarrefsInFunc( f: FuncDecl, rename: (name: string) => string | undefined,): FuncDecl매개변수
fFuncDeclThe function whose body is rewritten.
rename(name: string) => string | undefinedMaps a current variable name to its new name, or returns
undefinedto keep the current name.
반환값
A copy of f with the renamed body, or f itself when no
reference was renamed.
설명
Every variable reference (an expression with op: 'varref') is passed to
rename by name. When rename returns a string, the reference is
re-pointed at that name; when it returns undefined, the reference is
kept as is. Unchanged references keep their original objects, and f
itself is returned when no name changed (see rewriteExprsInFunc).
예제
예제
// Point reads of the `u` uniform block at `u_split`.const g = renameVarrefsInFunc(f, (name) => name === 'u' ? 'u_split' : undefined,)함께 보기
소스
src/core/passes/rename-varrefs.ts, 198행, 커밋 c66579bf 기준