diff options
-rw-r--r-- | ldo.c | 3 | ||||
-rw-r--r-- | lgc.c | 21 | ||||
-rw-r--r-- | lua.h | 5 |
3 files changed, 20 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.62 2009/04/26 21:55:35 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.63 2009/04/28 19:04:36 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 | */ |
@@ -60,6 +60,7 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { | |||
60 | break; | 60 | break; |
61 | } | 61 | } |
62 | case LUA_ERRSYNTAX: | 62 | case LUA_ERRSYNTAX: |
63 | case LUA_ERRGCMM: | ||
63 | case LUA_ERRRUN: { | 64 | case LUA_ERRRUN: { |
64 | setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ | 65 | setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ |
65 | break; | 66 | break; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.51 2009/04/28 19:04:36 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.52 2009/04/29 17:09:41 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -617,11 +617,12 @@ static void dothecall (lua_State *L, void *ud) { | |||
617 | } | 617 | } |
618 | 618 | ||
619 | 619 | ||
620 | static void GCTM (lua_State *L) { | 620 | static void GCTM (lua_State *L, int propagateerrors) { |
621 | global_State *g = G(L); | 621 | global_State *g = G(L); |
622 | Udata *udata = udata2finalize(g); | 622 | Udata *udata = udata2finalize(g); |
623 | const TValue *tm = gfasttm(g, udata->uv.metatable, TM_GC); | 623 | const TValue *tm = gfasttm(g, udata->uv.metatable, TM_GC); |
624 | if (tm != NULL && ttisfunction(tm)) { | 624 | if (tm != NULL && ttisfunction(tm)) { |
625 | int status; | ||
625 | lu_byte oldah = L->allowhook; | 626 | lu_byte oldah = L->allowhook; |
626 | lu_mem oldt = g->GCthreshold; | 627 | lu_mem oldt = g->GCthreshold; |
627 | L->allowhook = 0; /* stop debug hooks during GC tag method */ | 628 | L->allowhook = 0; /* stop debug hooks during GC tag method */ |
@@ -629,7 +630,15 @@ static void GCTM (lua_State *L) { | |||
629 | setobj2s(L, L->top, tm); | 630 | setobj2s(L, L->top, tm); |
630 | setuvalue(L, L->top+1, udata); | 631 | setuvalue(L, L->top+1, udata); |
631 | L->top += 2; | 632 | L->top += 2; |
632 | luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); | 633 | status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); |
634 | if (status != LUA_OK && propagateerrors) { /* error while running __gc? */ | ||
635 | if (status == LUA_ERRRUN) { /* is there an error msg.? */ | ||
636 | luaO_pushfstring(L, "error in __gc tag method (%s)", | ||
637 | lua_tostring(L, -1)); | ||
638 | status = LUA_ERRGCMM; /* error in __gc metamethod */ | ||
639 | } | ||
640 | luaD_throw(L, status); /* re-send error */ | ||
641 | } | ||
633 | L->allowhook = oldah; /* restore hooks */ | 642 | L->allowhook = oldah; /* restore hooks */ |
634 | g->GCthreshold = oldt; /* restore threshold */ | 643 | g->GCthreshold = oldt; /* restore threshold */ |
635 | } | 644 | } |
@@ -637,10 +646,10 @@ static void GCTM (lua_State *L) { | |||
637 | 646 | ||
638 | 647 | ||
639 | /* | 648 | /* |
640 | ** Call all GC tag methods | 649 | ** Call all GC tag methods (without raising errors) |
641 | */ | 650 | */ |
642 | void luaC_callAllGCTM (lua_State *L) { | 651 | void luaC_callAllGCTM (lua_State *L) { |
643 | while (G(L)->tobefnz) GCTM(L); | 652 | while (G(L)->tobefnz) GCTM(L, 0); |
644 | } | 653 | } |
645 | 654 | ||
646 | 655 | ||
@@ -783,7 +792,7 @@ static l_mem singlestep (lua_State *L) { | |||
783 | } | 792 | } |
784 | case GCSfinalize: { | 793 | case GCSfinalize: { |
785 | if (g->tobefnz) { | 794 | if (g->tobefnz) { |
786 | GCTM(L); | 795 | GCTM(L, 1); |
787 | if (g->estimate > GCFINALIZECOST) | 796 | if (g->estimate > GCFINALIZECOST) |
788 | g->estimate -= GCFINALIZECOST; | 797 | g->estimate -= GCFINALIZECOST; |
789 | return GCFINALIZECOST; | 798 | return GCFINALIZECOST; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.235 2009/04/08 18:04:33 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.236 2009/04/17 14:28:06 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
5 | ** See Copyright Notice at the end of this file | 5 | ** See Copyright Notice at the end of this file |
@@ -45,7 +45,8 @@ | |||
45 | #define LUA_ERRRUN 2 | 45 | #define LUA_ERRRUN 2 |
46 | #define LUA_ERRSYNTAX 3 | 46 | #define LUA_ERRSYNTAX 3 |
47 | #define LUA_ERRMEM 4 | 47 | #define LUA_ERRMEM 4 |
48 | #define LUA_ERRERR 5 | 48 | #define LUA_ERRGCMM 5 |
49 | #define LUA_ERRERR 6 | ||
49 | 50 | ||
50 | 51 | ||
51 | typedef struct lua_State lua_State; | 52 | typedef struct lua_State lua_State; |