aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-02 13:13:05 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-02 13:13:05 -0200
commit426d3e43bdec4b1ab2b0aed1844396c27f64872f (patch)
tree659b73e1e9720fb85c66a481b476c96671eef734 /ldo.c
parent8823f371a2a63f634121a0c16cb1d02e5ce9f5c5 (diff)
downloadlua-426d3e43bdec4b1ab2b0aed1844396c27f64872f.tar.gz
lua-426d3e43bdec4b1ab2b0aed1844396c27f64872f.tar.bz2
lua-426d3e43bdec4b1ab2b0aed1844396c27f64872f.zip
lock/unlock may use L + better structure for internal debug stuff
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/ldo.c b/ldo.c
index d98ab5bd..296352fe 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.119 2001/01/29 19:34:02 roberto Exp roberto $ 2** $Id: ldo.c,v 1.120 2001/02/01 17:40:48 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*/
@@ -94,9 +94,9 @@ static void dohook (lua_State *L, lua_Debug *ar, lua_Hook hook) {
94 StkId old_top = L->Cbase = L->top; 94 StkId old_top = L->Cbase = L->top;
95 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ 95 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
96 L->allowhooks = 0; /* cannot call hooks inside a hook */ 96 L->allowhooks = 0; /* cannot call hooks inside a hook */
97 LUA_UNLOCK; 97 LUA_UNLOCK(L);
98 (*hook)(L, ar); 98 (*hook)(L, ar);
99 LUA_LOCK; 99 LUA_LOCK(L);
100 lua_assert(L->allowhooks == 0); 100 lua_assert(L->allowhooks == 0);
101 L->allowhooks = 1; 101 L->allowhooks = 1;
102 L->top = old_top; 102 L->top = old_top;
@@ -135,9 +135,9 @@ static StkId callCclosure (lua_State *L, const struct Closure *cl, StkId base) {
135 luaD_checkstack(L, nup+LUA_MINSTACK); /* ensure minimum stack size */ 135 luaD_checkstack(L, nup+LUA_MINSTACK); /* ensure minimum stack size */
136 for (n=0; n<nup; n++) /* copy upvalues as extra arguments */ 136 for (n=0; n<nup; n++) /* copy upvalues as extra arguments */
137 setobj(L->top++, &cl->upvalue[n]); 137 setobj(L->top++, &cl->upvalue[n]);
138 LUA_UNLOCK; 138 LUA_UNLOCK(L);
139 n = (*cl->f.c)(L); /* do the actual call */ 139 n = (*cl->f.c)(L); /* do the actual call */
140 LUA_LOCK; 140 LUA_LOCK(L);
141 L->Cbase = old_Cbase; /* restore old C base */ 141 L->Cbase = old_Cbase; /* restore old C base */
142 return L->top - n; /* return index of first result */ 142 return L->top - n; /* return index of first result */
143} 143}
@@ -219,13 +219,13 @@ LUA_API int lua_call (lua_State *L, int nargs, int nresults) {
219 StkId func; 219 StkId func;
220 struct CallS c; 220 struct CallS c;
221 int status; 221 int status;
222 LUA_LOCK; 222 LUA_LOCK(L);
223 func = L->top - (nargs+1); /* function to be called */ 223 func = L->top - (nargs+1); /* function to be called */
224 c.func = func; c.nresults = nresults; 224 c.func = func; c.nresults = nresults;
225 status = luaD_runprotected(L, f_call, &c); 225 status = luaD_runprotected(L, f_call, &c);
226 if (status != 0) /* an error occurred? */ 226 if (status != 0) /* an error occurred? */
227 L->top = func; /* remove parameters from the stack */ 227 L->top = func; /* remove parameters from the stack */
228 LUA_UNLOCK; 228 LUA_UNLOCK(L);
229 return status; 229 return status;
230} 230}
231 231
@@ -233,23 +233,23 @@ LUA_API int lua_call (lua_State *L, int nargs, int nresults) {
233/* 233/*
234** Execute a protected parser. 234** Execute a protected parser.
235*/ 235*/
236struct ParserS { /* data to `f_parser' */ 236struct SParser { /* data to `f_parser' */
237 ZIO *z; 237 ZIO *z;
238 int bin; 238 int bin;
239}; 239};
240 240
241static void f_parser (lua_State *L, void *ud) { 241static void f_parser (lua_State *L, void *ud) {
242 struct ParserS *p = (struct ParserS *)ud; 242 struct SParser *p = (struct SParser *)ud;
243 Proto *tf = p->bin ? luaU_undump(L, p->z) : luaY_parser(L, p->z); 243 Proto *tf = p->bin ? luaU_undump(L, p->z) : luaY_parser(L, p->z);
244 luaV_Lclosure(L, tf, 0); 244 luaV_Lclosure(L, tf, 0);
245} 245}
246 246
247 247
248static int protectedparser (lua_State *L, ZIO *z, int bin) { 248static int protectedparser (lua_State *L, ZIO *z, int bin) {
249 struct ParserS p; 249 struct SParser p;
250 mem_int old_blocks; 250 mem_int old_blocks;
251 int status; 251 int status;
252 LUA_LOCK; 252 LUA_LOCK(L);
253 p.z = z; p.bin = bin; 253 p.z = z; p.bin = bin;
254 luaC_checkGC(L); 254 luaC_checkGC(L);
255 old_blocks = G(L)->nblocks; 255 old_blocks = G(L)->nblocks;
@@ -261,7 +261,7 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
261 } 261 }
262 else if (status == LUA_ERRRUN) /* an error occurred: correct error code */ 262 else if (status == LUA_ERRRUN) /* an error occurred: correct error code */
263 status = LUA_ERRSYNTAX; 263 status = LUA_ERRSYNTAX;
264 LUA_UNLOCK; 264 LUA_UNLOCK(L);
265 return status; 265 return status;
266} 266}
267 267