[qfcc] Add a check for bool types

And us it in matrix_type. Although there are no bool matrices even in
glsl, there are bool vectors and vector_type uses matrix_type.
This commit is contained in:
Bill Currie 2024-08-10 14:22:20 +09:00
parent 8fe23a29b3
commit 4c424fcb61
2 changed files with 15 additions and 0 deletions

View file

@ -219,6 +219,7 @@ const char *type_get_encoding (const type_t *type);
#include "QF/progs/pr_type_names.h"
int is_enum (const type_t *type) __attribute__((pure));
int is_bool (const type_t *type) __attribute__((pure));
int is_integral (const type_t *type) __attribute__((pure));
int is_real (const type_t *type) __attribute__((pure));
int is_scalar (const type_t *type) __attribute__((pure));

View file

@ -663,6 +663,9 @@ pointer_type (const type_t *aux)
const type_t *
matrix_type (const type_t *ele_type, int cols, int rows)
{
if (!is_bool (ele_type) && !is_scalar (ele_type)) {
return nullptr;
}
if (rows == 1 && cols == 1) {
for (type_t **t = ev_types; t - ev_types < ev_type_count; t++) {
if ((*t)->type == ele_type->type && (*t)->width == 1) {
@ -1251,6 +1254,17 @@ is_enum (const type_t *type)
return 0;
}
int
is_bool (const type_t *type)
{
type = unalias_type (type);
if (type->meta != ty_bool) {
return 0;
}
//FIXME 64-bit bool
return type->type == ev_int;
}
int
is_integral (const type_t *type)
{