mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +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
|
@ -150,11 +150,7 @@ assign_expr (exprval_t *dst, const exprval_t *src, exprctx_t *context)
|
||||||
if (!src) {
|
if (!src) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (binop = dst->type->binops; binop && binop->op; binop++) {
|
binop = cexpr_find_cast (dst->type, src->type);
|
||||||
if (binop->op == '=' && binop->other == src->type) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (binop && binop->op) {
|
if (binop && binop->op) {
|
||||||
binop->func (dst, src, dst, context);
|
binop->func (dst, src, dst, context);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -125,6 +125,13 @@ BINOP(uint, bor, unsigned, |)
|
||||||
BINOP(uint, xor, unsigned, ^)
|
BINOP(uint, xor, unsigned, ^)
|
||||||
BINOP(uint, rem, 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, pos, unsigned, +)
|
||||||
UNOP(uint, neg, unsigned, -)
|
UNOP(uint, neg, unsigned, -)
|
||||||
UNOP(uint, tnot, unsigned, !)
|
UNOP(uint, tnot, unsigned, !)
|
||||||
|
@ -142,6 +149,7 @@ binop_t uint_binops[] = {
|
||||||
{ '^', &cexpr_uint, &cexpr_uint, uint_xor },
|
{ '^', &cexpr_uint, &cexpr_uint, uint_xor },
|
||||||
{ '%', &cexpr_uint, &cexpr_uint, uint_rem },
|
{ '%', &cexpr_uint, &cexpr_uint, uint_rem },
|
||||||
{ MOD, &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