mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
use memcpy instead of ugly casts to transfer locals
This commit is contained in:
parent
1e6d69e2be
commit
ce014fc5c7
1 changed files with 11 additions and 12 deletions
|
@ -285,23 +285,23 @@ PR_EnterFunction (progs_t * pr, dfunction_t *f)
|
||||||
if (pr->pr_depth >= MAX_STACK_DEPTH)
|
if (pr->pr_depth >= MAX_STACK_DEPTH)
|
||||||
PR_RunError (pr, "stack overflow");
|
PR_RunError (pr, "stack overflow");
|
||||||
|
|
||||||
// save off any locals that the new function steps on
|
// save off any locals that the new function steps on
|
||||||
c = f->locals;
|
c = f->locals;
|
||||||
if (pr->localstack_used + c > LOCALSTACK_SIZE)
|
if (pr->localstack_used + c > LOCALSTACK_SIZE)
|
||||||
PR_RunError (pr, "PR_ExecuteProgram: locals stack overflow\n");
|
PR_RunError (pr, "PR_ExecuteProgram: locals stack overflow\n");
|
||||||
|
|
||||||
for (i = 0; i < c; i++)
|
memcpy (&pr->localstack[pr->localstack_used],
|
||||||
pr->localstack[pr->localstack_used + i] =
|
&pr->pr_globals[f->parm_start],
|
||||||
((int *) pr->pr_globals)[f->parm_start + i];
|
sizeof (pr_type_t) * c);
|
||||||
pr->localstack_used += c;
|
pr->localstack_used += c;
|
||||||
|
|
||||||
// copy parameters
|
// copy parameters
|
||||||
o = f->parm_start;
|
o = f->parm_start;
|
||||||
for (i = 0; i < f->numparms; i++) {
|
for (i = 0; i < f->numparms; i++) {
|
||||||
for (j = 0; j < f->parm_size[i]; j++) {
|
for (j = 0; j < f->parm_size[i]; j++) {
|
||||||
|
memcpy (&pr->pr_globals[o],
|
||||||
((int *) pr->pr_globals)[o] =
|
&pr->pr_globals[OFS_PARM0 + i * 3 + j],
|
||||||
((int *) pr->pr_globals)[OFS_PARM0 + i * 3 + j];
|
sizeof (pr_type_t));
|
||||||
o++;
|
o++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ PR_EnterFunction (progs_t * pr, dfunction_t *f)
|
||||||
int
|
int
|
||||||
PR_LeaveFunction (progs_t * pr)
|
PR_LeaveFunction (progs_t * pr)
|
||||||
{
|
{
|
||||||
int i, c;
|
int c;
|
||||||
|
|
||||||
if (pr->pr_depth <= 0)
|
if (pr->pr_depth <= 0)
|
||||||
PR_Error (pr, "prog stack underflow");
|
PR_Error (pr, "prog stack underflow");
|
||||||
|
@ -327,10 +327,9 @@ PR_LeaveFunction (progs_t * pr)
|
||||||
if (pr->localstack_used < 0)
|
if (pr->localstack_used < 0)
|
||||||
PR_RunError (pr, "PR_ExecuteProgram: locals stack underflow\n");
|
PR_RunError (pr, "PR_ExecuteProgram: locals stack underflow\n");
|
||||||
|
|
||||||
for (i = 0; i < c; i++)
|
memcpy (&pr->pr_globals[pr->pr_xfunction->parm_start],
|
||||||
|
&pr->localstack[pr->localstack_used],
|
||||||
((int *) pr->pr_globals)[pr->pr_xfunction->parm_start + i] =
|
sizeof (pr_type_t) * c);
|
||||||
pr->localstack[pr->localstack_used + i];
|
|
||||||
|
|
||||||
// up stack
|
// up stack
|
||||||
pr->pr_depth--;
|
pr->pr_depth--;
|
||||||
|
|
Loading…
Reference in a new issue