diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-17 11:33:23 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-17 11:34:49 +0100 |
commit | a8e82fc01f2558550289f76f55c917039296ec11 (patch) | |
tree | b226aeca2d8445ee8bcfd644477992a0635e46e0 /src/ldo.js | |
parent | 4a03542f6ebc8c6d4ed624bc0d30f5a7148a279b (diff) | |
download | fengari-a8e82fc01f2558550289f76f55c917039296ec11.tar.gz fengari-a8e82fc01f2558550289f76f55c917039296ec11.tar.bz2 fengari-a8e82fc01f2558550289f76f55c917039296ec11.zip |
lua_load (bytecode only), lua_call(k)
Diffstat (limited to 'src/ldo.js')
-rw-r--r-- | src/ldo.js | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -9,6 +9,8 @@ const lstate = require('./lstate.js'); const llimit = require('./llimit.js'); const ltm = require('./ltm.js'); const lvm = require('./lvm.js'); +const lfunc = require('./lfunc.js'); +const BytecodeParser = require('./lundump.js'); const CT = lua.constant_types; const TS = lua.thread_status; const LUA_MULTRET = lua.LUA_MULTRET; @@ -237,7 +239,7 @@ const luaD_pcall = function(L, func, u, old_top, ef) { let old_errfunc = L.errfunc; L.errfunc = ef; - status = luaD_rawrunprotected(L, func, u); + let status = luaD_rawrunprotected(L, func, u); if (status !== TS.LUA_OK) { lfunc.luaF_close(L, old_top); @@ -263,12 +265,10 @@ const luaD_callnoyield = function(L, off, nResults) { // TODO: since we only handle binary, no need for a reader or mode const f_parser = function(L, data) { - assert(data instanceof DataView, "data must be a DataView"); + let p = new BytecodeParser(data); + let cl = p.luaU_undump(L); - let p = new lundump.BytecodeParser(data); - let cl = p.luaU_undump(); - - assert(cl.nupvalues == cl.p.sizeupvalues); + assert(cl.nupvalues == cl.p.upvalues.length); lfunc.luaF_initupvals(L, cl); }; @@ -283,14 +283,15 @@ const luaD_protectedparser = function(L, data, name) { return status; }; -module.exports.nil = nil; -module.exports.luaD_precall = luaD_precall; -module.exports.luaD_poscall = luaD_poscall; -module.exports.moveresults = moveresults; -module.exports.adjust_varargs = adjust_varargs; -module.exports.tryfuncTM = tryfuncTM; -module.exports.stackerror = stackerror; -module.exports.luaD_call = luaD_call; -module.exports.luaD_callnoyield = luaD_callnoyield; -module.exports.luaD_pcall = luaD_pcall; -module.exports.luaD_rawrunprotected = luaD_rawrunprotected;
\ No newline at end of file +module.exports.nil = nil; +module.exports.luaD_precall = luaD_precall; +module.exports.luaD_poscall = luaD_poscall; +module.exports.moveresults = moveresults; +module.exports.adjust_varargs = adjust_varargs; +module.exports.tryfuncTM = tryfuncTM; +module.exports.stackerror = stackerror; +module.exports.luaD_call = luaD_call; +module.exports.luaD_callnoyield = luaD_callnoyield; +module.exports.luaD_pcall = luaD_pcall; +module.exports.luaD_rawrunprotected = luaD_rawrunprotected; +module.exports.luaD_protectedparser = luaD_protectedparser;
\ No newline at end of file |