Skip to main content

luaur_vm/macros/
lua_r_lookupmemberatoffset.rs

1//! Node: `cxx:Macro:Luau.VM:VM/src/lclass.h:51:lua_r_lookupmemberatoffset`
2//! Source: `VM/src/lclass.h:51-54` (hand-fixed: the original translation used
3//! C ternary syntax `? :` and could never have compiled). Yields `*mut TValue`.
4
5#[allow(non_upper_case_globals)]
6#[macro_export]
7macro_rules! luaR_lookupmemberatoffset {
8    ($inst:expr, $offset:expr) => {{
9        let inst = $inst;
10        let offset = $offset;
11        luaur_common::LUAU_ASSERT!(
12            $crate::macros::lua_r_checkoffsetinbounds::luaR_checkoffsetinbounds!(inst, offset)
13        );
14        unsafe {
15            if offset < (*(*inst).lclass).numberofinstancemembers {
16                (*inst).members.add(offset as usize)
17            } else {
18                (*(*inst).lclass)
19                    .staticmembers
20                    .add((offset - (*(*inst).lclass).numberofinstancemembers) as usize)
21            }
22        }
23    }};
24}
25
26pub use luaR_lookupmemberatoffset;