diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-04-14 08:59:00 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-04-14 11:06:19 +0200 |
commit | 43c97cbc2904d2bac87c61515bbc16c38a091548 (patch) | |
tree | 31dee0450518dc6a6aebd913e450bcd8ed4131b2 /src/lapi.js | |
parent | fd613ef1da5e3eeb10d13351ccf217e33b30b1dd (diff) | |
download | fengari-43c97cbc2904d2bac87c61515bbc16c38a091548.tar.gz fengari-43c97cbc2904d2bac87c61515bbc16c38a091548.tar.bz2 fengari-43c97cbc2904d2bac87c61515bbc16c38a091548.zip |
hooks
Diffstat (limited to 'src/lapi.js')
-rw-r--r-- | src/lapi.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/lapi.js b/src/lapi.js index caafc0a..bf9b381 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -403,6 +403,15 @@ const lua_rawset = function(L, idx) { L.top -= 2; }; +const lua_rawsetp = function(L, idx, p) { + assert(1 < L.top - L.ci.funcOff, "not enough elements in the stack"); + let o = index2addr(L, idx); + assert(L, o.ttistable(), "table expected"); + let k = p; + o.__newindex(o, k, L.stack[L.top - 1]); + L.top--; +}; + /* ** get functions (Lua -> stack) */ @@ -436,6 +445,15 @@ const lua_rawgeti = function(L, idx, n) { return L.stack[L.top - 1].ttnov(); }; +const lua_rawgetp = function(L, idx, p) { + let t = index2addr(L, idx); + assert(t.ttistable(), "table expected"); + let k = p; + L.stack[L.top++] = t.__index(t, k); + assert(L.top <= L.ci.top, "stack overflow"); + return L.stack[L.top - 1].ttnov(); +}; + const lua_rawget = function(L, idx) { let t = index2addr(L, idx); @@ -875,7 +893,7 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) { ci.extra = c.funcOff; ci.u.c.old_errfunc = L.errfunc; L.errfunc = func; - // TODO: setoah(ci->callstatus, L->allowhook); + ci.callstatus &= ~lstate.CIST_OAH | L.allowhook; ci.callstatus |= lstate.CIST_YPCALL; /* function can do error recovery */ ldo.luaD_call(L, c.funcOff, nresults); /* do the call */ ci.callstatus &= ~lstate.CIST_YPCALL; @@ -1049,8 +1067,10 @@ module.exports.lua_pushvalue = lua_pushvalue; module.exports.lua_rawequal = lua_rawequal; module.exports.lua_rawget = lua_rawget; module.exports.lua_rawgeti = lua_rawgeti; +module.exports.lua_rawgetp = lua_rawgetp; module.exports.lua_rawlen = lua_rawlen; module.exports.lua_rawset = lua_rawset; +module.exports.lua_rawsetp = lua_rawsetp; module.exports.lua_remove = lua_remove; module.exports.lua_replace = lua_replace; module.exports.lua_rotate = lua_rotate; |