IfChain
클래스, 작성 분류
The chain object Builder.if and If(/api/if/) return, so .elif(...) and .else(...) read top to bottom in authored order.
import { IfChain } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
class IfChain설명
The chain object Builder.if and If return, so .elif(...) and
.else(...) read top to bottom in authored order. It is reached only through the call
that starts a chain. Its methods extend the same if statement in place, pushed once on
the first arm, so a chain without a trailing .else still emits a valid if / else if
with no else block.
예제
예제
If(p.idx.eq(1), () => { pos.assign(vec2(3, -1))}).elif(p.idx.eq(2), () => { pos.assign(vec2(-1, 3))})생성자
new IfChain(private readonly parent: Builder, private readonly arms: Array<{ cond: Expr; body: Stmt[] }>, private readonly setElse: (body: Stmt[]) => void)
인스턴스 메서드
elif(cond: ReadonlyNode<'bool'>, body: (b: Builder) => ReadonlyNode | void): IfChainAdd an
else if (cond) { body }arm. Returns the chain. A body that returns a value is rejected withSD0115, as forBuilder.if.else(body: (b: Builder) => ReadonlyNode | void): voidAdd the
else { body }block and end the chain. A body that returns a value is rejected withSD0115, as forBuilder.if.
함께 보기
소스
src/core/ir/builder.ts, 388행, 커밋 c66579bf 기준