lowerModule
이 페이지에서

lowerModule()

함수, 출력 분류

Rewrites every matchExpr in a module into a form the backends can emit: a hoisted variable assigned from a switch statement, placed immediately before the statement that contained the expression.

import { lowerModule } from 'typeshade'

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

구문

function lowerModule(m: ModuleDecl): ModuleDecl

매개변수

m ModuleDecl

The module to rewrite. It is not modified.

반환값

ModuleDecl

A new module whose function bodies contain no matchExpr.

예외

Error

When a matchExpr appears in a for loop header (the init, condition or update part). Hoisting it out of the header would evaluate it once where the loop evaluates it on every iteration. Compute the value into a var inside the loop body, or before the loop when it does not depend on the loop variable.

설명

WGSL and GLSL have switch only as a statement, so a multi-arm conditional expression cannot be emitted in place.

emitModule runs this pass automatically, so a shader author never calls it. It is exported for tests and for hosts that drive the emit pipeline step by step. The pass rebuilds every node it touches, so the returned module does not share node identity with the authored one and diagnostics cannot map its nodes back to authored source locations. Run validate and diagnose() on the module before this pass.

함께 보기

소스

src/core/passes/match-lower.ts, 62행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고