luaur_vm/macros/vm_uv.rs
1//! Node: `cxx:Macro:Luau.VM:VM/src/lvmexecute.cpp:71:VM_UV`
2//! Source: `VM/src/lvmexecute.cpp:71` (hand-ported)
3//!
4//! `uprefs` is the C flexible-array-member idiom (`TValue uprefs[1]` with
5//! over-allocation) — indexing the Rust `[TValue; 1]` would PANIC for i >= 1,
6//! so the element is reached via pointer arithmetic, exactly like C.
7
8#[allow(non_snake_case)]
9#[macro_export]
10macro_rules! VM_UV {
11 ($i:expr, $cl:expr) => {{
12 let i = $i;
13 let cl = $cl;
14 luaur_common::LUAU_ASSERT!((i as u32) < ((*cl).nupvalues as u32));
15 unsafe {
16 let l = &mut (*cl).inner.l;
17 &mut *l.uprefs.as_mut_ptr().add(i as usize)
18 }
19 }};
20}
21
22pub use VM_UV;