summaryrefslogtreecommitdiff
path: root/src/ldo.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 09:27:51 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 09:27:51 +0100
commit50aa5b5029165be03d0cfb34e7d664795dd80898 (patch)
treedc42e1a73ac367fef1a88c3dd0502a0879eebea3 /src/ldo.js
parent4eea48935f2e0ea1267d314f2900af2a1a4b8b02 (diff)
downloadfengari-50aa5b5029165be03d0cfb34e7d664795dd80898.tar.gz
fengari-50aa5b5029165be03d0cfb34e7d664795dd80898.tar.bz2
fengari-50aa5b5029165be03d0cfb34e7d664795dd80898.zip
More accurate state and closure init
Diffstat (limited to 'src/ldo.js')
-rw-r--r--src/ldo.js22
1 files changed, 22 insertions, 0 deletions
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;