diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-08-22 16:58:29 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-08-22 16:58:29 -0300 |
commit | 23b79c5945023a661754e45c58595f89c84d4800 (patch) | |
tree | c96b90464cca1b6837cfb8a7cf928ed81bc0ffce /ldo.c | |
parent | 6fcd334ca0baa76a4509ff584aff3b146b43e027 (diff) | |
download | lua-23b79c5945023a661754e45c58595f89c84d4800.tar.gz lua-23b79c5945023a661754e45c58595f89c84d4800.tar.bz2 lua-23b79c5945023a661754e45c58595f89c84d4800.zip |
small changes to facilitate external C coroutines
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.29 2005/08/09 19:49:04 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.30 2005/08/22 18:54:49 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 | */ |
@@ -48,7 +48,7 @@ struct lua_longjmp { | |||
48 | }; | 48 | }; |
49 | 49 | ||
50 | 50 | ||
51 | static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { | 51 | void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { |
52 | switch (errcode) { | 52 | switch (errcode) { |
53 | case LUA_ERRMEM: { | 53 | case LUA_ERRMEM: { |
54 | setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); | 54 | setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); |
@@ -82,7 +82,7 @@ static void resetstack (lua_State *L, int status) { | |||
82 | L->ci = L->base_ci; | 82 | L->ci = L->base_ci; |
83 | L->base = L->ci->base; | 83 | L->base = L->ci->base; |
84 | luaF_close(L, L->base); /* close eventual pending closures */ | 84 | luaF_close(L, L->base); /* close eventual pending closures */ |
85 | seterrorobj(L, status, L->base); | 85 | luaD_seterrorobj(L, status, L->base); |
86 | L->nCcalls = 0; | 86 | L->nCcalls = 0; |
87 | L->allowhook = 1; | 87 | L->allowhook = 1; |
88 | restore_stack_limit(L); | 88 | restore_stack_limit(L); |
@@ -427,10 +427,11 @@ LUA_API int lua_resume (lua_State *L, int nargs) { | |||
427 | else if (L->ci != L->base_ci) | 427 | else if (L->ci != L->base_ci) |
428 | return resume_error(L, "cannot resume non-suspended coroutine"); | 428 | return resume_error(L, "cannot resume non-suspended coroutine"); |
429 | } | 429 | } |
430 | luai_userstateresume(L, nargs); | ||
430 | status = luaD_rawrunprotected(L, resume, L->top - nargs); | 431 | status = luaD_rawrunprotected(L, resume, L->top - nargs); |
431 | if (status != 0) { /* error? */ | 432 | if (status != 0) { /* error? */ |
432 | L->status = cast(lu_byte, status); /* mark thread as `dead' */ | 433 | L->status = cast(lu_byte, status); /* mark thread as `dead' */ |
433 | seterrorobj(L, status, L->top); | 434 | luaD_seterrorobj(L, status, L->top); |
434 | } | 435 | } |
435 | else | 436 | else |
436 | status = L->status; | 437 | status = L->status; |
@@ -440,9 +441,8 @@ LUA_API int lua_resume (lua_State *L, int nargs) { | |||
440 | 441 | ||
441 | 442 | ||
442 | LUA_API int lua_yield (lua_State *L, int nresults) { | 443 | LUA_API int lua_yield (lua_State *L, int nresults) { |
443 | CallInfo *ci; | 444 | luai_userstateyield(L, nresults); |
444 | lua_lock(L); | 445 | lua_lock(L); |
445 | ci = L->ci; | ||
446 | if (L->nCcalls > 0) | 446 | if (L->nCcalls > 0) |
447 | luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); | 447 | luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); |
448 | L->base = L->top - nresults; /* protect stack slots below */ | 448 | L->base = L->top - nresults; /* protect stack slots below */ |
@@ -464,7 +464,7 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u, | |||
464 | if (status != 0) { /* an error occurred? */ | 464 | if (status != 0) { /* an error occurred? */ |
465 | StkId oldtop = restorestack(L, old_top); | 465 | StkId oldtop = restorestack(L, old_top); |
466 | luaF_close(L, oldtop); /* close eventual pending closures */ | 466 | luaF_close(L, oldtop); /* close eventual pending closures */ |
467 | seterrorobj(L, status, oldtop); | 467 | luaD_seterrorobj(L, status, oldtop); |
468 | L->nCcalls = oldnCcalls; | 468 | L->nCcalls = oldnCcalls; |
469 | L->ci = restoreci(L, old_ci); | 469 | L->ci = restoreci(L, old_ci); |
470 | L->base = L->ci->base; | 470 | L->base = L->ci->base; |