diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-12 16:07:30 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-12 16:07:30 -0300 |
| commit | fa3113ffbf4455871baf1d1d9d48679a17e6f3e5 (patch) | |
| tree | ea9c4c8ba1427b1e6483a7fc4a448760585ae815 | |
| parent | d94bb6c273d05005504be78f2caab2451aeb2cee (diff) | |
| download | lua-fa3113ffbf4455871baf1d1d9d48679a17e6f3e5.tar.gz lua-fa3113ffbf4455871baf1d1d9d48679a17e6f3e5.tar.bz2 lua-fa3113ffbf4455871baf1d1d9d48679a17e6f3e5.zip | |
cleaner way to handle bit CIST_OAH (with auxiliar macros)
| -rw-r--r-- | lapi.c | 7 | ||||
| -rw-r--r-- | ldo.c | 4 | ||||
| -rw-r--r-- | lstate.h | 21 |
3 files changed, 16 insertions, 16 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 2.216 2014/06/10 18:51:21 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.217 2014/06/10 19:13:26 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -970,10 +970,7 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, | |||
| 970 | ci->extra = savestack(L, c.func); | 970 | ci->extra = savestack(L, c.func); |
| 971 | ci->u.c.old_errfunc = L->errfunc; | 971 | ci->u.c.old_errfunc = L->errfunc; |
| 972 | L->errfunc = func; | 972 | L->errfunc = func; |
| 973 | if (L->allowhook) /* save original value of 'allowhook' */ | 973 | setoah(ci->callstatus, L->allowhook); /* save value of 'allowhook' */ |
| 974 | ci->callstatus |= CIST_OAH; | ||
| 975 | else | ||
| 976 | ci->callstatus &= ~CIST_OAH; | ||
| 977 | ci->callstatus |= CIST_YPCALL; /* function can do error recovery */ | 974 | ci->callstatus |= CIST_YPCALL; /* function can do error recovery */ |
| 978 | luaD_call(L, c.func, nresults, 1); /* do the call */ | 975 | luaD_call(L, c.func, nresults, 1); /* do the call */ |
| 979 | ci->callstatus &= ~CIST_YPCALL; | 976 | ci->callstatus &= ~CIST_YPCALL; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.120 2014/06/10 19:18:50 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.121 2014/06/11 16:01:55 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 | */ |
| @@ -492,7 +492,7 @@ static int recover (lua_State *L, int status) { | |||
| 492 | luaF_close(L, oldtop); | 492 | luaF_close(L, oldtop); |
| 493 | seterrorobj(L, status, oldtop); | 493 | seterrorobj(L, status, oldtop); |
| 494 | L->ci = ci; | 494 | L->ci = ci; |
| 495 | L->allowhook = (ci->callstatus & CIST_OAH); | 495 | L->allowhook = getoah(ci->callstatus); /* restore original 'allowhook' */ |
| 496 | L->nny = 0; /* should be zero to be yieldable */ | 496 | L->nny = 0; /* should be zero to be yieldable */ |
| 497 | luaD_shrinkstack(L); | 497 | luaD_shrinkstack(L); |
| 498 | L->errfunc = ci->u.c.old_errfunc; | 498 | L->errfunc = ci->u.c.old_errfunc; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.h,v 2.105 2014/06/10 18:51:21 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.106 2014/06/10 19:18:50 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -80,18 +80,21 @@ typedef struct CallInfo { | |||
| 80 | /* | 80 | /* |
| 81 | ** Bits in CallInfo status | 81 | ** Bits in CallInfo status |
| 82 | */ | 82 | */ |
| 83 | #define CIST_LUA (1<<0) /* call is running a Lua function */ | 83 | #define CIST_OAH (1<<0) /* original value of 'allowhook' */ |
| 84 | #define CIST_HOOKED (1<<1) /* call is running a debug hook */ | 84 | #define CIST_LUA (1<<1) /* call is running a Lua function */ |
| 85 | #define CIST_REENTRY (1<<2) /* call is running on same invocation of | 85 | #define CIST_HOOKED (1<<2) /* call is running a debug hook */ |
| 86 | #define CIST_REENTRY (1<<3) /* call is running on same invocation of | ||
| 86 | luaV_execute of previous call */ | 87 | luaV_execute of previous call */ |
| 87 | #define CIST_YPCALL (1<<3) /* call is a yieldable protected call */ | 88 | #define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ |
| 88 | #define CIST_TAIL (1<<4) /* call was tail called */ | 89 | #define CIST_TAIL (1<<5) /* call was tail called */ |
| 89 | #define CIST_HOOKYIELD (1<<5) /* last hook called yielded */ | 90 | #define CIST_HOOKYIELD (1<<6) /* last hook called yielded */ |
| 90 | #define CIST_OAH (1<<6) /* original value of 'allowhook' */ | ||
| 91 | |||
| 92 | 91 | ||
| 93 | #define isLua(ci) ((ci)->callstatus & CIST_LUA) | 92 | #define isLua(ci) ((ci)->callstatus & CIST_LUA) |
| 94 | 93 | ||
| 94 | /* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ | ||
| 95 | #define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) | ||
| 96 | #define getoah(st) ((st) & CIST_OAH) | ||
| 97 | |||
| 95 | 98 | ||
| 96 | /* | 99 | /* |
| 97 | ** `global state', shared by all threads of this state | 100 | ** `global state', shared by all threads of this state |
