From 61a150c500fd64d1eeae74f9abb6829721261d39 Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 23 Jul 2004 13:08:22 +0000 Subject: Adding some LUA features --- lib/lua/src/ldo.c | 9 ++++++++- lib/lua/src/lvm.c | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/lua/src') 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; -- cgit v1.2.3