mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-29 20:20:43 +00:00
emit.c:
implement % for v6 code. hacky, but it works :) (Closes: #29) expr.c: emit the body of a block expresion before emitting its result (needed for v6 %)
This commit is contained in:
parent
1e5402a30a
commit
308ff7163f
2 changed files with 24 additions and 1 deletions
|
@ -384,9 +384,10 @@ emit_sub_expr (expr_t *e, def_t *dest)
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case ex_block:
|
case ex_block:
|
||||||
if (e->e.block.result) {
|
if (e->e.block.result) {
|
||||||
d = emit_sub_expr (e->e.block.result, dest);
|
expr_t *res = e->e.block.result;
|
||||||
for (e = e->e.block.head; e; e = e->next)
|
for (e = e->e.block.head; e; e = e->next)
|
||||||
emit_expr (e);
|
emit_expr (e);
|
||||||
|
d = emit_sub_expr (res, dest);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ex_name:
|
case ex_name:
|
||||||
|
|
|
@ -1439,6 +1439,28 @@ binary_expr (int op, expr_t *e1, expr_t *e2)
|
||||||
if (!type)
|
if (!type)
|
||||||
error (e1, "internal error");
|
error (e1, "internal error");
|
||||||
|
|
||||||
|
if (options.code.progsversion == PROG_ID_VERSION) {
|
||||||
|
switch (op) {
|
||||||
|
case '%':
|
||||||
|
{
|
||||||
|
expr_t *tmp1, *tmp2;
|
||||||
|
e = new_block_expr ();
|
||||||
|
tmp1 = new_temp_def_expr (&type_float);
|
||||||
|
tmp2 = new_temp_def_expr (&type_float);
|
||||||
|
e2 = binary_expr ('&', e2, new_float_expr (-1.0));
|
||||||
|
e1 = binary_expr ('&', e1, new_float_expr (-1.0));
|
||||||
|
append_expr (e, assign_expr (tmp1, e2));
|
||||||
|
append_expr (e, assign_expr (tmp2,
|
||||||
|
binary_expr ('/', e1, tmp1)));
|
||||||
|
e2 = binary_expr ('&', tmp2, new_float_expr (-1.0));
|
||||||
|
e->e.block.result = binary_expr ('-', tmp2, e2);
|
||||||
|
e2 = e;
|
||||||
|
e1 = tmp1;
|
||||||
|
op = '*';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
e = new_binary_expr (op, e1, e2);
|
e = new_binary_expr (op, e1, e2);
|
||||||
e->e.expr.type = type;
|
e->e.expr.type = type;
|
||||||
return e;
|
return e;
|
||||||
|
|
Loading…
Reference in a new issue