diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-29 18:22:22 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-29 18:22:22 -0200 |
commit | 413fc7334bf8ceaea71417d73edef15c99d3a793 (patch) | |
tree | 50e762d979ad8e80681902cdeb8aa42b041ae323 /lstate.c | |
parent | fca0a12e23f964006ce43d35ab86b27c6bbb0a48 (diff) | |
download | lua-413fc7334bf8ceaea71417d73edef15c99d3a793.tar.gz lua-413fc7334bf8ceaea71417d73edef15c99d3a793.tar.bz2 lua-413fc7334bf8ceaea71417d73edef15c99d3a793.zip |
new implementation for lua upvalues (sugested by E.T.): simpler and solves
a bug for multi-stacks
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -10,6 +10,7 @@ | |||
10 | #include "lua.h" | 10 | #include "lua.h" |
11 | 11 | ||
12 | #include "ldo.h" | 12 | #include "ldo.h" |
13 | #include "lfunc.h" | ||
13 | #include "lgc.h" | 14 | #include "lgc.h" |
14 | #include "llex.h" | 15 | #include "llex.h" |
15 | #include "lmem.h" | 16 | #include "lmem.h" |
@@ -88,7 +89,7 @@ LUA_API lua_State *lua_newthread (lua_State *OL, int stacksize) { | |||
88 | L->errorJmp = NULL; | 89 | L->errorJmp = NULL; |
89 | L->callhook = NULL; | 90 | L->callhook = NULL; |
90 | L->linehook = NULL; | 91 | L->linehook = NULL; |
91 | L->opencl = NULL; | 92 | L->openupval = NULL; |
92 | L->allowhooks = 1; | 93 | L->allowhooks = 1; |
93 | L->next = L->previous = L; | 94 | L->next = L->previous = L; |
94 | so.stacksize = stacksize; | 95 | so.stacksize = stacksize; |
@@ -105,6 +106,8 @@ LUA_API lua_State *lua_newthread (lua_State *OL, int stacksize) { | |||
105 | 106 | ||
106 | 107 | ||
107 | static void close_state (lua_State *L, lua_State *OL) { | 108 | static void close_state (lua_State *L, lua_State *OL) { |
109 | luaF_close(L, L->stack); /* close all upvalues for this thread */ | ||
110 | lua_assert(L->openupval == NULL); | ||
108 | if (OL != NULL) { /* are there other threads? */ | 111 | if (OL != NULL) { /* are there other threads? */ |
109 | lua_assert(L->previous != L); | 112 | lua_assert(L->previous != L); |
110 | L->previous->next = L->next; | 113 | L->previous->next = L->next; |
@@ -116,6 +119,7 @@ static void close_state (lua_State *L, lua_State *OL) { | |||
116 | lua_assert(G(L)->rootproto == NULL); | 119 | lua_assert(G(L)->rootproto == NULL); |
117 | lua_assert(G(L)->rootudata == NULL); | 120 | lua_assert(G(L)->rootudata == NULL); |
118 | lua_assert(G(L)->rootcl == NULL); | 121 | lua_assert(G(L)->rootcl == NULL); |
122 | lua_assert(G(L)->rootupval == NULL); | ||
119 | lua_assert(G(L)->roottable == NULL); | 123 | lua_assert(G(L)->roottable == NULL); |
120 | luaS_freeall(L); | 124 | luaS_freeall(L); |
121 | luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM); | 125 | 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) { | |||
126 | luaM_freelem(OL, L); | 130 | luaM_freelem(OL, L); |
127 | } | 131 | } |
128 | 132 | ||
133 | |||
129 | LUA_API void lua_close (lua_State *L) { | 134 | LUA_API void lua_close (lua_State *L) { |
130 | lua_State *OL; | 135 | lua_State *OL; |
131 | lua_assert(L != lua_state || lua_gettop(L) == 0); | 136 | lua_assert(L != lua_state || lua_gettop(L) == 0); |