feat: add wrenAbortFiber() API to abort current fiber with runtime error object

Add a new public API function `wrenAbortFiber()` that allows foreign methods to abort the currently executing fiber with a custom runtime error object. The function validates the API slot, then sets the fiber's error field to the value in the specified slot. The interpreter loop is updated to check for a non-null fiber error after calling a foreign method, triggering a runtime error if set. New test files (error.c, error.h, error.wren) demonstrate usage via a static Error.runtimeError foreign method, verifying that the error is propagated through Fiber.try() and that the fiber's isDone and error properties are correctly set. Xcode project updated to include the new error.c source file.
This commit is contained in:
Bob Nystrom
2016-06-10 02:14:21 +00:00
parent 78fa150869
commit 1de17224e8
8 changed files with 55 additions and 1 deletions
+3
View File
@@ -436,5 +436,8 @@ void wrenInsertInList(WrenVM* vm, int listSlot, int index, int elementSlot);
// [slot].
void wrenGetVariable(WrenVM* vm, const char* module, const char* name,
int slot);
// Sets the current fiber to be aborted, and uses the value in [slot] as the
// runtime error object.
void wrenAbortFiber(WrenVM* vm, int slot);
#endif