summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js5
-rw-r--r--src/lobject.js6
-rw-r--r--src/lua.js2
3 files changed, 8 insertions, 5 deletions
diff --git a/src/lapi.js b/src/lapi.js
index e323e4f..1dfd112 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -697,7 +697,7 @@ const lua_rawlen = function(L, idx) {
case CT.LUA_TLNGSTR:
return o.vslen();
case CT.LUA_TUSERDATA:
- return o.len;
+ return o.value.len;
case CT.LUA_TTABLE:
return ltable.luaH_getn(o.value);
default:
@@ -716,7 +716,8 @@ const lua_tointeger = function(L, idx) {
};
const lua_tonumber = function(L, idx) {
- return lvm.tonumber(index2addr(L, idx));
+ let n = lvm.tonumber(index2addr(L, idx));
+ return n === false ? 0 : n;
};
const lua_touserdata = function(L, idx) {
diff --git a/src/lobject.js b/src/lobject.js
index f395036..7f81438 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -658,7 +658,9 @@ const numarith = function(L, op, v1, v2) {
}
};
-const luaO_arith = function(L, op, p1, p2, res) {
+const luaO_arith = function(L, op, p1, p2, p3) {
+ let res = (typeof p3 === "number") ? L.stack[p3] : p3; /* FIXME */
+
switch (op) {
case defs.LUA_OPBAND: case defs.LUA_OPBOR: case defs.LUA_OPBXOR:
case defs.LUA_OPSHL: case defs.LUA_OPSHR:
@@ -693,7 +695,7 @@ const luaO_arith = function(L, op, p1, p2, res) {
}
/* could not perform raw operation; try metamethod */
assert(L !== null); /* should not fail when folding (compile time) */
- ltm.luaT_trybinTM(L, p1, p2, res, (op - defs.LUA_OPADD) + ltm.TMS.TM_ADD);
+ ltm.luaT_trybinTM(L, p1, p2, p3, (op - defs.LUA_OPADD) + ltm.TMS.TM_ADD);
};
diff --git a/src/lua.js b/src/lua.js
index 94eff3d..c921982 100644
--- a/src/lua.js
+++ b/src/lua.js
@@ -213,4 +213,4 @@ module.exports.lua_version = lapi.lua_version;
module.exports.lua_xmove = lapi.lua_xmove;
module.exports.lua_yield = ldo.lua_yield;
module.exports.lua_yieldk = ldo.lua_yieldk;
-module.exports.lua_tocfunctoin = ldo.lua_tocfunctoin;
+module.exports.lua_tocfunction = lapi.lua_tocfunction;