diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lapi.js | 18 | ||||
-rw-r--r-- | src/lvm.js | 4 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/lapi.js b/src/lapi.js index 089f138..705fec4 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -210,6 +210,14 @@ const lua_setglobal = function(L, name) { auxsetstr(L, L.l_G.l_registry.value.array[lua.LUA_RIDX_GLOBALS], name); }; +const lua_settable = function(L, idx) { + assert(2 < L.top - L.ci.funcOff, "not enough elements in the stack"); + + let t = index2addr(L, idx); + lvm.settable(L, t, L.stack[L.top - 2], L.stack[L.top - 1]); + L.top -= 2; +}; + /* ** get functions (Lua -> stack) @@ -230,6 +238,12 @@ const lua_newtable = function(L) { lua_createtable(L, 0, 0); }; +const lua_gettable = function(L, idx) { + let t = index2addr(L, idx); + lvm.gettable(L, t, L.stack[L.top - 1], L.top - 1); + return L.stack[L.top - 1].ttnov(); +}; + /* ** access functions (stack -> JS) @@ -401,4 +415,6 @@ module.exports.lua_pop = lua_pop; module.exports.lua_setglobal = lua_setglobal; module.exports.lua_istable = lua_istable; module.exports.lua_createtable = lua_createtable; -module.exports.lua_newtable = lua_newtable;
\ No newline at end of file +module.exports.lua_newtable = lua_newtable; +module.exports.lua_settable = lua_settable; +module.exports.lua_gettable = lua_gettable;
\ No newline at end of file @@ -1034,4 +1034,6 @@ module.exports.LEintfloat = LEintfloat; module.exports.LTintfloat = LTintfloat; module.exports.l_strcmp = l_strcmp; module.exports.luaV_objlen = luaV_objlen; -module.exports.luaV_finishset = luaV_finishset;
\ No newline at end of file +module.exports.luaV_finishset = luaV_finishset; +module.exports.gettable = gettable; +module.exports.settable = settable;
\ No newline at end of file |