summaryrefslogtreecommitdiff
path: root/src/ldo.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-16 17:34:44 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-16 18:06:44 +1000
commit652e9ca6e0b74222e645262c38350731c74b2fab (patch)
tree30ebd09f8987c21f7cca0ee5ccce47d987882880 /src/ldo.js
parent1f59eebdd76692ad0f68239bdd45f0e8b84882ce (diff)
downloadfengari-652e9ca6e0b74222e645262c38350731c74b2fab.tar.gz
fengari-652e9ca6e0b74222e645262c38350731c74b2fab.tar.bz2
fengari-652e9ca6e0b74222e645262c38350731c74b2fab.zip
src/ldo.js: Add call debug hook
Diffstat (limited to 'src/ldo.js')
-rw-r--r--src/ldo.js16
1 files changed, 15 insertions, 1 deletions
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 */