mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +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;
|
expr_t *earg;
|
||||||
opcode_t *op;
|
opcode_t *op;
|
||||||
int count = 0, ind;
|
int count = 0, ind;
|
||||||
|
def_t *args[MAX_PARMS];
|
||||||
|
|
||||||
for (earg = e->e.expr.e2; earg; earg = earg->next)
|
for (earg = e->e.expr.e2; earg; earg = earg->next)
|
||||||
count++;
|
count++;
|
||||||
ind = count;
|
ind = count;
|
||||||
for (earg = e->e.expr.e2; earg; earg = earg->next) {
|
for (earg = e->e.expr.e2; earg; earg = earg->next) {
|
||||||
ind--;
|
ind--;
|
||||||
parm = def_parms[ind];
|
args[ind] = PR_GetTempDef (types[get_type (earg)], pr_scope);
|
||||||
parm.type = types[get_type (earg)];
|
arg = emit_sub_expr (earg, args[ind]);
|
||||||
arg = emit_sub_expr (earg, &parm);
|
|
||||||
if (earg->type != ex_expr && earg->type != ex_uexpr) {
|
if (earg->type != ex_expr && earg->type != ex_uexpr) {
|
||||||
op = PR_Opcode_Find ("=", 5, arg, &parm, &parm);
|
op = PR_Opcode_Find ("=", 5, arg, args[ind], args[ind]);
|
||||||
emit_statement (e->line, op, arg, &parm, 0);
|
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);
|
op = PR_Opcode_Find (va ("<CALL%d>", count), -1, &def_function, &def_void, &def_void);
|
||||||
emit_statement (e->line, op, func, 0, 0);
|
emit_statement (e->line, op, func, 0, 0);
|
||||||
|
|
||||||
def_ret.type = func->type->aux_type;
|
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);
|
op = PR_Opcode_Find ("=", 5, dest, &def_ret, &def_ret);
|
||||||
emit_statement (e->line, op, &def_ret, dest, 0);
|
emit_statement (e->line, op, &def_ret, dest, 0);
|
||||||
return dest;
|
return dest;
|
||||||
} else {
|
} else
|
||||||
return &def_ret;
|
return &def_ret;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def_t *
|
def_t *
|
||||||
|
|
|
@ -10,6 +10,7 @@ float snafu = 2;
|
||||||
float negative = -------2;
|
float negative = -------2;
|
||||||
|
|
||||||
void () eek;
|
void () eek;
|
||||||
|
float (float a, float b) boing;
|
||||||
|
|
||||||
float () main =
|
float () main =
|
||||||
{/*
|
{/*
|
||||||
|
@ -33,7 +34,7 @@ float () main =
|
||||||
print (buffer);
|
print (buffer);
|
||||||
} while (read_result == 1024);
|
} while (read_result == 1024);
|
||||||
close (handle);
|
close (handle);
|
||||||
eek ();*/
|
eek ();
|
||||||
traceon();
|
traceon();
|
||||||
local float foo = 0;
|
local float foo = 0;
|
||||||
foo += 1;
|
foo += 1;
|
||||||
|
@ -49,7 +50,10 @@ float () main =
|
||||||
bar = 12 % 5;
|
bar = 12 % 5;
|
||||||
bar %= 3;
|
bar %= 3;
|
||||||
foo %= 5;
|
foo %= 5;
|
||||||
return foo;
|
return foo;*/
|
||||||
|
traceon ();
|
||||||
|
boing (boing (1, 2), boing (3, 4));
|
||||||
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
float () baz =
|
float () baz =
|
||||||
|
@ -88,6 +92,11 @@ void () blarg =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float (float a, float b) boing =
|
||||||
|
{
|
||||||
|
return a + b;
|
||||||
|
};
|
||||||
|
|
||||||
float (float baz) test_int =
|
float (float baz) test_int =
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue