diff --git a/tools/qfcc/source/emit.c b/tools/qfcc/source/emit.c index 28d84068b..8b37d02b0 100644 --- a/tools/qfcc/source/emit.c +++ b/tools/qfcc/source/emit.c @@ -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, &parm, &parm); - emit_statement (e->line, op, arg, &parm, 0); + 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 ("", 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 * diff --git a/tools/qwaq/main.qc b/tools/qwaq/main.qc index 6a57039bd..fdf14c630 100644 --- a/tools/qwaq/main.qc +++ b/tools/qwaq/main.qc @@ -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;