aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-10-08 10:42:07 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-10-08 10:42:07 -0300
commit4cd1f4aac01184765818e0cebf02da454ccf6590 (patch)
treec7e6398095afccc9987ed42598477094b6ee2aa6 /lgc.c
parentb114c7d4871051cbdd7af185a61f35fe4028da79 (diff)
downloadlua-4cd1f4aac01184765818e0cebf02da454ccf6590.tar.gz
lua-4cd1f4aac01184765818e0cebf02da454ccf6590.tar.bz2
lua-4cd1f4aac01184765818e0cebf02da454ccf6590.zip
Towards "to closed" local variables
Start of the implementation of "scoped variables" or "to be closed" variables, local variables whose '__close' (or themselves) are called when they go out of scope. This commit implements the syntax, the opcode, and the creation of the corresponding upvalue, but it still does not call the finalizations when the variable goes out of scope (the most important part). Currently, the syntax is 'local scoped name = exp', but that will probably change.
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lgc.c b/lgc.c
index e8429e1b..39b3ab73 100644
--- a/lgc.c
+++ b/lgc.c
@@ -293,7 +293,8 @@ static void reallymarkobject (global_State *g, GCObject *o) {
293 gray2black(o); 293 gray2black(o);
294 break; 294 break;
295 } 295 }
296 case LUA_TUPVAL: { 296 case LUA_TUPVAL:
297 case LUA_TUPVALTBC: {
297 UpVal *uv = gco2upv(o); 298 UpVal *uv = gco2upv(o);
298 if (!upisopen(uv)) /* open upvalues are kept gray */ 299 if (!upisopen(uv)) /* open upvalues are kept gray */
299 gray2black(o); 300 gray2black(o);
@@ -760,6 +761,7 @@ static void freeobj (lua_State *L, GCObject *o) {
760 luaF_freeproto(L, gco2p(o)); 761 luaF_freeproto(L, gco2p(o));
761 break; 762 break;
762 case LUA_TUPVAL: 763 case LUA_TUPVAL:
764 case LUA_TUPVALTBC:
763 freeupval(L, gco2upv(o)); 765 freeupval(L, gco2upv(o));
764 break; 766 break;
765 case LUA_TLCL: 767 case LUA_TLCL: