diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-21 16:22:58 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-21 16:22:58 -0200 |
commit | 609392ff2e02eb44fa48c8563faf5994fc55297c (patch) | |
tree | ae4d3a4094a795a3c04583895007f0d6119da52a /opcode.c | |
parent | 96ea2e0fb462789015824823801ba34782364b68 (diff) | |
download | lua-609392ff2e02eb44fa48c8563faf5994fc55297c.tar.gz lua-609392ff2e02eb44fa48c8563faf5994fc55297c.tar.bz2 lua-609392ff2e02eb44fa48c8563faf5994fc55297c.zip |
fallback for "call expression not a function" errors
Diffstat (limited to 'opcode.c')
-rw-r--r-- | opcode.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.18 1994/11/18 19:46:21 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.19 1994/11/21 13:30:15 roberto Exp $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -209,6 +209,20 @@ static int callC (lua_CFunction func, int base) | |||
209 | return firstResult; | 209 | return firstResult; |
210 | } | 210 | } |
211 | 211 | ||
212 | /* | ||
213 | ** Call the fallback for invalid functions (see do_call) | ||
214 | */ | ||
215 | static void call_funcFB (Object *func, int base, int nResults, int whereRes) | ||
216 | { | ||
217 | int i; | ||
218 | /* open space for first parameter (func) */ | ||
219 | for (i=top-stack; i>base; i--) | ||
220 | stack[i] = stack[i-1]; | ||
221 | top++; | ||
222 | stack[base] = *func; | ||
223 | do_call(&luaI_fallBacks[FB_FUNCTION].function, base, nResults, whereRes); | ||
224 | } | ||
225 | |||
212 | 226 | ||
213 | /* | 227 | /* |
214 | ** Call a function (C or Lua). The parameters must be on the stack, | 228 | ** Call a function (C or Lua). The parameters must be on the stack, |
@@ -224,9 +238,9 @@ static void do_call (Object *func, int base, int nResults, int whereRes) | |||
224 | else if (tag(func) == LUA_T_FUNCTION) | 238 | else if (tag(func) == LUA_T_FUNCTION) |
225 | firstResult = lua_execute(bvalue(func), base); | 239 | firstResult = lua_execute(bvalue(func), base); |
226 | else | 240 | else |
227 | { | 241 | { /* func is not a function */ |
228 | lua_reportbug ("call expression not a function"); | 242 | call_funcFB(func, base, nResults, whereRes); |
229 | return; /* to avoid warnings */ | 243 | return; |
230 | } | 244 | } |
231 | /* adjust the number of results */ | 245 | /* adjust the number of results */ |
232 | if (nResults != MULT_RET && top - (stack+firstResult) != nResults) | 246 | if (nResults != MULT_RET && top - (stack+firstResult) != nResults) |