[qfcc] Add an expression type for types

No support functions yet, but this should make it easy to manipulate
type "expressions" in the parser for building generic functions.
This commit is contained in:
Bill Currie 2024-04-25 23:19:24 +09:00
parent 45d4b12e7a
commit 434bcdebbb
5 changed files with 14 additions and 0 deletions

View file

@ -306,6 +306,10 @@ typedef struct {
ex_list_t components; ///< multivector components
} ex_multivec_t;
typedef struct {
const type_t *type;
} ex_type_t;
#define POINTER_VAL(p) (((p).def ? (p).def->offset : 0) + (p).val)
typedef struct expr_s {
@ -345,6 +349,7 @@ typedef struct expr_s {
ex_swizzle_t swizzle; ///< vector swizzle operation
ex_extend_t extend; ///< vector extend operation
ex_multivec_t multivec; ///< geometric algebra multivector
ex_type_t typ; ///< type expression
};
} expr_t;

View file

@ -67,5 +67,6 @@ EX_EXPR(swizzle) ///< vector swizzle operation (::ex_swizzle_t)
EX_EXPR(extend) ///< vector extend operation (::ex_extend_t)
EX_EXPR(multivec) ///< geometric algebra multivector (::ex_multivec_t)
EX_EXPR(list) ///< non-invasive list of expressions (::ex_list_t)
EX_EXPR(type) ///< type expression for generics
///@}

View file

@ -198,6 +198,8 @@ get_type (const expr_t *e)
return get_type (last->expr);
}
return 0;
case ex_type:
return nullptr;
case ex_count:
internal_error (e, "invalid expression");
}
@ -1723,6 +1725,7 @@ has_function_call (const expr_t *e)
case ex_adjstk:
case ex_with:
case ex_args:
case ex_type:
return 0;
case ex_multivec:
for (auto c = e->multivec.components.head; c; c = c->next) {
@ -1832,6 +1835,7 @@ unary_expr (int op, const expr_t *e)
case ex_with:
case ex_args:
case ex_list:
case ex_type:
internal_error (e, "unexpected expression type");
case ex_uexpr:
if (e->expr.op == '-') {
@ -1948,6 +1952,7 @@ unary_expr (int op, const expr_t *e)
case ex_with:
case ex_args:
case ex_list:
case ex_type:
internal_error (e, "unexpected expression type");
case ex_bool:
return new_bool_expr (e->boolean.false_list,
@ -2042,6 +2047,7 @@ unary_expr (int op, const expr_t *e)
case ex_with:
case ex_args:
case ex_list:
case ex_type:
internal_error (e, "unexpected expression type");
case ex_uexpr:
if (e->expr.op == '~')

View file

@ -149,6 +149,7 @@ is_lvalue (const expr_t *expr)
case ex_extend:
case ex_multivec:
case ex_list:
case ex_type:
break;
case ex_count:
internal_error (expr, "invalid expression");

View file

@ -76,6 +76,7 @@ edag_add_expr (const expr_t *expr)
case ex_adjstk:
case ex_with:
case ex_args:
case ex_type:
// these are never put in the dag
return expr;
case ex_list: