summaryrefslogtreecommitdiff
path: root/src/lstate.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-28 14:42:41 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-28 14:42:41 +0200
commit354d659f577fc27969784400c8c1e6090756da7b (patch)
tree4aa17f23121794bc8b855e2ed0bf85951281b37e /src/lstate.js
parentcebad06a3429e28cb5e0c247c707bb5eb51943d8 (diff)
downloadfengari-354d659f577fc27969784400c8c1e6090756da7b.tar.gz
fengari-354d659f577fc27969784400c8c1e6090756da7b.tar.bz2
fengari-354d659f577fc27969784400c8c1e6090756da7b.zip
os.exit
Diffstat (limited to 'src/lstate.js')
-rw-r--r--src/lstate.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lstate.js b/src/lstate.js
index 4ecb92f..4b4aaa5 100644
--- a/src/lstate.js
+++ b/src/lstate.js
@@ -8,6 +8,7 @@ const lobject = require('./lobject.js');
const ldo = require('./ldo.js');
const lapi = require('./lapi.js');
const ltable = require('./ltable.js');
+const lfunc = require('./lfunc.js');
const luaT_init = require('./ltm.js').luaT_init;
const CT = defs.constant_types;
const TS = defs.thread_status;
@@ -167,6 +168,16 @@ const lua_newstate = function() {
return L;
};
+const close_state = function(L) {
+ let g = L.l_G;
+ lfunc.luaF_close(L, L.stack); /* close all upvalues for this thread */
+};
+
+const lua_close = function(L) {
+ L = L.l_G.mainthread; /* only the main thread can be closed */
+ close_state(L);
+};
+
module.exports.lua_State = lua_State;
module.exports.CallInfo = CallInfo;
module.exports.CIST_OAH = (1<<0); /* original value of 'allowhook' */
@@ -178,5 +189,6 @@ module.exports.CIST_TAIL = (1<<5); /* call was tail called */
module.exports.CIST_HOOKYIELD = (1<<6); /* last hook called yielded */
module.exports.CIST_LEQ = (1<<7); /* using __lt for __le */
module.exports.CIST_FIN = (1<<8); /* call is running a finalizer */
+module.exports.lua_close = lua_close;
module.exports.lua_newstate = lua_newstate;
module.exports.lua_newthread = lua_newthread;