luaur_vm/macros/vm_interrupt.rs
1//! Node: `cxx:Macro:Luau.VM:VM/src/lvmexecute.cpp:79:VM_INTERRUPT`
2//! Source: `VM/src/lvmexecute.cpp:79-91` (hand-ported)
3//!
4//! C++ `goto exit` becomes `return` — the macro only expands inside
5//! `luau_execute_impl`, whose `exit:` label is the function end.
6
7#[allow(non_snake_case)]
8#[macro_export]
9macro_rules! VM_INTERRUPT {
10 ($L:expr, $pc:expr, $base:expr) => {{
11 let interrupt = unsafe { (*(*$L).global).cb.interrupt };
12 if let Some(interrupt) = interrupt {
13 // the interrupt hook is called right before we advance pc
14 $crate::macros::vm_protect::vm_protect!($L, $pc, $base, {
15 unsafe {
16 (*(*$L).ci).savedpc = (*(*$L).ci).savedpc.add(1);
17 interrupt($L, -1);
18 }
19 });
20 if unsafe { (*$L).status } != 0 {
21 unsafe {
22 (*(*$L).ci).savedpc = (*(*$L).ci).savedpc.sub(1);
23 }
24 return;
25 }
26 }
27 }};
28}
29
30pub use VM_INTERRUPT;