lock/unlock may use L + better structure for internal debug stuff

This commit is contained in:
Roberto Ierusalimschy
2001-02-02 13:13:05 -02:00
parent 8823f371a2
commit 426d3e43bd
12 changed files with 213 additions and 224 deletions

24
ldo.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: ldo.c,v 1.119 2001/01/29 19:34:02 roberto Exp roberto $
** $Id: ldo.c,v 1.120 2001/02/01 17:40:48 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -94,9 +94,9 @@ static void dohook (lua_State *L, lua_Debug *ar, lua_Hook hook) {
StkId old_top = L->Cbase = L->top;
luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
L->allowhooks = 0; /* cannot call hooks inside a hook */
LUA_UNLOCK;
LUA_UNLOCK(L);
(*hook)(L, ar);
LUA_LOCK;
LUA_LOCK(L);
lua_assert(L->allowhooks == 0);
L->allowhooks = 1;
L->top = old_top;
@@ -135,9 +135,9 @@ static StkId callCclosure (lua_State *L, const struct Closure *cl, StkId base) {
luaD_checkstack(L, nup+LUA_MINSTACK); /* ensure minimum stack size */
for (n=0; n<nup; n++) /* copy upvalues as extra arguments */
setobj(L->top++, &cl->upvalue[n]);
LUA_UNLOCK;
LUA_UNLOCK(L);
n = (*cl->f.c)(L); /* do the actual call */
LUA_LOCK;
LUA_LOCK(L);
L->Cbase = old_Cbase; /* restore old C base */
return L->top - n; /* return index of first result */
}
@@ -219,13 +219,13 @@ LUA_API int lua_call (lua_State *L, int nargs, int nresults) {
StkId func;
struct CallS c;
int status;
LUA_LOCK;
LUA_LOCK(L);
func = L->top - (nargs+1); /* function to be called */
c.func = func; c.nresults = nresults;
status = luaD_runprotected(L, f_call, &c);
if (status != 0) /* an error occurred? */
L->top = func; /* remove parameters from the stack */
LUA_UNLOCK;
LUA_UNLOCK(L);
return status;
}
@@ -233,23 +233,23 @@ LUA_API int lua_call (lua_State *L, int nargs, int nresults) {
/*
** Execute a protected parser.
*/
struct ParserS { /* data to `f_parser' */
struct SParser { /* data to `f_parser' */
ZIO *z;
int bin;
};
static void f_parser (lua_State *L, void *ud) {
struct ParserS *p = (struct ParserS *)ud;
struct SParser *p = (struct SParser *)ud;
Proto *tf = p->bin ? luaU_undump(L, p->z) : luaY_parser(L, p->z);
luaV_Lclosure(L, tf, 0);
}
static int protectedparser (lua_State *L, ZIO *z, int bin) {
struct ParserS p;
struct SParser p;
mem_int old_blocks;
int status;
LUA_LOCK;
LUA_LOCK(L);
p.z = z; p.bin = bin;
luaC_checkGC(L);
old_blocks = G(L)->nblocks;
@@ -261,7 +261,7 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
}
else if (status == LUA_ERRRUN) /* an error occurred: correct error code */
status = LUA_ERRSYNTAX;
LUA_UNLOCK;
LUA_UNLOCK(L);
return status;
}