summaryrefslogtreecommitdiff
path: root/src/ldo.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 14:36:33 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 14:53:03 +0100
commit5131a5ab1f471655d6398748b1eaa9abd47c14da (patch)
treebf8d1b5102a59898ed520d1afa023301f6483607 /src/ldo.js
parent78b48979b8dbd367043c39fb21007ab4f54cd0a4 (diff)
downloadfengari-5131a5ab1f471655d6398748b1eaa9abd47c14da.tar.gz
fengari-5131a5ab1f471655d6398748b1eaa9abd47c14da.tar.bz2
fengari-5131a5ab1f471655d6398748b1eaa9abd47c14da.zip
lua_pcall
Diffstat (limited to 'src/ldo.js')
-rw-r--r--src/ldo.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/ldo.js b/src/ldo.js
index 632bc22..458ae46 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -19,6 +19,23 @@ const TMS = ltm.TMS;
const nil = new TValue(CT.LUA_TNIL, null);
+const seterrorobj = function(L, errcode, oldtop) {
+ switch (errcode) {
+ case TS.LUA_ERRMEM: {
+ L.stack[oldtop] = new TValue(CT.LUA_TLNGSTR, "not enough memory");
+ break;
+ }
+ case TS.LUA_ERRERR: {
+ L.stack[oldtop] = new TValue(CT.LUA_TLNGSTR, "error in error handling");
+ }
+ default: {
+ L.stack[oldtop] = L.stack[L.top - 1];
+ }
+ }
+
+ L.top = oldtop + 1;
+};
+
/*
** Prepares a function call: checks the stack, creates a new CallInfo
** entry, fills in the relevant information, calls hook if needed.
@@ -221,7 +238,6 @@ const luaD_rawrunprotected = function(L, f, ud) {
try {
f(L, ud);
} catch (e) {
- console.log(e);
if (lj.status == 0) lj.status = -1;
}
@@ -243,7 +259,7 @@ const luaD_pcall = function(L, func, u, old_top, ef) {
if (status !== TS.LUA_OK) {
lfunc.luaF_close(L, old_top);
- // TODO: seterrorobj(L, status, oldtop);
+ seterrorobj(L, status, old_top);
L.ci = old_ci;
// TODO: L->allowhook = old_allowhooks;
L.nny = old_nny;