mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
start of the support for chained function calls. Actually, they
should work fine now, there's just some extra temp vars we want to remove before we can consider it "done" :)
This commit is contained in:
parent
b44fd6ab91
commit
caeb31e6ca
2 changed files with 29 additions and 10 deletions
|
@ -89,31 +89,41 @@ emit_function_call (expr_t *e, def_t *dest)
|
|||
expr_t *earg;
|
||||
opcode_t *op;
|
||||
int count = 0, ind;
|
||||
def_t *args[MAX_PARMS];
|
||||
|
||||
for (earg = e->e.expr.e2; earg; earg = earg->next)
|
||||
count++;
|
||||
ind = count;
|
||||
for (earg = e->e.expr.e2; earg; earg = earg->next) {
|
||||
ind--;
|
||||
parm = def_parms[ind];
|
||||
parm.type = types[get_type (earg)];
|
||||
arg = emit_sub_expr (earg, &parm);
|
||||
args[ind] = PR_GetTempDef (types[get_type (earg)], pr_scope);
|
||||
arg = emit_sub_expr (earg, args[ind]);
|
||||
if (earg->type != ex_expr && earg->type != ex_uexpr) {
|
||||
op = PR_Opcode_Find ("=", 5, arg, args[ind], args[ind]);
|
||||
emit_statement (e->line, op, arg, args[ind], 0);
|
||||
}
|
||||
}
|
||||
ind = count;
|
||||
for (; ind > 0; ind--) {
|
||||
ind--;
|
||||
arg = args[ind];
|
||||
parm = def_parms[ind];
|
||||
parm.type = arg->type;
|
||||
op = PR_Opcode_Find ("=", 5, arg, &parm, &parm);
|
||||
emit_statement (e->line, op, arg, &parm, 0);
|
||||
}
|
||||
}
|
||||
op = PR_Opcode_Find (va ("<CALL%d>", count), -1, &def_function, &def_void, &def_void);
|
||||
emit_statement (e->line, op, func, 0, 0);
|
||||
|
||||
def_ret.type = func->type->aux_type;
|
||||
if (dest) {
|
||||
if (def_ret.type->type != ev_void) {
|
||||
if (!dest)
|
||||
dest = PR_GetTempDef (def_ret.type, pr_scope);
|
||||
op = PR_Opcode_Find ("=", 5, dest, &def_ret, &def_ret);
|
||||
emit_statement (e->line, op, &def_ret, dest, 0);
|
||||
return dest;
|
||||
} else {
|
||||
} else
|
||||
return &def_ret;
|
||||
}
|
||||
}
|
||||
|
||||
def_t *
|
||||
|
|
|
@ -10,6 +10,7 @@ float snafu = 2;
|
|||
float negative = -------2;
|
||||
|
||||
void () eek;
|
||||
float (float a, float b) boing;
|
||||
|
||||
float () main =
|
||||
{/*
|
||||
|
@ -33,7 +34,7 @@ float () main =
|
|||
print (buffer);
|
||||
} while (read_result == 1024);
|
||||
close (handle);
|
||||
eek ();*/
|
||||
eek ();
|
||||
traceon();
|
||||
local float foo = 0;
|
||||
foo += 1;
|
||||
|
@ -49,7 +50,10 @@ float () main =
|
|||
bar = 12 % 5;
|
||||
bar %= 3;
|
||||
foo %= 5;
|
||||
return foo;
|
||||
return foo;*/
|
||||
traceon ();
|
||||
boing (boing (1, 2), boing (3, 4));
|
||||
return 0;
|
||||
};
|
||||
|
||||
float () baz =
|
||||
|
@ -88,6 +92,11 @@ void () blarg =
|
|||
}
|
||||
};
|
||||
|
||||
float (float a, float b) boing =
|
||||
{
|
||||
return a + b;
|
||||
};
|
||||
|
||||
float (float baz) test_int =
|
||||
{
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue