diff options
| -rw-r--r-- | ldo.c | 16 |
1 files changed, 14 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.132 2014/11/02 19:19:04 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.133 2014/11/02 19:33:33 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -121,6 +121,9 @@ l_noret luaD_throw (lua_State *L, int errcode) { | |||
| 121 | } | 121 | } |
| 122 | else { /* no handler at all; abort */ | 122 | else { /* no handler at all; abort */ |
| 123 | if (g->panic) { /* panic function? */ | 123 | if (g->panic) { /* panic function? */ |
| 124 | seterrorobj(L, errcode, L->top); /* assume EXTRA_STACK */ | ||
| 125 | if (L->ci->top < L->top) | ||
| 126 | L->ci->top = L->top + 2; | ||
| 124 | lua_unlock(L); | 127 | lua_unlock(L); |
| 125 | g->panic(L); /* call it (last chance to jump out) */ | 128 | g->panic(L); /* call it (last chance to jump out) */ |
| 126 | } | 129 | } |
| @@ -283,12 +286,21 @@ static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { | |||
| 283 | } | 286 | } |
| 284 | 287 | ||
| 285 | 288 | ||
| 289 | /* | ||
| 290 | ** Check whether __call metafield of 'func' is a function. If so, put | ||
| 291 | ** it in stack below original 'func' so that 'luaD_precall' can call | ||
| 292 | ** it. Raise an error if __call metafield is not a function. (The | ||
| 293 | ** check 'luaD_checkstack' avoids problems of errors in tag methods, | ||
| 294 | ** because both tag methods and error messages may need EXTRA_STACK.) | ||
| 295 | */ | ||
| 286 | static StkId tryfuncTM (lua_State *L, StkId func) { | 296 | static StkId tryfuncTM (lua_State *L, StkId func) { |
| 287 | const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); | 297 | const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); |
| 288 | StkId p; | 298 | StkId p; |
| 289 | ptrdiff_t funcr = savestack(L, func); | 299 | ptrdiff_t funcr = savestack(L, func); |
| 290 | if (!ttisfunction(tm)) | 300 | if (!ttisfunction(tm)) { |
| 301 | luaD_checkstack(L, 1); | ||
| 291 | luaG_typeerror(L, func, "call"); | 302 | luaG_typeerror(L, func, "call"); |
| 303 | } | ||
| 292 | /* Open a hole inside the stack at 'func' */ | 304 | /* Open a hole inside the stack at 'func' */ |
| 293 | for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); | 305 | for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); |
| 294 | incr_top(L); | 306 | incr_top(L); |
