From: andy Date: Tue, 25 Jan 2005 22:37:22 +0000 (+0000) Subject: Move error handling in setupFuncall above the stack frame creation. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6a6cc22e9cd67ea684d3317504a6468629afd0ac;p=simgear.git 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... --- diff --git a/simgear/nasal/code.c b/simgear/nasal/code.c index 02829f71..374b8f32 100644 --- a/simgear/nasal/code.c +++ b/simgear/nasal/code.c @@ -150,6 +150,13 @@ void naGarbageCollect() 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; f = &(ctx->fStack[ctx->fTop++]); 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);) - if(!IS_REF(func)) - ERR(ctx, "function/method call invoked on uncallable object"); - f->args = args; if(IS_CCODE(func.ref.ptr.func->code)) { f->locals = naNil(); } else if(IS_CODE(func.ref.ptr.func->code)) { f->locals = naNewHash(ctx); naHash_set(f->locals, ctx->argRef, args); - } else { - ERR(ctx, "function/method call invoked on uncallable object"); } }