mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Remove union hack for block expressions
I don't remember why I thought it was a good idea at the time, but I decided that having the union was a bit iffy and making the list "official" would be a good idea. In the end, it removed a nice chunk of code (redundant list manipulations).
This commit is contained in:
parent
dcd2505bb9
commit
8b9333e108
5 changed files with 15 additions and 34 deletions
|
@ -112,15 +112,11 @@ typedef struct ex_list_s {
|
|||
ex_listitem_t **tail;
|
||||
} ex_list_t;
|
||||
|
||||
typedef union {
|
||||
typedef struct {
|
||||
ex_list_t list;
|
||||
struct {
|
||||
ex_listitem_t *head;
|
||||
ex_listitem_t **tail;
|
||||
const expr_t *result; ///< the result of this block if non-void
|
||||
int is_call; ///< this block exprssion forms a function call
|
||||
void *return_addr;///< who allocated this
|
||||
};
|
||||
const expr_t *result; ///< the result of this block if non-void
|
||||
int is_call; ///< this block exprssion forms a function call
|
||||
void *return_addr; ///< who allocated this
|
||||
} ex_block_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -549,17 +549,11 @@ new_block_expr (const expr_t *old)
|
|||
expr_t *b = new_expr ();
|
||||
|
||||
b->type = ex_block;
|
||||
b->block.head = 0;
|
||||
b->block.tail = &b->block.head;
|
||||
if (old) {
|
||||
if (old->type != ex_block) {
|
||||
internal_error (old, "not a block expression");
|
||||
}
|
||||
if ((b->block.head = old->block.head)) {
|
||||
b->block.tail = old->block.tail;
|
||||
}
|
||||
b->block.result = old->block.result;
|
||||
b->block.is_call = old->block.is_call;
|
||||
b->block = old->block;
|
||||
}
|
||||
b->block.return_addr = __builtin_return_address (0);
|
||||
return b;
|
||||
|
@ -593,10 +587,9 @@ build_block_expr (expr_t *list, bool set_result)
|
|||
}
|
||||
expr_t *b = new_block_expr (0);
|
||||
|
||||
b->block.head = list->list.head;
|
||||
b->block.tail = list->list.tail;
|
||||
if (set_result && b->block.tail != &b->block.head) {
|
||||
auto last = (ex_listitem_t *) b->block.tail;
|
||||
b->block.list = list->list;
|
||||
if (set_result && b->block.list.tail != &b->block.list.head) {
|
||||
auto last = (ex_listitem_t *) b->block.list.tail;
|
||||
b->block.result = last->expr;
|
||||
}
|
||||
return b;
|
||||
|
@ -1606,9 +1599,7 @@ append_expr (expr_t *block, const expr_t *e)
|
|||
if (!e || e->type == ex_error)
|
||||
return block;
|
||||
|
||||
auto li = new_listitem (e);
|
||||
*block->block.tail = li;
|
||||
block->block.tail = &li->next;
|
||||
list_append (&block->block.list, e);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
@ -1622,13 +1613,7 @@ prepend_expr (expr_t *block, const expr_t *e)
|
|||
if (!e || e->type == ex_error)
|
||||
return block;
|
||||
|
||||
auto li = new_listitem (e);
|
||||
li->next = block->block.head;
|
||||
block->block.head = li;
|
||||
|
||||
if (block->block.tail == &block->block.head) {
|
||||
block->block.tail = &li->next;
|
||||
}
|
||||
list_prepend (&block->block.list, e);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
@ -1887,7 +1872,7 @@ has_function_call (const expr_t *e)
|
|||
if (e->block.is_call)
|
||||
return 1;
|
||||
case ex_list:
|
||||
for (auto li = e->block.head; li; li = li->next)
|
||||
for (auto li = e->block.list.head; li; li = li->next)
|
||||
if (has_function_call (li->expr))
|
||||
return 1;
|
||||
return 0;
|
||||
|
|
|
@ -308,8 +308,8 @@ convert_bool (const expr_t *e, int block)
|
|||
auto b = new_block_expr (0);
|
||||
append_expr (b, branch_expr (QC_NE, e, 0));
|
||||
append_expr (b, goto_expr (0));
|
||||
e = new_bool_expr (make_list (b->block.head->expr),
|
||||
make_list (b->block.head->next->expr), b);
|
||||
e = new_bool_expr (make_list (b->block.list.head->expr),
|
||||
make_list (b->block.list.head->next->expr), b);
|
||||
}
|
||||
}
|
||||
if (block && e->boolean.e->type != ex_block) {
|
||||
|
|
|
@ -2160,7 +2160,7 @@ identifier_list
|
|||
classdecl
|
||||
: CLASS identifier_list ';'
|
||||
{
|
||||
for (auto li = $2->block.head; li; li = li->next) {
|
||||
for (auto li = $2->block.list.head; li; li = li->next) {
|
||||
auto e = li->expr;
|
||||
get_class (e->symbol, 1);
|
||||
if (!e->symbol->table)
|
||||
|
|
|
@ -2274,7 +2274,7 @@ build_bool_block (expr_t *block, expr_t *e)
|
|||
break;
|
||||
case ex_block:
|
||||
if (!e->block.result) {
|
||||
for (auto t = e->block.head; t; t = t->next) {
|
||||
for (auto t = e->block.list.head; t; t = t->next) {
|
||||
build_bool_block (block, (expr_t *) t->expr);
|
||||
}
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue