mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Add partial support for pointer arithmetic.
Only pointer +/- integral is supported. pointer - pointer will come later.
This commit is contained in:
parent
afbab60c25
commit
48fe9f729d
2 changed files with 25 additions and 0 deletions
|
@ -450,6 +450,13 @@ do_op_pointer (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
||||||
type_t *type;
|
type_t *type;
|
||||||
static int valid[] = {'=', PAS, '&', 'M', '.', EQ, NE, 0};
|
static int valid[] = {'=', PAS, '&', 'M', '.', EQ, NE, 0};
|
||||||
|
|
||||||
|
if (is_integral (type = get_type (e2)) && (op == '-' || op == '+')) {
|
||||||
|
// pointer arithmetic
|
||||||
|
expr_t *ptoi = new_alias_expr (type, e1);
|
||||||
|
e->e.expr.e1 = ptoi;
|
||||||
|
e = fold_constants (e);
|
||||||
|
return new_alias_expr (get_type (e1), e);
|
||||||
|
}
|
||||||
if (!valid_op (op, valid))
|
if (!valid_op (op, valid))
|
||||||
return error (e1, "invalid operator for pointer");
|
return error (e1, "invalid operator for pointer");
|
||||||
|
|
||||||
|
|
|
@ -33,3 +33,21 @@ weapon_range =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
duffs_device (int *to, int *from, int count)
|
||||||
|
{
|
||||||
|
int n = (count + 7) / 8;
|
||||||
|
|
||||||
|
switch (count % 8) {
|
||||||
|
case 0: do { *to = *from++;
|
||||||
|
case 7: *to = *from++;
|
||||||
|
case 6: *to = *from++;
|
||||||
|
case 5: *to = *from++;
|
||||||
|
case 4: *to = *from++;
|
||||||
|
case 3: *to = *from++;
|
||||||
|
case 2: *to = *from++;
|
||||||
|
case 1: *to = *from++;
|
||||||
|
} while(--n > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue