Assing const As.* functions to type class
Change-Id: I99c588b53f28da119611ef0a5b27820cdaa57fc2 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20262 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
cb883a2817
commit
dd218b050d
|
@ -108,6 +108,61 @@ bool Type::is_integer_scalar_or_vector() {
|
|||
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
|
||||
}
|
||||
|
||||
const AliasType* Type::AsAlias() const {
|
||||
assert(IsAlias());
|
||||
return static_cast<const AliasType*>(this);
|
||||
}
|
||||
|
||||
const ArrayType* Type::AsArray() const {
|
||||
assert(IsArray());
|
||||
return static_cast<const ArrayType*>(this);
|
||||
}
|
||||
|
||||
const BoolType* Type::AsBool() const {
|
||||
assert(IsBool());
|
||||
return static_cast<const BoolType*>(this);
|
||||
}
|
||||
|
||||
const F32Type* Type::AsF32() const {
|
||||
assert(IsF32());
|
||||
return static_cast<const F32Type*>(this);
|
||||
}
|
||||
|
||||
const I32Type* Type::AsI32() const {
|
||||
assert(IsI32());
|
||||
return static_cast<const I32Type*>(this);
|
||||
}
|
||||
|
||||
const MatrixType* Type::AsMatrix() const {
|
||||
assert(IsMatrix());
|
||||
return static_cast<const MatrixType*>(this);
|
||||
}
|
||||
|
||||
const PointerType* Type::AsPointer() const {
|
||||
assert(IsPointer());
|
||||
return static_cast<const PointerType*>(this);
|
||||
}
|
||||
|
||||
const StructType* Type::AsStruct() const {
|
||||
assert(IsStruct());
|
||||
return static_cast<const StructType*>(this);
|
||||
}
|
||||
|
||||
const U32Type* Type::AsU32() const {
|
||||
assert(IsU32());
|
||||
return static_cast<const U32Type*>(this);
|
||||
}
|
||||
|
||||
const VectorType* Type::AsVector() const {
|
||||
assert(IsVector());
|
||||
return static_cast<const VectorType*>(this);
|
||||
}
|
||||
|
||||
const VoidType* Type::AsVoid() const {
|
||||
assert(IsVoid());
|
||||
return static_cast<const VoidType*>(this);
|
||||
}
|
||||
|
||||
AliasType* Type::AsAlias() {
|
||||
assert(IsAlias());
|
||||
return static_cast<AliasType*>(this);
|
||||
|
|
|
@ -81,6 +81,29 @@ class Type {
|
|||
/// @returns true if this type is an integer scalar or vector
|
||||
bool is_integer_scalar_or_vector();
|
||||
|
||||
/// @returns the type as an alias type
|
||||
const AliasType* AsAlias() const;
|
||||
/// @returns the type as an array type
|
||||
const ArrayType* AsArray() const;
|
||||
/// @returns the type as a bool type
|
||||
const BoolType* AsBool() const;
|
||||
/// @returns the type as a f32 type
|
||||
const F32Type* AsF32() const;
|
||||
/// @returns the type as an i32 type
|
||||
const I32Type* AsI32() const;
|
||||
/// @returns the type as a matrix type
|
||||
const MatrixType* AsMatrix() const;
|
||||
/// @returns the type as a pointer type
|
||||
const PointerType* AsPointer() const;
|
||||
/// @returns the type as a struct type
|
||||
const StructType* AsStruct() const;
|
||||
/// @returns the type as a u32 type
|
||||
const U32Type* AsU32() const;
|
||||
/// @returns the type as a vector type
|
||||
const VectorType* AsVector() const;
|
||||
/// @returns the type as a void type
|
||||
const VoidType* AsVoid() const;
|
||||
|
||||
/// @returns the type as an alias type
|
||||
AliasType* AsAlias();
|
||||
/// @returns the type as an array type
|
||||
|
|
Loading…
Reference in New Issue