Please sign in to comment.
Rethink how errors are handled
This changes the error handling to be closer to PUC Lua's implementation: raising an error just "jumps" to the location of pcall. From there, we call the error function, and then unwind the stack, closing any upvalues. This has the advantage that the callstack of coroutines is maintained, even if they error, as the handles are no longer popped. One thing to be aware of here is that return hooks are no longer called on errors. While this may be a little counter-intuitive, it is consistent with how PUC Lua operates. Note, Lua actually calls the error handler when throwing the error, rather than when catching it. However, this way means we don't need to thread a LuaState everywhere we want to throw an error.
- Loading branch information...
Showing with 467 additions and 457 deletions.
- +11 −0 src/main/java/org/squiddev/cobalt/LuaThread.java
- +5 −0 src/main/java/org/squiddev/cobalt/debug/DebugFrame.java
- +15 −3 src/main/java/org/squiddev/cobalt/debug/DebugHandler.java
- +409 −437 src/main/java/org/squiddev/cobalt/function/LuaInterpreter.java
- +23 −13 src/main/java/org/squiddev/cobalt/lib/BaseLib.java
- +4 −4 src/test/resources/lua5.1/db.lua
Oops, something went wrong.