aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/util/lua/ldo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword25/util/lua/ldo.cpp')
-rw-r--r--engines/sword25/util/lua/ldo.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/engines/sword25/util/lua/ldo.cpp b/engines/sword25/util/lua/ldo.cpp
index 5d9667f4f0..a230097f2a 100644
--- a/engines/sword25/util/lua/ldo.cpp
+++ b/engines/sword25/util/lua/ldo.cpp
@@ -6,12 +6,10 @@
// FIXME: LUAI_THROW and LUAI_TRY use either throw/catch or setjmp/longjmp.
-// Neither of these is supported in ScummVM. So we need to come up
-// with a replacement. The most simple, direct and crude approach:
-// Replace "throw" with an "error()" call. Of course we only
-// would want to do that if this actually never happens...
-#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp
-#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp
+// Neither of these is supported in ScummVM. Calls to LUAI_THROW have been
+// replaced with error() in ScummVM, but the calls to LUAI_TRY remain
+#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp // for LUAI_TRY, i.e. try()
+#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp // for LUAI_TRY and LUAI_THROW, i.e. throw()
#include "common/textconsole.h"
@@ -100,15 +98,23 @@ static void resetstack (lua_State *L, int status) {
}
+// Added in ScummVM. Refer to http://www.lua.org/manual/5.1/manual.html
+static const char* luaErrorDescription[] = {
+ "No error",
+ "Coroutine yield", // not an actual error, see lua_resume
+ "Runtime error",
+ "Syntax error during pre-compilation", // refer to lua_load
+ "Memory allocation error",
+ "Error while running the error handler function"
+};
+
void luaD_throw (lua_State *L, int errcode) {
if (L->errorJmp) {
L->errorJmp->status = errcode;
- // FIXME: LUAI_THROW and LUAI_TRY use either throw/catch or setjmp/longjmp.
- // Neither of these is supported in ScummVM. So we need to come up
- // with a replacement. The most simple, direct and crude approach:
- // Replace "throw" with an "error()" call. Of course we only
- // would want to do that if this actually never happens...
- LUAI_THROW(L, L->errorJmp);
+ // LUAI_THROW has been replaced with an error message in ScummVM, together
+ // with the LUA error code and description
+ //LUAI_THROW(L, L->errorJmp);
+ error("LUA error occured, error code is %d (%s)", errcode, luaErrorDescription[errcode]);
}
else {
L->status = cast_byte(errcode);
@@ -129,9 +135,8 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
L->errorJmp = &lj;
// FIXME: LUAI_THROW and LUAI_TRY use either throw/catch or setjmp/longjmp.
// Neither of these is supported in ScummVM. So we need to come up
- // with a replacement. The most simple, direct and crude approach:
- // Replace "throw" with an "error()" call. Of course we only
- // would want to do that if this actually never happens...
+ // with a replacement. Calls to LUAI_THROW have been replaced with error()
+ // in ScummVM, but the calls to LUAI_TRY remain
LUAI_TRY(L, &lj,
(*f)(L, ud);
);