aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);