mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 08:27:39 +00:00
Create a function to build if/else blocks.
This commit is contained in:
parent
638f4445cc
commit
258c896e4d
2 changed files with 41 additions and 0 deletions
|
@ -601,6 +601,7 @@ expr_t *incop_expr (int op, expr_t *e, int postop);
|
||||||
expr_t *array_expr (expr_t *array, expr_t *index);
|
expr_t *array_expr (expr_t *array, expr_t *index);
|
||||||
expr_t *pointer_expr (expr_t *pointer);
|
expr_t *pointer_expr (expr_t *pointer);
|
||||||
expr_t *address_expr (expr_t *e1, expr_t *e2, struct type_s *t);
|
expr_t *address_expr (expr_t *e1, expr_t *e2, struct type_s *t);
|
||||||
|
expr_t *build_if_statement (expr_t *test, expr_t *s1, expr_t *s2);
|
||||||
expr_t *assign_expr (expr_t *e1, expr_t *e2);
|
expr_t *assign_expr (expr_t *e1, expr_t *e2);
|
||||||
expr_t *cast_expr (struct type_s *t, expr_t *e);
|
expr_t *cast_expr (struct type_s *t, expr_t *e);
|
||||||
|
|
||||||
|
|
|
@ -2526,6 +2526,46 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t)
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expr_t *
|
||||||
|
build_if_statement (expr_t *test, expr_t *s1, expr_t *s2)
|
||||||
|
{
|
||||||
|
int line = pr.source_line;
|
||||||
|
string_t file = pr.source_file;
|
||||||
|
expr_t *if_expr;
|
||||||
|
expr_t *tl = new_label_expr ();
|
||||||
|
expr_t *fl = new_label_expr ();
|
||||||
|
|
||||||
|
pr.source_line = test->line;
|
||||||
|
pr.source_file = test->file;
|
||||||
|
|
||||||
|
if_expr = new_block_expr ();
|
||||||
|
|
||||||
|
test = convert_bool (test, 1);
|
||||||
|
if (test->type != ex_error) {
|
||||||
|
backpatch (test->e.bool.true_list, tl);
|
||||||
|
backpatch (test->e.bool.false_list, fl);
|
||||||
|
append_expr (test->e.bool.e, tl);
|
||||||
|
append_expr (if_expr, test);
|
||||||
|
}
|
||||||
|
append_expr (if_expr, s1);
|
||||||
|
|
||||||
|
if (s2) {
|
||||||
|
expr_t *nl = new_label_expr ();
|
||||||
|
append_expr (if_expr, new_unary_expr ('g', nl));
|
||||||
|
|
||||||
|
append_expr (if_expr, fl);
|
||||||
|
append_expr (if_expr, s2);
|
||||||
|
append_expr (if_expr, nl);
|
||||||
|
} else {
|
||||||
|
append_expr (if_expr, fl);
|
||||||
|
}
|
||||||
|
|
||||||
|
pr.source_line = line;
|
||||||
|
pr.source_file = file;
|
||||||
|
|
||||||
|
return if_expr;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
is_indirect (expr_t *e)
|
is_indirect (expr_t *e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue