summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 14:13:10 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 14:13:10 +0100
commit78b48979b8dbd367043c39fb21007ab4f54cd0a4 (patch)
treef944c36322bad140da8b8bd69aa7c1c17944ab87 /src
parentea562b1094672f641707c0f809827a0d3a982f23 (diff)
downloadfengari-78b48979b8dbd367043c39fb21007ab4f54cd0a4.tar.gz
fengari-78b48979b8dbd367043c39fb21007ab4f54cd0a4.tar.bz2
fengari-78b48979b8dbd367043c39fb21007ab4f54cd0a4.zip
lua_settable, lua_gettable
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js18
-rw-r--r--src/lvm.js4
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
diff --git a/src/lvm.js b/src/lvm.js
index 4f52678..a75e305 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -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