diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lauxlib.js | 19 | ||||
-rw-r--r-- | src/lcorolib.js | 3 | ||||
-rw-r--r-- | src/ldblib.js | 25 | ||||
-rw-r--r-- | src/lmathlib.js | 1 | ||||
-rw-r--r-- | src/loslib.js | 1 | ||||
-rw-r--r-- | src/ltablib.js | 1 | ||||
-rw-r--r-- | src/lua.js | 9 |
7 files changed, 31 insertions, 28 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js index 055abcd..2300391 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -5,7 +5,6 @@ const assert = require('assert'); const lapi = require('./lapi.js'); const lua = require('./lua.js'); -const ldebug = require('./ldebug.js'); const lobject = require('./lobject.js'); const LUA_LOADED_TABLE = "_LOADED"; @@ -55,7 +54,7 @@ const findfield = function(L, objidx, level) { */ const pushglobalfuncname = function(L, ar) { let top = lua.lua_gettop(L); - ldebug.lua_getinfo(L, ['f'.charCodeAt(0)], ar); /* push function */ + lua.lua_getinfo(L, ['f'.charCodeAt(0)], ar); /* push function */ lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring(LUA_LOADED_TABLE, true)); if (findfield(L, top + 1, 2)) { let name = lua.lua_tostring(L, -1); @@ -94,11 +93,11 @@ const lastlevel = function(L) { let li = 1; let le = 1; /* find an upper bound */ - while (ldebug.lua_getstack(L, le, ar)) { li = le; le *= 2; } + while (lua.lua_getstack(L, le, ar)) { li = le; le *= 2; } /* do a binary search */ while (li < le) { let m = Math.floor((li + le)/2); - if (ldebug.lua_getstack(L, m, ar)) li = m + 1; + if (lua.lua_getstack(L, m, ar)) li = m + 1; else le = m; } return le - 1; @@ -113,12 +112,12 @@ const luaL_traceback = function(L, L1, msg, level) { lua.lua_pushstring(L, msg.concat('\n'.charCodeAt(0))); luaL_checkstack(L, 10, null); lua.lua_pushliteral(L, "stack traceback:"); - while (ldebug.lua_getstack(L1, level++, ar)) { + while (lua.lua_getstack(L1, level++, ar)) { if (n1-- === 0) { /* too many levels? */ lua.lua_pushliteral(L, "\n\t..."); /* add a '...' */ level = last - LEVELS2 + 1; /* and skip to last ones */ } else { - ldebug.lua_getinfo(L1, lua.to_luastring("Slnt", true), ar); + lua.lua_getinfo(L1, lua.to_luastring("Slnt", true), ar); lua.lua_pushstring(L, ['\n'.charCodeAt(0), '\t'.charCodeAt(0), '.'.charCodeAt(0), '.'.charCodeAt(0), '.'.charCodeAt(0)].concat(ar.short_src)); if (ar.currentline > 0) lua.lua_pushliteral(L, `${ar.currentline}:`); @@ -139,10 +138,10 @@ const panic = function(L) { const luaL_argerror = function(L, arg, extramsg) { let ar = new lua.lua_Debug(); - if (!ldebug.lua_getstack(L, 0, ar)) /* no stack frame? */ + if (!lua.lua_getstack(L, 0, ar)) /* no stack frame? */ return luaL_error(L, lua.to_luastring(`bad argument #${arg} (${lobject.jsstring(extramsg)})`)); - ldebug.lua_getinfo(L, 'n', ar); + lua.lua_getinfo(L, 'n', ar); if (ar.namewhat === lua.to_luastring('method', true)) { arg--; /* do not count 'self' */ @@ -171,8 +170,8 @@ const typeerror = function(L, arg, tname) { const luaL_where = function(L, level) { let ar = new lua.lua_Debug(); - if (ldebug.lua_getstack(L, level, ar)) { - ldebug.lua_getinfo(L, lua.to_luastring("Sl", true), ar); + if (lua.lua_getstack(L, level, ar)) { + lua.lua_getinfo(L, lua.to_luastring("Sl", true), ar); if (ar.currentline > 0) { lua.lua_pushstring(L, lua.to_luastring(`${lobject.jsstring(ar.short_src)}:${ar.currentline}:`)); return; diff --git a/src/lcorolib.js b/src/lcorolib.js index baf7254..af1a3ec 100644 --- a/src/lcorolib.js +++ b/src/lcorolib.js @@ -5,7 +5,6 @@ const assert = require('assert'); const lua = require('./lua.js'); const lauxlib = require('./lauxlib.js'); const ldo = require('./ldo.js'); -const ldebug = require('./ldebug.js'); const lobject = require('./lobject.js'); const getco = function(L) { @@ -101,7 +100,7 @@ const luaB_costatus = function(L) { break; case lua.LUA_OK: { let ar = new lua.lua_Debug(); - if (ldebug.lua_getstack(co, 0, ar) > 0) /* does it have frames? */ + if (lua.lua_getstack(co, 0, ar) > 0) /* does it have frames? */ lua.lua_pushliteral(L, "normal"); /* it is running */ else if (lua.lua_gettop(co) === 0) lua.lua_pushliteral(L, "dead"); diff --git a/src/ldblib.js b/src/ldblib.js index c5ef8d4..8ed95d7 100644 --- a/src/ldblib.js +++ b/src/ldblib.js @@ -4,7 +4,6 @@ const assert = require('assert'); const lua = require('./lua.js'); const lauxlib = require('./lauxlib.js'); -const ldebug = require('./ldebug.js'); /* ** If L1 != L, L1 can be in any state, and therefore there are no @@ -128,13 +127,13 @@ const db_getinfo = function(L) { lua.lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ lua.lua_xmove(L, L1, 1); } else { /* stack level */ - if (!ldebug.lua_getstack(L1, lauxlib.luaL_checkinteger(L, arg + 1), ar)) { + if (!lua.lua_getstack(L1, lauxlib.luaL_checkinteger(L, arg + 1), ar)) { lua.lua_pushnil(L); /* level out of range */ return 1; } } - if (!ldebug.lua_getinfo(L1, options, ar)) + if (!lua.lua_getinfo(L1, options, ar)) lauxlib.luaL_argerror(L, arg + 2, lua.to_luastring("invalid option", true)); lua.lua_newtable(L); /* table to collect results */ if (options.indexOf('S'.charCodeAt(0)) > -1) { @@ -171,14 +170,14 @@ const db_getlocal = function(L) { let nvar = lauxlib.luaL_checkinteger(L, arg + 2); /* local-variable index */ if (lua.lua_isfunction(L, arg + 1)) { lua.lua_pushvalue(L, arg + 1); /* push function */ - lua.lua_pushstring(L, ldebug.lua_getlocal(L, null, nvar)); /* push local name */ + lua.lua_pushstring(L, lua.lua_getlocal(L, null, nvar)); /* push local name */ return 1; /* return only name (there is no value) */ } else { /* stack-level argument */ let level = lauxlib.luaL_checkinteger(L, arg + 1); - if (!ldebug.lua_getstack(L1, level, ar)) /* out of range? */ + if (!lua.lua_getstack(L1, level, ar)) /* out of range? */ return lauxlib.luaL_argerror(L, arg+1, lua.to_luastring("level out of range", true)); checkstack(L, L1, 1); - let name = ldebug.lua_getlocal(L1, ar, nvar); + let name = lua.lua_getlocal(L1, ar, nvar); if (name) { lua.lua_xmove(L1, L, 1); /* move local value */ lua.lua_pushstring(L, name.value); /* push name */ @@ -199,13 +198,13 @@ const db_setlocal = function(L) { let ar = new lua.lua_Debug(); let level = lauxlib.luaL_checkinteger(L, arg + 1); let nvar = lauxlib.luaL_checkinteger(L, arg + 2); - if (!ldebug.lua_getstack(L1, level, ar)) /* out of range? */ + if (!lua.lua_getstack(L1, level, ar)) /* out of range? */ return lauxlib.luaL_argerror(L, arg + 1, "level out of range"); lauxlib.luaL_checkany(L, arg + 3); lua.lua_settop(L, arg + 3); checkstack(L, L1, 1); lua.lua_xmove(L, L1, 1); - let name = ldebug.lua_setlocal(L1, ar, nvar); + let name = lua.lua_setlocal(L1, ar, nvar); if (name === null) lua.lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ lua.lua_pushstring(L, name.value); @@ -281,7 +280,7 @@ const hookf = function(L, ar) { if (ar.currentline >= 0) lua.lua_pushinteger(L, ar.currentline); /* push current line */ else lua.lua_pushnil(L); - assert(ldebug.lua_getinfo(L, ["l".charCodeAt(0), "S".charCodeAt(0)], ar)); + assert(lua.lua_getinfo(L, ["l".charCodeAt(0), "S".charCodeAt(0)], ar)); lua.lua_call(L, 2, 0); /* call hook function */ } }; @@ -337,7 +336,7 @@ const db_sethook = function(L) { lua.lua_pushthread(L1); lua.lua_xmove(L1, L, 1); /* key (thread) */ lua.lua_pushvalue(L, arg + 1); /* value (hook function) */ lua.lua_rawset(L, -3); /* hooktable[L1] = new Lua hook */ - ldebug.lua_sethook(L1, func, mask, count); + lua.lua_sethook(L1, func, mask, count); return 0; }; @@ -346,8 +345,8 @@ const db_gethook = function(L) { let L1 = thread.thread; let arg = thread.arg; let buff = []; - let mask = ldebug.lua_gethookmask(L1); - let hook = ldebug.lua_gethook(L1); + let mask = lua.lua_gethookmask(L1); + let hook = lua.lua_gethook(L1); if (hook === null) /* no hook? */ lua.lua_pushnil(L); else if (hook !== hookf) /* external hook? */ @@ -360,7 +359,7 @@ const db_gethook = function(L) { lua.lua_remove(L, -2); /* remove hook table */ } lua.lua_pushstring(L, unmakemask(mask, buff)); /* 2nd result = mask */ - lua.lua_pushinteger(L, ldebug.lua_gethookcount(L1)); /* 3rd result = count */ + lua.lua_pushinteger(L, lua.lua_gethookcount(L1)); /* 3rd result = count */ return 3; }; diff --git a/src/lmathlib.js b/src/lmathlib.js index 4f323c6..8ee9f71 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -7,7 +7,6 @@ const lua = require('./lua.js'); const lauxlib = require('./lauxlib.js'); const lstate = require('./lstate.js'); const ldo = require('./ldo.js'); -const ldebug = require('./ldebug.js'); const llimit = require('./llimit.js'); const luaconf = require('./luaconf.js'); diff --git a/src/loslib.js b/src/loslib.js index 348dcd6..e577b1b 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -4,7 +4,6 @@ const assert = require('assert'); const lua = require('./lua.js'); const lauxlib = require('./lauxlib.js'); -const ldebug = require('./ldebug.js'); const llimit = require('./llimit.js'); const setfield = function(L, key, value) { diff --git a/src/ltablib.js b/src/ltablib.js index 5dc33d1..08cf4d6 100644 --- a/src/ltablib.js +++ b/src/ltablib.js @@ -7,7 +7,6 @@ const lapi = require('./lapi.js'); const lauxlib = require('./lauxlib.js'); const lstate = require('./lstate.js'); const ldo = require('./ldo.js'); -const ldebug = require('./ldebug.js'); const llimit = require('./llimit.js'); const lobject = require('./lobject.js'); @@ -3,6 +3,7 @@ const defs = require("./defs.js"); const lapi = require("./lapi.js"); +const ldebug = require("./ldebug.js"); const lstate = require("./lstate.js"); module.exports.FENGARI_AUTHORS = defs.FENGARI_AUTHORS; @@ -95,8 +96,14 @@ module.exports.lua_getallocf = lapi.lua_getallocf; module.exports.lua_getextraspace = lapi.lua_getextraspace; module.exports.lua_getfield = lapi.lua_getfield; module.exports.lua_getglobal = lapi.lua_getglobal; +module.exports.lua_gethook = ldebug.lua_gethook; +module.exports.lua_gethookcount = ldebug.lua_gethookcount; +module.exports.lua_gethookmask = ldebug.lua_gethookmask; module.exports.lua_geti = lapi.lua_geti; +module.exports.lua_getinfo = ldebug.lua_getinfo; +module.exports.lua_getlocal = ldebug.lua_getlocal; module.exports.lua_getmetatable = lapi.lua_getmetatable; +module.exports.lua_getstack = ldebug.lua_getstack; module.exports.lua_gettable = lapi.lua_gettable; module.exports.lua_gettop = lapi.lua_gettop; module.exports.lua_getupvalue = lapi.lua_getupvalue; @@ -152,7 +159,9 @@ module.exports.lua_replace = lapi.lua_replace; module.exports.lua_rotate = lapi.lua_rotate; module.exports.lua_setfield = lapi.lua_setfield; module.exports.lua_setglobal = lapi.lua_setglobal; +module.exports.lua_sethook = ldebug.lua_sethook; module.exports.lua_seti = lapi.lua_seti; +module.exports.lua_setlocal = ldebug.lua_setlocal; module.exports.lua_setmetatable = lapi.lua_setmetatable; module.exports.lua_settable = lapi.lua_settable; module.exports.lua_settop = lapi.lua_settop; |