From 91e09ea32148c34965809b8d69987d439d389870 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 22 May 2017 18:06:40 +1000 Subject: Compare allowed stack indices to stack_last Not L.stack.length which is more equivalent to C's L->stacksize --- src/lstate.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/lstate.js') diff --git a/src/lstate.js b/src/lstate.js index 5481f95..b71e011 100644 --- a/src/lstate.js +++ b/src/lstate.js @@ -49,7 +49,8 @@ class lua_State { this.base_ci = new CallInfo(); // Will be populated later this.top = 0; this.ci = null; - this.stack = []; + this.stack = null; + this.stack_last = NaN; this.openupval = null; this.status = TS.LUA_OK; this.next = null; @@ -86,8 +87,10 @@ const luaE_extendCI = function(L) { }; 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.stack = new Array(BASIC_STACK_SIZE); L1.top = 0; + L1.stack_last = BASIC_STACK_SIZE - EXTRA_STACK; + /* initialize first ci */ let ci = L1.base_ci; ci.next = ci.previous = null; ci.callstatus = 0; -- cgit v1.2.3-54-g00ecf