diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-22 08:23:37 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-22 08:23:37 +0100 |
commit | dbe2a3bf2ef8c053e6c596c99e29eb27b6118f1b (patch) | |
tree | 4920ab827f35d0305a951fde5d627cc8c767b4fe /src/lapi.js | |
parent | c1824a99035a231172f3c10ae3ee24a3e6330260 (diff) | |
download | fengari-dbe2a3bf2ef8c053e6c596c99e29eb27b6118f1b.tar.gz fengari-dbe2a3bf2ef8c053e6c596c99e29eb27b6118f1b.tar.bz2 fengari-dbe2a3bf2ef8c053e6c596c99e29eb27b6118f1b.zip |
ipairs
Diffstat (limited to 'src/lapi.js')
-rw-r--r-- | src/lapi.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lapi.js b/src/lapi.js index c091150..e149619 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -426,6 +426,20 @@ const lua_getfield = function(L, idx, k) { return auxgetstr(L, index2addr(L, idx), k); }; +const lua_geti = function(L, idx, n) { + let t = index2addr(L, idx); + let slot = t.__index(t, n); + if (!slot.ttisnil()) { + L.stack[L.top++] = slot; + assert(L.top <= L.ci.top, "stack overflow"); + } else { + L.stack[L.top++] = new TValue(CT.LUA_TNUMINT, n); + assert(L.top <= L.ci.top, "stack overflow"); + lvm.gettable(L, t, L.stack[L.top - 1], L.top - 1); + } + return L.stack[L.top - 1].ttnov(); +}; + const lua_getglobal = function(L, name) { return auxgetstr(L, L.l_G.l_registry.value.array[lua.LUA_RIDX_GLOBALS - 1], name); }; @@ -651,6 +665,7 @@ module.exports.lua_createtable = lua_createtable; module.exports.lua_newtable = lua_newtable; module.exports.lua_settable = lua_settable; module.exports.lua_gettable = lua_gettable; +module.exports.lua_geti = lua_geti; module.exports.lua_absindex = lua_absindex; module.exports.index2addr = index2addr; module.exports.lua_rawget = lua_rawget; |