From 6a6cc22e9cd67ea684d3317504a6468629afd0ac Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 25 Jan 2005 22:37:22 +0000 Subject: [PATCH] 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... --- simgear/nasal/code.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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"); } } -- 2.39.5