summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ldebug.js26
-rw-r--r--src/ldo.js16
2 files changed, 28 insertions, 14 deletions
diff --git a/src/ldebug.js b/src/ldebug.js
index 532fd9c..1c55264 100644
--- a/src/ldebug.js
+++ b/src/ldebug.js
@@ -116,7 +116,7 @@ const findlocal = function(L, ci, n) {
base = ci.funcOff + 1;
if (name === null) { /* no 'standard' name? */
- let limit = ci === L.ci ? L.top : ci.next.func;
+ let limit = ci === L.ci ? L.top : ci.next.funcOff;
if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */
name = defs.to_luastring("(*temporary)", true); /* generic name for any valid slot */
else
@@ -475,18 +475,18 @@ const funcnamefromcode = function(L, ci) {
case OCi.OP_SETTABLE:
tm = ltm.TMS.TM_NEWINDEX;
break;
- case OCi.OP_ADD: tm = ltm.TMS.OP_ADD; break;
- case OCi.OP_SUB: tm = ltm.TMS.OP_SUB; break;
- case OCi.OP_MUL: tm = ltm.TMS.OP_MUL; break;
- case OCi.OP_MOD: tm = ltm.TMS.OP_MOD; break;
- case OCi.OP_POW: tm = ltm.TMS.OP_POW; break;
- case OCi.OP_DIV: tm = ltm.TMS.OP_DIV; break;
- case OCi.OP_IDIV: tm = ltm.TMS.OP_IDI; break;
- case OCi.OP_BAND: tm = ltm.TMS.OP_BAN; break;
- case OCi.OP_BOR: tm = ltm.TMS.OP_BOR; break;
- case OCi.OP_BXOR: tm = ltm.TMS.OP_BXO; break;
- case OCi.OP_SHL: tm = ltm.TMS.OP_SHL; break;
- case OCi.OP_SHR: tm = ltm.TMS.OP_SHR; break;
+ case OCi.OP_ADD: tm = ltm.TMS.TM_ADD; break;
+ case OCi.OP_SUB: tm = ltm.TMS.TM_SUB; break;
+ case OCi.OP_MUL: tm = ltm.TMS.TM_MUL; break;
+ case OCi.OP_MOD: tm = ltm.TMS.TM_MOD; break;
+ case OCi.OP_POW: tm = ltm.TMS.TM_POW; break;
+ case OCi.OP_DIV: tm = ltm.TMS.TM_DIV; break;
+ case OCi.OP_IDIV: tm = ltm.TMS.TM_IDIV; break;
+ case OCi.OP_BAND: tm = ltm.TMS.TM_BAND; break;
+ case OCi.OP_BOR: tm = ltm.TMS.TM_BOR; break;
+ case OCi.OP_BXOR: tm = ltm.TMS.TM_BXOR; break;
+ case OCi.OP_SHL: tm = ltm.TMS.TM_SHL; break;
+ case OCi.OP_SHR: tm = ltm.TMS.TM_SHR; break;
case OCi.OP_UNM: tm = ltm.TMS.TM_UNM; break;
case OCi.OP_BNOT: tm = ltm.TMS.TM_BNOT; break;
case OCi.OP_LEN: tm = ltm.TMS.TM_LEN; break;
diff --git a/src/ldo.js b/src/ldo.js
index ed1213e..426422a 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -9,6 +9,7 @@ const ldebug = require('./ldebug.js');
const lfunc = require('./lfunc.js');
const llimit = require('./llimit.js');
const lobject = require('./lobject.js');
+const lopcodes= require('./lopcodes.js');
const lparser = require('./lparser.js');
const lstate = require('./lstate.js');
const lstring = require('./lstring.js');
@@ -173,7 +174,8 @@ const luaD_precall = function(L, off, nresults) {
ci.l_code = p.code;
ci.l_savedpc = 0;
ci.callstatus = lstate.CIST_LUA;
-
+ if (L.hookmask & defs.LUA_MASKCALL)
+ callhook(L, ci);
return false;
}
default:
@@ -272,6 +274,18 @@ const luaD_hook = function(L, event, line) {
}
};
+const callhook = function(L, ci) {
+ let hook = defs.LUA_HOOKCALL;
+ ci.l_savedpc++; /* hooks assume 'pc' is already incremented */
+ if ((ci.previous.callstatus & lstate.CIST_LUA) &&
+ ci.previous.l_code[ci.previous.l_savedpc - 1].opcode == lopcodes.OpCodesI.OP_TAILCALL) {
+ ci.callstatus |= lstate.CIST_TAIL;
+ hook = defs.LUA_HOOKTAILCALL;
+ }
+ luaD_hook(L, hook, -1);
+ ci.l_savedpc--; /* correct 'pc' */
+};
+
const adjust_varargs = function(L, p, actual) {
let nfixargs = p.numparams;
/* move fixed parameters to final position */