renameVarrefsInFunc
이 페이지에서

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

매개변수

f FuncDecl

The function whose body is rewritten.

rename (name: string) => string | undefined

Maps a current variable name to its new name, or returns undefined to keep the current name.

반환값

FuncDecl

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 기준

이 페이지 편집 문제 보고