isScalar
이 페이지에서

isScalar()

함수, 타입 분류

Narrows a ShaderType to the native { kind: 'scalar' } arm.

import { isScalar } from 'typeshade'

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

구문

const isScalar: (
t: ShaderType,
) => t is Extract<ShaderType, { kind: "scalar"; }>

매개변수

t ShaderType

반환값

t is Extract<ShaderType, { kind: 'scalar' }>

설명

Narrows a ShaderType to the native { kind: 'scalar' } arm (f32, i32, u32, bool). It is false for f64T, which is its own kind so that this predicate does not treat it as a scalar. Arithmetic type resolution uses it to detect the vector-scalar broadcast case (isVec(a) && isScalar(b) and its mirror), where the vector operand’s type is the result.

예제

예제

import { isScalar, f32T, f64T } from 'typeshade'
isScalar(f32T) // true
isScalar(f64T) // false: f64 is its own ShaderType kind

함께 보기

소스

src/core/ir/types.ts, 1089행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고