Skip to content

Commit a28ac44

Browse files
committed
Add ERROR_ON macro to interrupt interpreter.
1 parent c2a75f1 commit a28ac44

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/vm/wren_vm.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,16 @@ static WrenInterpretResult runInterpreter(WrenVM* vm, register ObjFiber* fiber)
875875
DISPATCH(); \
876876
} while (false)
877877

878+
#define ERROR_ON(condition, ...) \
879+
do \
880+
{ \
881+
if (condition) \
882+
{ \
883+
vm->fiber->error = wrenStringFormat(vm, __VA_ARGS__); \
884+
RUNTIME_ERROR(); \
885+
} \
886+
} while (false)
887+
878888
#if WREN_DEBUG_TRACE_INSTRUCTIONS
879889
// Prints the stack and instruction before each instruction is executed.
880890
#define DEBUG_TRACE_INSTRUCTIONS() \

0 commit comments

Comments
 (0)