aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-12 15:05:33 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-12 16:54:47 +1000
commit662d01cc30a60a5ef63f489570c3cdaf3f35b9ce (patch)
tree0cb83c1d43ac17104e6454c43071fde09ddac5e7 /src
parentad7aa3169657879cc81ecadf5583c3d25177949e (diff)
downloadfengari-662d01cc30a60a5ef63f489570c3cdaf3f35b9ce.tar.gz
fengari-662d01cc30a60a5ef63f489570c3cdaf3f35b9ce.tar.bz2
fengari-662d01cc30a60a5ef63f489570c3cdaf3f35b9ce.zip
src/lstate.js: Implement freestack(), call from lua_close
Work towards https://github.com/giann/fengari/commit/354d659f577fc27969784400c8c1e6090756da7b#commitcomment-21975897
Diffstat (limited to 'src')
-rw-r--r--src/lstate.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lstate.js b/src/lstate.js
index 664ef27..020971a 100644
--- a/src/lstate.js
+++ b/src/lstate.js
@@ -75,6 +75,11 @@ class global_State {
}
+const luaE_freeCI = function(L) {
+ let ci = L.ci;
+ ci.next = null;
+};
+
const stack_init = function(L1, L) {
L1.stack = new Array(BASIC_STACK_SIZE); // TODO: for now we don't care about the stack size
L1.top = 0;
@@ -88,6 +93,12 @@ const stack_init = function(L1, L) {
L1.ci = ci;
};
+const freestack = function(L) {
+ L.ci = L.base_ci;
+ luaE_freeCI(L);
+ L.stack = null;
+};
+
/*
** Create registry table and its predefined values
*/
@@ -158,6 +169,7 @@ const lua_newstate = function() {
const close_state = function(L) {
lfunc.luaF_close(L, L.stack); /* close all upvalues for this thread */
+ freestack(L);
};
const lua_close = function(L) {