new implementation for lua upvalues (sugested by E.T.): simpler and solves

a bug for multi-stacks
This commit is contained in:
Roberto Ierusalimschy
2001-11-29 18:22:22 -02:00
parent fca0a12e23
commit 413fc7334b
8 changed files with 67 additions and 112 deletions

View File

@@ -10,6 +10,7 @@
#include "lua.h"
#include "ldo.h"
#include "lfunc.h"
#include "lgc.h"
#include "llex.h"
#include "lmem.h"
@@ -88,7 +89,7 @@ LUA_API lua_State *lua_newthread (lua_State *OL, int stacksize) {
L->errorJmp = NULL;
L->callhook = NULL;
L->linehook = NULL;
L->opencl = NULL;
L->openupval = NULL;
L->allowhooks = 1;
L->next = L->previous = L;
so.stacksize = stacksize;
@@ -105,6 +106,8 @@ LUA_API lua_State *lua_newthread (lua_State *OL, int stacksize) {
static void close_state (lua_State *L, lua_State *OL) {
luaF_close(L, L->stack); /* close all upvalues for this thread */
lua_assert(L->openupval == NULL);
if (OL != NULL) { /* are there other threads? */
lua_assert(L->previous != L);
L->previous->next = L->next;
@@ -116,6 +119,7 @@ static void close_state (lua_State *L, lua_State *OL) {
lua_assert(G(L)->rootproto == NULL);
lua_assert(G(L)->rootudata == NULL);
lua_assert(G(L)->rootcl == NULL);
lua_assert(G(L)->rootupval == NULL);
lua_assert(G(L)->roottable == NULL);
luaS_freeall(L);
luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM);
@@ -126,6 +130,7 @@ static void close_state (lua_State *L, lua_State *OL) {
luaM_freelem(OL, L);
}
LUA_API void lua_close (lua_State *L) {
lua_State *OL;
lua_assert(L != lua_state || lua_gettop(L) == 0);