From d251efeb37778e2ab57a3d2c80b9df621a691796 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 13 Apr 2017 07:17:05 +0200 Subject: Table indexes are also starting at 1 internally Since we use a Map we don't have to care about indexes starting at 0 --- src/lapi.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lapi.js') diff --git a/src/lapi.js b/src/lapi.js index 894b5bb..048a6b7 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -346,7 +346,7 @@ const auxsetstr = function(L, t, k) { }; const lua_setglobal = function(L, name) { - auxsetstr(L, L.l_G.l_registry.value.get(lua.LUA_RIDX_GLOBALS - 1), name); + auxsetstr(L, L.l_G.l_registry.value.get(lua.LUA_RIDX_GLOBALS), name); }; const lua_setmetatable = function(L, objindex) { @@ -562,7 +562,7 @@ const lua_geti = function(L, idx, n) { }; const lua_getglobal = function(L, name) { - return auxgetstr(L, L.l_G.l_registry.value.get(lua.LUA_RIDX_GLOBALS - 1), name); + return auxgetstr(L, L.l_G.l_registry.value.get(lua.LUA_RIDX_GLOBALS), name); }; /* @@ -773,7 +773,7 @@ const lua_load = function(L, reader, data, chunckname, mode) { if (f.nupvalues >= 1) { /* does it have an upvalue? */ /* get global table from registry */ let reg = L.l_G.l_registry; - let gt = reg.value.get(lua.LUA_RIDX_GLOBALS - 1); + let gt = reg.value.get(lua.LUA_RIDX_GLOBALS); /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ f.upvals[0].u.value = gt; } -- cgit v1.2.3-54-g00ecf