diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-06 10:03:45 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-06 10:03:45 -0200 |
commit | 617be660158490c7f6558e82d9be2c667c48d9a4 (patch) | |
tree | 27c0c29cb550d576cef2b4953ff4c4622f852503 /ldo.c | |
parent | f356eb010b6785cf22e8d5f1d4f7761e0789ae51 (diff) | |
download | lua-617be660158490c7f6558e82d9be2c667c48d9a4.tar.gz lua-617be660158490c7f6558e82d9be2c667c48d9a4.tar.bz2 lua-617be660158490c7f6558e82d9be2c667c48d9a4.zip |
better control (and error recovery) for begin/end blocks
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.56 1999/12/02 16:41:29 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.57 1999/12/06 11:43:58 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 | */ |
@@ -243,12 +243,13 @@ void lua_error (lua_State *L, const char *s) { | |||
243 | 243 | ||
244 | 244 | ||
245 | /* | 245 | /* |
246 | ** Execute a protected call. Assumes that function is at L->Cstack.base and | 246 | ** Execute a protected call. Assumes that function is at Cstack.base and |
247 | ** parameters are on top of it. Leave nResults on the stack. | 247 | ** parameters are on top of it. |
248 | */ | 248 | */ |
249 | int luaD_protectedrun (lua_State *L) { | 249 | int luaD_protectedrun (lua_State *L) { |
250 | struct lua_longjmp myErrorJmp; | 250 | struct lua_longjmp myErrorJmp; |
251 | volatile StkId base = L->Cstack.base; | 251 | volatile StkId base = L->Cstack.base; |
252 | volatile int numCblocks = L->numCblocks; | ||
252 | volatile int status; | 253 | volatile int status; |
253 | struct lua_longjmp *volatile oldErr = L->errorJmp; | 254 | struct lua_longjmp *volatile oldErr = L->errorJmp; |
254 | L->errorJmp = &myErrorJmp; | 255 | L->errorJmp = &myErrorJmp; |
@@ -262,6 +263,7 @@ int luaD_protectedrun (lua_State *L) { | |||
262 | else { /* an error occurred: restore the stack */ | 263 | else { /* an error occurred: restore the stack */ |
263 | L->Cstack.num = 0; /* no results */ | 264 | L->Cstack.num = 0; /* no results */ |
264 | L->top = L->Cstack.base = L->Cstack.lua2C = base; | 265 | L->top = L->Cstack.base = L->Cstack.lua2C = base; |
266 | L->numCblocks = numCblocks; | ||
265 | restore_stack_limit(L); | 267 | restore_stack_limit(L); |
266 | status = 1; | 268 | status = 1; |
267 | } | 269 | } |
@@ -276,6 +278,7 @@ int luaD_protectedrun (lua_State *L) { | |||
276 | static int protectedparser (lua_State *L, ZIO *z, int bin) { | 278 | static int protectedparser (lua_State *L, ZIO *z, int bin) { |
277 | struct lua_longjmp myErrorJmp; | 279 | struct lua_longjmp myErrorJmp; |
278 | volatile StkId base = L->Cstack.base; | 280 | volatile StkId base = L->Cstack.base; |
281 | volatile int numCblocks = L->numCblocks; | ||
279 | volatile int status; | 282 | volatile int status; |
280 | TProtoFunc *volatile tf; | 283 | TProtoFunc *volatile tf; |
281 | struct lua_longjmp *volatile oldErr = L->errorJmp; | 284 | struct lua_longjmp *volatile oldErr = L->errorJmp; |
@@ -288,6 +291,7 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) { | |||
288 | else { /* an error occurred: restore Cstack and top */ | 291 | else { /* an error occurred: restore Cstack and top */ |
289 | L->Cstack.num = 0; /* no results */ | 292 | L->Cstack.num = 0; /* no results */ |
290 | L->top = L->Cstack.base = L->Cstack.lua2C = base; | 293 | L->top = L->Cstack.base = L->Cstack.lua2C = base; |
294 | L->numCblocks = numCblocks; | ||
291 | tf = NULL; | 295 | tf = NULL; |
292 | status = 1; | 296 | status = 1; |
293 | } | 297 | } |