summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-14 07:50:36 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-14 07:56:46 +0200
commitb711f32eee2e0c696cb0e621f54e38c398c7090a (patch)
tree5c99b4510570789dd9d72cd4c0de357edeaaae23 /src/lapi.js
parent127ca3042ce2be23bd0b07570154c81ac3fda432 (diff)
downloadfengari-b711f32eee2e0c696cb0e621f54e38c398c7090a.tar.gz
fengari-b711f32eee2e0c696cb0e621f54e38c398c7090a.tar.bz2
fengari-b711f32eee2e0c696cb0e621f54e38c398c7090a.zip
debug.getuservalue, debug.setuservalue, debug.setlocal
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 048a6b7..b41cfbe 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -537,6 +537,15 @@ const lua_getmetatable = function(L, objindex) {
return res;
};
+const lua_getuservalue = function(L, idx) {
+ let o = index2addr(L, idx);
+ assert(L, o.ttisfulluserdata(), "full userdata expected");
+ L.stack[L.top].type = o.type;
+ L.stack[L.top++].value = o.value;
+ assert(L.top <= L.ci.top, "stack overflow");
+ return L.stack[L.top - 1].ttnov();
+};
+
const lua_gettable = function(L, idx) {
let t = index2addr(L, idx);
lvm.gettable(L, t, L.stack[L.top - 1], L.top - 1);
@@ -793,6 +802,16 @@ const lua_status = function(L) {
return L.status;
};
+const lua_setuservalue = function(L, idx) {
+ assert(1 < L.top - L.ci.funcOff, "not enough elements in the stack");
+ let o = index2addr(L, idx);
+ assert(L, o.ttisfulluserdata(), "full userdata expected");
+ L.stack[L.top - 1].type = o.type;
+ L.stack[L.top - 1].value = o.value;
+ L.top--;
+};
+
+
const lua_callk = function(L, nargs, nresults, ctx, k) {
assert(k === null || !(L.ci.callstatus & lstate.CIST_LUA), "cannot use continuations inside hooks");
assert(nargs + 1 < L.top - L.ci.funcOff, "not enough elements in the stack");
@@ -972,6 +991,7 @@ module.exports.lua_getmetatable = lua_getmetatable;
module.exports.lua_gettable = lua_gettable;
module.exports.lua_gettop = lua_gettop;
module.exports.lua_getupvalue = lua_getupvalue;
+module.exports.lua_getuservalue = lua_getuservalue;
module.exports.lua_insert = lua_insert;
module.exports.lua_isfunction = lua_isfunction;
module.exports.lua_isinteger = lua_isinteger;
@@ -1023,6 +1043,7 @@ module.exports.lua_setmetatable = lua_setmetatable;
module.exports.lua_settable = lua_settable;
module.exports.lua_settop = lua_settop;
module.exports.lua_setupvalue = lua_setupvalue;
+module.exports.lua_setuservalue = lua_setuservalue;
module.exports.lua_status = lua_status;
module.exports.lua_stringtonumber = lua_stringtonumber;
module.exports.lua_toboolean = lua_toboolean;