summaryrefslogtreecommitdiff
path: root/src/ltm.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-21 09:55:56 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-21 09:55:56 +0100
commite111f5cb7a21455df2c62eb65cd7b38aac0d834c (patch)
tree429d0f422e536d945a9d7c7c89ca1122a981fa2f /src/ltm.js
parent66826a03cd3215d1d25856a3d07d9d37be7fe602 (diff)
downloadfengari-e111f5cb7a21455df2c62eb65cd7b38aac0d834c.tar.gz
fengari-e111f5cb7a21455df2c62eb65cd7b38aac0d834c.tar.bz2
fengari-e111f5cb7a21455df2c62eb65cd7b38aac0d834c.zip
luaG_concaterror, luaG_opinterror, luaG_tointerror
Diffstat (limited to 'src/ltm.js')
-rw-r--r--src/ltm.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ltm.js b/src/ltm.js
index f163f44..6186066 100644
--- a/src/ltm.js
+++ b/src/ltm.js
@@ -9,6 +9,8 @@ const Table = lobject.Table;
const ldo = require('./ldo.js');
const lstate = require('./lstate.js');
const lua = require('./lua.js');
+const ldebug = require('./ldebug.js');
+const lvm = require('./lvm.js');
const CT = lua.constant_types;
@@ -114,7 +116,21 @@ const luaT_callbinTM = function(L, p1, p2, res, event) {
const luaT_trybinTM = function(L, p1, p2, res, event) {
if (!luaT_callbinTM(L, p1, p2, res, event)) {
- throw new Error("TM error"); // TODO: luaG_error
+ switch (event) {
+ case TMS.TM_CONCAT:
+ ldebug.luaG_concaterror(L, p1, p2);
+ case TMS.TM_BAND: case TMS.TM_BOR: case TMS.TM_BXOR:
+ case TMS.TM_SHL: case TMS.TM_SHR: case TMS.TM_BNOT: {
+ let n1 = lvm.tonumber(p1);
+ let n2 = lvm.tonumber(p2);
+ if (n1 !== false && n2 !== false)
+ ldebug.luaG_tointerror(L, p1, p2);
+ else
+ ldebug.luaG_opinterror(L, p1, p2, "perform bitwise operation on");
+ }
+ default:
+ ldebug.luaG_opinterror(L, p1, p2, "perform arithmetic on");
+ }
}
};