mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
[util] Add an int to uint cast for cexpr
This commit is contained in:
parent
25ade4c0f3
commit
5b0da2b14c
2 changed files with 9 additions and 5 deletions
libs/util
|
@ -150,11 +150,7 @@ assign_expr (exprval_t *dst, const exprval_t *src, exprctx_t *context)
|
|||
if (!src) {
|
||||
return;
|
||||
}
|
||||
for (binop = dst->type->binops; binop && binop->op; binop++) {
|
||||
if (binop->op == '=' && binop->other == src->type) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
binop = cexpr_find_cast (dst->type, src->type);
|
||||
if (binop && binop->op) {
|
||||
binop->func (dst, src, dst, context);
|
||||
} else {
|
||||
|
|
|
@ -125,6 +125,13 @@ BINOP(uint, bor, unsigned, |)
|
|||
BINOP(uint, xor, unsigned, ^)
|
||||
BINOP(uint, rem, unsigned, %)
|
||||
|
||||
static void
|
||||
uint_cast_int (const exprval_t *val1, const exprval_t *src, exprval_t *result,
|
||||
exprctx_t *ctx)
|
||||
{
|
||||
*(unsigned *) result->value = *(int *) src->value;
|
||||
}
|
||||
|
||||
UNOP(uint, pos, unsigned, +)
|
||||
UNOP(uint, neg, unsigned, -)
|
||||
UNOP(uint, tnot, unsigned, !)
|
||||
|
@ -142,6 +149,7 @@ binop_t uint_binops[] = {
|
|||
{ '^', &cexpr_uint, &cexpr_uint, uint_xor },
|
||||
{ '%', &cexpr_uint, &cexpr_uint, uint_rem },
|
||||
{ MOD, &cexpr_uint, &cexpr_uint, uint_rem },
|
||||
{ '=', &cexpr_int, &cexpr_uint, uint_cast_int },
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue