diff options
author | daurnimator <quae@daurnimator.com> | 2017-06-16 17:34:44 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-06-16 18:06:44 +1000 |
commit | 652e9ca6e0b74222e645262c38350731c74b2fab (patch) | |
tree | 30ebd09f8987c21f7cca0ee5ccce47d987882880 /src/ldo.js | |
parent | 1f59eebdd76692ad0f68239bdd45f0e8b84882ce (diff) | |
download | fengari-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.js | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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 */ |