aboutsummaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js18
1 files changed, 17 insertions, 1 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