summaryrefslogtreecommitdiff
path: root/src/ldebug.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-12 16:01:44 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-12 16:55:03 +1000
commit1556f554f8d5f100bce10918d914debd467bd827 (patch)
tree5f8a9dd5c7ed52acd8b66ea4de8728e28b4de1de /src/ldebug.js
parentd387948354206fe214685c3d56d066fbae905fc6 (diff)
downloadfengari-1556f554f8d5f100bce10918d914debd467bd827.tar.gz
fengari-1556f554f8d5f100bce10918d914debd467bd827.tar.bz2
fengari-1556f554f8d5f100bce10918d914debd467bd827.zip
src/ldebug.js: Introduce currentpc function
Diffstat (limited to 'src/ldebug.js')
-rw-r--r--src/ldebug.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/ldebug.js b/src/ldebug.js
index 5839e83..6386458 100644
--- a/src/ldebug.js
+++ b/src/ldebug.js
@@ -17,8 +17,13 @@ const lvm = require('./lvm.js');
const CT = defs.constant_types;
const TS = defs.thread_status;
+const currentpc = function(ci) {
+ assert(ci.callstatus & lstate.CIST_LUA);
+ return ci.pcOff - 1;
+};
+
const currentline = function(ci) {
- return ci.func.value.p.lineinfo ? ci.func.value.p.lineinfo[ci.pcOff-1] : -1;
+ return ci.func.value.p.lineinfo ? ci.func.value.p.lineinfo[currentpc(ci)] : -1;
};
/*
@@ -105,7 +110,7 @@ const findlocal = function(L, ci, n) {
return findvararg(ci, -n);
else {
base = ci.l_base;
- name = lfunc.luaF_getlocalname(ci.func.value.p, n, ci.pcOff);
+ name = lfunc.luaF_getlocalname(ci.func.value.p, n, currentpc(ci));
}
} else
base = ci.funcOff + 1;
@@ -439,7 +444,7 @@ const funcnamefromcode = function(L, ci) {
let tm = 0; /* (initial value avoids warnings) */
let p = ci.func.value.p; /* calling function */
- let pc = ci.pcOff - 1; /* calling instruction index */
+ let pc = currentpc(ci); /* calling instruction index */
let i = p.code[pc]; /* calling instruction */
if (ci.callstatus & lstate.CIST_HOOKED) {
@@ -529,7 +534,7 @@ const varinfo = function(L, o) {
kind = getupvalname(L, ci, o); /* check whether 'o' is an upvalue */
let stkid = isinstack(L, ci, o);
if (!kind && stkid) /* no? try a register */
- kind = getobjname(ci.func.value.p, ci.pcOff - 1, stkid - ci.l_base);
+ kind = getobjname(ci.func.value.p, currentpc(ci), stkid - ci.l_base);
}
return kind ? lobject.luaO_pushfstring(L, defs.to_luastring(" (%s '%s')", true), kind.funcname, kind.name) : defs.to_luastring("", true);