diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-17 14:13:10 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-17 14:13:10 +0100 |
commit | 78b48979b8dbd367043c39fb21007ab4f54cd0a4 (patch) | |
tree | f944c36322bad140da8b8bd69aa7c1c17944ab87 /src/lapi.js | |
parent | ea562b1094672f641707c0f809827a0d3a982f23 (diff) | |
download | fengari-78b48979b8dbd367043c39fb21007ab4f54cd0a4.tar.gz fengari-78b48979b8dbd367043c39fb21007ab4f54cd0a4.tar.bz2 fengari-78b48979b8dbd367043c39fb21007ab4f54cd0a4.zip |
lua_settable, lua_gettable
Diffstat (limited to 'src/lapi.js')
-rw-r--r-- | src/lapi.js | 18 |
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 |