diff options
Diffstat (limited to 'lib/lua')
-rw-r--r-- | lib/lua/include/lua.h | 4 | ||||
-rw-r--r-- | lib/lua/includes/lstate.h | 11 | ||||
-rw-r--r-- | lib/lua/src/ldo.c | 9 | ||||
-rw-r--r-- | lib/lua/src/lvm.c | 6 |
4 files changed, 24 insertions, 6 deletions
diff --git a/lib/lua/include/lua.h b/lib/lua/include/lua.h index f525a30..109b16e 100644 --- a/lib/lua/include/lua.h +++ b/lib/lua/include/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.3 2003-12-11 16:53:28 pixel Exp $ +** $Id: lua.h,v 1.4 2004-07-23 13:08:23 pixel Exp $ ** Lua - An Extensible Extension Language ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil ** http://www.lua.org mailto:info@lua.org @@ -222,6 +222,8 @@ LUA_API int lua_next (lua_State *L, int idx); LUA_API void lua_concat (lua_State *L, int n); +LUA_API void lua_break (lua_State *L); + /* diff --git a/lib/lua/includes/lstate.h b/lib/lua/includes/lstate.h index 6cebdfb..191cb45 100644 --- a/lib/lua/includes/lstate.h +++ b/lib/lua/includes/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 1.2 2003-12-11 16:53:29 pixel Exp $ +** $Id: lstate.h,v 1.3 2004-07-23 13:08:23 pixel Exp $ ** Global State ** See Copyright Notice in lua.h */ @@ -24,12 +24,16 @@ ** or when reading immutable fields from global objects ** (such as string values and udata values). */ + +void do_lua_lock(lua_State *); +void do_lua_unlock(lua_State *); + #ifndef lua_lock -#define lua_lock(L) ((void) 0) +#define lua_lock(L) do_lua_lock(L) #endif #ifndef lua_unlock -#define lua_unlock(L) ((void) 0) +#define lua_unlock(L) do_lua_unlock(L) #endif @@ -100,6 +104,7 @@ typedef struct CallInfo { #define CI_CALLING (1<<2) #define CI_SAVEDPC (1<<3) /* 1 if `savedpc' is updated */ #define CI_YIELD (1<<4) /* 1 if thread is suspended */ +#define CI_BREAK (1<<5) /* 1 if user break */ #define ci_func(ci) (clvalue((ci)->base - 1)) diff --git a/lib/lua/src/ldo.c b/lib/lua/src/ldo.c index 2198c58..44bba83 100644 --- a/lib/lua/src/ldo.c +++ b/lib/lua/src/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 1.2 2003-12-11 16:53:30 pixel Exp $ +** $Id: ldo.c,v 1.3 2004-07-23 13:08:23 pixel Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -391,6 +391,13 @@ LUA_API int lua_yield (lua_State *L, int nresults) { return -1; } +LUA_API void lua_break (lua_State *L) { + CallInfo * ci; + lua_lock(L); + ci = L->ci; + ci->state |= CI_BREAK; + lua_unlock(L); +} int luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef) { diff --git a/lib/lua/src/lvm.c b/lib/lua/src/lvm.c index bc40f5c..3a8a974 100644 --- a/lib/lua/src/lvm.c +++ b/lib/lua/src/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 1.2 2003-12-11 16:53:30 pixel Exp $ +** $Id: lvm.c,v 1.3 2004-07-23 13:08:23 pixel Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -421,6 +421,10 @@ StkId luaV_execute (lua_State *L) { L->ci->state = CI_YIELD | CI_SAVEDPC; return NULL; } + if (L->ci->state & CI_BREAK) { /* did hook break? */ + luaG_runerror(L, "breaking"); + L->ci->state &= ~CI_BREAK; + } } /* warning!! several calls may realloc the stack and invalidate `ra' */ base = L->base; |