summaryrefslogtreecommitdiff
path: root/src/ldo.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-21 12:53:41 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-21 13:03:58 +0100
commit82ef443de9a3ba53b4a5b9abd161ddc164776a59 (patch)
treeb28dea891d19c1cb472551d4f2b24844e94b44e9 /src/ldo.js
parente111f5cb7a21455df2c62eb65cd7b38aac0d834c (diff)
downloadfengari-82ef443de9a3ba53b4a5b9abd161ddc164776a59.tar.gz
fengari-82ef443de9a3ba53b4a5b9abd161ddc164776a59.tar.bz2
fengari-82ef443de9a3ba53b4a5b9abd161ddc164776a59.zip
Use correct luaG errors instead of throwing Errors
Diffstat (limited to 'src/ldo.js')
-rw-r--r--src/ldo.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ldo.js b/src/ldo.js
index bf07c8c..4333f5e 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -11,6 +11,7 @@ const ltm = require('./ltm.js');
const lvm = require('./lvm.js');
const lfunc = require('./lfunc.js');
const BytecodeParser = require('./lundump.js');
+const ldebug = require('./ldebug.js');
const CT = lua.constant_types;
const TS = lua.thread_status;
const LUA_MULTRET = lua.LUA_MULTRET;
@@ -190,7 +191,7 @@ const adjust_varargs = function(L, p, actual) {
const tryfuncTM = function(L, off, func) {
let tm = ltm.luaT_gettmbyobj(L, func, ltm.TMS.TM_CALL);
if (!tm.ttisfunction(tm))
- throw new Error("__call metatable member is not a function"); // TODO: luaG_typeerror
+ ldebug.luaG_typeerror(L, func, "call");
/* Open a hole inside the stack at 'func' */
for (let p = L.top; p > off; p--)
L.stack[p] = L.stack[p-1];
@@ -207,9 +208,9 @@ const tryfuncTM = function(L, off, func) {
*/
const stackerror = function(L) {
if (L.nCcalls === llimit.LUAI_MAXCCALLS)
- throw new Error("JS stack overflow");
- else if (L.nCcalls >= llimit.LUAI_MAXCCALLS + (llimit.LUAI_MAXCCALLS >> 3)) /* error while handing stack error */
- throw new Error("stack overflow"); // TODO: luaD_throw(L, LUA_ERRERR);
+ ldebug.luaG_runerror(L, "JS stack overflow");
+ else if (L.nCcalls >= llimit.LUAI_MAXCCALLS + (llimit.LUAI_MAXCCALLS >> 3))
+ luaD_throw(L, TS.LUA_ERRERR); /* error while handing stack error */
};
/*