Skip to main content

luaur_vm/functions/
lua_g_getline.rs

1use crate::type_aliases::proto::Proto;
2use luaur_common::macros::luau_assert::LUAU_ASSERT;
3
4#[no_mangle]
5pub unsafe fn luaG_getline(p: *mut Proto, pc: core::ffi::c_int) -> core::ffi::c_int {
6    LUAU_ASSERT!(pc >= 0 && pc < (*p).sizecode);
7
8    if (*p).lineinfo.is_null() {
9        return 0;
10    }
11
12    let abs_index = (pc >> (*p).linegaplog2) as usize;
13    let line_index = pc as usize;
14
15    let abs_line = *((*p).abslineinfo.add(abs_index));
16    let line_offset = *((*p).lineinfo.add(line_index)) as core::ffi::c_int;
17
18    abs_line + line_offset
19}