mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
Give - unary expressions special treatment.
The progs engine has no neg instruction, so need to implement -val as nil - val
This commit is contained in:
parent
f9e177efd6
commit
4324486ae6
1 changed files with 20 additions and 0 deletions
|
@ -589,6 +589,22 @@ expr_cast (sblock_t *sblock, expr_t *e, operand_t **op)
|
|||
return sblock;
|
||||
}
|
||||
|
||||
static sblock_t *
|
||||
expr_negate (sblock_t *sblock, expr_t *e, operand_t **op)
|
||||
{
|
||||
expr_t *neg;
|
||||
expr_t *zero;
|
||||
|
||||
zero = new_nil_expr ();
|
||||
zero->file = e->file;
|
||||
zero->line = e->line;
|
||||
convert_nil (zero, e->e.expr.type);
|
||||
neg = binary_expr ('-', zero, e->e.expr.e1);
|
||||
neg->file = e->file;
|
||||
neg->line = e->line;
|
||||
return statement_subexpr (sblock, neg, op);
|
||||
}
|
||||
|
||||
static sblock_t *
|
||||
expr_uexpr (sblock_t *sblock, expr_t *e, operand_t **op)
|
||||
{
|
||||
|
@ -608,6 +624,10 @@ expr_uexpr (sblock_t *sblock, expr_t *e, operand_t **op)
|
|||
case 'C':
|
||||
sblock = expr_cast (sblock, e, op);
|
||||
break;
|
||||
case '-':
|
||||
// progs has no neg instruction!?!
|
||||
sblock = expr_negate (sblock, e, op);
|
||||
break;
|
||||
default:
|
||||
opcode = convert_op (e->e.expr.op);
|
||||
if (!opcode)
|
||||
|
|
Loading…
Reference in a new issue