Move error handling in setupFuncall above the stack frame creation.
The error properly belongs to the enclosing scope, not the called (non-)function. This bug was fixed a few months back in my private tree, but Melchior just discovered that the new Concorde scripts tickle it. I really need to re-synchronize SimGear with my own Nasal tree...
This commit is contained in:
parent
b293639b76
commit
6a6cc22e9c
@ -150,6 +150,13 @@ void naGarbageCollect()
|
|||||||
|
|
||||||
void setupFuncall(struct Context* ctx, naRef func, naRef args)
|
void setupFuncall(struct Context* ctx, naRef func, naRef args)
|
||||||
{
|
{
|
||||||
|
if(!IS_FUNC(func) ||
|
||||||
|
!(IS_CCODE(func.ref.ptr.func->code) ||
|
||||||
|
IS_CODE(func.ref.ptr.func->code)))
|
||||||
|
{
|
||||||
|
ERR(ctx, "function/method call invoked on uncallable object");
|
||||||
|
}
|
||||||
|
|
||||||
struct Frame* f;
|
struct Frame* f;
|
||||||
f = &(ctx->fStack[ctx->fTop++]);
|
f = &(ctx->fStack[ctx->fTop++]);
|
||||||
f->func = func;
|
f->func = func;
|
||||||
@ -159,17 +166,12 @@ void setupFuncall(struct Context* ctx, naRef func, naRef args)
|
|||||||
|
|
||||||
DBG(printf("Entering frame %d\n", ctx->fTop-1);)
|
DBG(printf("Entering frame %d\n", ctx->fTop-1);)
|
||||||
|
|
||||||
if(!IS_REF(func))
|
|
||||||
ERR(ctx, "function/method call invoked on uncallable object");
|
|
||||||
|
|
||||||
f->args = args;
|
f->args = args;
|
||||||
if(IS_CCODE(func.ref.ptr.func->code)) {
|
if(IS_CCODE(func.ref.ptr.func->code)) {
|
||||||
f->locals = naNil();
|
f->locals = naNil();
|
||||||
} else if(IS_CODE(func.ref.ptr.func->code)) {
|
} else if(IS_CODE(func.ref.ptr.func->code)) {
|
||||||
f->locals = naNewHash(ctx);
|
f->locals = naNewHash(ctx);
|
||||||
naHash_set(f->locals, ctx->argRef, args);
|
naHash_set(f->locals, ctx->argRef, args);
|
||||||
} else {
|
|
||||||
ERR(ctx, "function/method call invoked on uncallable object");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user