mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
make pointers work a bit better
This commit is contained in:
parent
3b3b90ef4a
commit
6af57049d5
4 changed files with 11 additions and 13 deletions
|
@ -80,7 +80,6 @@ typedef struct {
|
|||
typedef struct {
|
||||
int val;
|
||||
struct type_s *type;
|
||||
int abs;
|
||||
struct def_s *def;
|
||||
} ex_pointer_t;
|
||||
|
||||
|
|
|
@ -335,10 +335,9 @@ emit_deref_expr (expr_t *e, def_t *dest)
|
|||
|
||||
e = e->e.expr.e1;
|
||||
if (e->type == ex_pointer) {
|
||||
if (e->e.pointer.val > 0 && e->e.pointer.val < 65536) {
|
||||
if (e->e.pointer.val >= 0 && e->e.pointer.val < 65536) {
|
||||
d = new_def (e->e.pointer.type, 0, current_scope);
|
||||
d->ofs = e->e.pointer.val;
|
||||
d->absolute = e->e.pointer.abs;
|
||||
} else {
|
||||
d = ReuseConstant (e, 0);
|
||||
zero.type = ex_short;
|
||||
|
@ -346,6 +345,10 @@ emit_deref_expr (expr_t *e, def_t *dest)
|
|||
op = opcode_find (".", d, z, dest);
|
||||
d = emit_statement (e, op, d, z, dest);
|
||||
}
|
||||
if (e->e.pointer.def) {
|
||||
d->global = e->e.pointer.def->global;
|
||||
d->local = e->e.pointer.def->local;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
if (!dest && (e->type != ex_pointer
|
||||
|
|
|
@ -1242,7 +1242,6 @@ field_expr (expr_t *e1, expr_t *e2)
|
|||
i = e1->e.pointer.val;
|
||||
e->e.pointer.val = i + field->offset;
|
||||
e->e.pointer.type = field->type;
|
||||
e->e.pointer.abs = e1->e.pointer.abs;
|
||||
return unary_expr ('.', e);
|
||||
}
|
||||
}
|
||||
|
@ -2056,28 +2055,21 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t)
|
|||
def_t *def = e1->e.def;
|
||||
type = def->type;
|
||||
if (type->type == ev_struct) {
|
||||
int abs = e1->e.def->global;
|
||||
def_t *def = e1->e.def;
|
||||
|
||||
e = e1;
|
||||
e->type = ex_pointer;
|
||||
e->e.pointer.val = def->ofs;
|
||||
e->e.pointer.type = t;
|
||||
e->e.pointer.abs = abs;
|
||||
e->e.pointer.def = def;
|
||||
} else if (type->type == ev_array) {
|
||||
int abs = e1->e.def->global;
|
||||
def_t *def = e1->e.def;
|
||||
|
||||
e = e1;
|
||||
e->type = ex_pointer;
|
||||
e->e.pointer.val = def->ofs;
|
||||
e->e.pointer.type = t;
|
||||
e->e.pointer.abs = abs;
|
||||
e->e.pointer.def = def;
|
||||
} else {
|
||||
e = new_unary_expr ('&', e1);
|
||||
e->e.expr.type = pointer_type (type);
|
||||
}
|
||||
e->e.pointer.def = def;
|
||||
break;
|
||||
}
|
||||
case ex_expr:
|
||||
|
|
|
@ -136,6 +136,10 @@ flags (def_t *d)
|
|||
flags |= QFOD_LOCAL;
|
||||
if (d->system)
|
||||
flags |= QFOD_SYSTEM;
|
||||
if (!flags) {
|
||||
fprintf (stderr, "malformed def flags\n");
|
||||
abort ();
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue