From 50aa5b5029165be03d0cfb34e7d664795dd80898 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 17 Feb 2017 09:27:51 +0100 Subject: More accurate state and closure init --- src/ldo.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/ldo.js') diff --git a/src/ldo.js b/src/ldo.js index f965a47..3686f7d 100644 --- a/src/ldo.js +++ b/src/ldo.js @@ -261,6 +261,28 @@ const luaD_callnoyield = function(L, off, nResults) { L.nny--; }; +// 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 lundump.BytecodeParser(data); + let cl = p.luaU_undump(); + + assert(cl.nupvalues == cl.p.sizeupvalues); + + lfunc.luaF_initupvals(L, cl); +}; + +const luaD_protectedparser = function(L, data, name) { + L.nny++; + + let status = luaD_pcall(L, f_parser, data, L.top, L.errfunc); + + L.nny--; + + return status; +}; + module.exports.nil = nil; module.exports.luaD_precall = luaD_precall; module.exports.luaD_poscall = luaD_poscall; -- cgit v1.2.3-54-g00ecf