[gamecode] Skip return ptr restore if depth changed

When calling a builtin, normally the return pointer needs to be
restored, but if the builtin changes the call depth (usually by
effecting "return foo()" as in support for objects, but possibly
setjmp/longjmp when they are implemented), then the return pointer must
not be restored. This gets vkgen past object allocation, but it dies
when trying to send messages to super. This appears to be a compiler
bug.
This commit is contained in:
Bill Currie 2022-01-31 16:51:46 +09:00
parent c5ae1ae13c
commit cabb53e693

View file

@ -452,9 +452,12 @@ PR_CallFunction (progs_t *pr, pr_func_t fnum, pr_type_t *return_ptr)
PR_GetString (pr, f->descriptor->name), f->func);
}
pr_type_t *saved_return = pr->pr_return;
int builtin_depth = pr->pr_depth;
pr->pr_return = return_ptr;
f->func (pr);
pr->pr_return = saved_return;
if (builtin_depth == pr->pr_depth) {
pr->pr_return = saved_return;
}
return 0;
} else {
PR_EnterFunction (pr, f);