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.
This commit is contained in:
6
lvm.c
6
lvm.c
@@ -1455,6 +1455,12 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
||||
luaF_close(L, ra);
|
||||
vmbreak;
|
||||
}
|
||||
vmcase(OP_TBC) {
|
||||
UpVal *up = luaF_findupval(L, ra); /* create new upvalue */
|
||||
up->tt = LUA_TUPVALTBC; /* mark it to be closed */
|
||||
setnilvalue(s2v(ra)); /* intialize it with nil */
|
||||
vmbreak;
|
||||
}
|
||||
vmcase(OP_JMP) {
|
||||
dojump(ci, i, 0);
|
||||
vmbreak;
|
||||
|
||||
Reference in New Issue
Block a user