summaryrefslogtreecommitdiff
path: root/src/ldblib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-12 07:55:38 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-12 09:18:43 +0200
commitfc08312ebf8cf01a53b4826acce0f1c3aedcdc53 (patch)
tree5b1c3a1276037b482102bfe2c36bcb31c459acac /src/ldblib.js
parent58fcb1d7f55424de904fd6ae53954b46d82aae8c (diff)
downloadfengari-fc08312ebf8cf01a53b4826acce0f1c3aedcdc53.tar.gz
fengari-fc08312ebf8cf01a53b4826acce0f1c3aedcdc53.tar.bz2
fengari-fc08312ebf8cf01a53b4826acce0f1c3aedcdc53.zip
debug.traceback
Diffstat (limited to 'src/ldblib.js')
-rw-r--r--src/ldblib.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ldblib.js b/src/ldblib.js
index 426cef2..318e616 100644
--- a/src/ldblib.js
+++ b/src/ldblib.js
@@ -84,8 +84,23 @@ const db_upvalueid = function(L) {
return 1;
};
+const db_traceback = function(L) {
+ let thread = getthread(L);
+ let L1 = thread.thread;
+ let arg = thread.arg;
+ let msg = lapi.lua_tostring(L, arg + 1);
+ if (msg === null && !lapi.lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */
+ lapi.lua_pushvalue(L, arg + 1); /* return it untouched */
+ else {
+ let level = lauxlib.luaL_optinteger(L, arg + 2, L === L1 ? 1 : 0);
+ lauxlib.luaL_traceback(L, L1, msg, level);
+ }
+ return 1;
+};
+
const dblib = {
- "getlocal": db_getlocal,
+ "getlocal": db_getlocal,
+ "traceback": db_traceback,
"upvalueid": db_upvalueid
};