Skip to main content

luaur_analysis/methods/
txn_log_bind_table.rs

1use crate::records::pending_type::PendingType;
2use crate::records::table_type::TableType;
3use crate::records::txn_log::TxnLog;
4use crate::type_aliases::type_id::TypeId;
5use luaur_common::macros::luau_assert::LUAU_ASSERT;
6
7impl TxnLog {
8    pub fn bind_table(&mut self, ty: TypeId, new_bound_to: Option<TypeId>) -> *mut PendingType {
9        // SAFETY: We assume get<TableType>(ty) is valid per the C++ assertion
10        // and that queue_type_id returns a valid PendingType pointer
11        let new_ty = self.queue_type_id(ty);
12
13        // SAFETY: get_mutable_pending_type is the Rust analog of getMutable<TableType>
14        // We assume the type is a TableType as per the C++ assertion
15        unsafe {
16            let table_type = crate::functions::get_mutable_txn_log::get_mutable_pending_type::<
17                TableType,
18            >(new_ty);
19            if !table_type.is_null() {
20                (*table_type).bound_to = new_bound_to;
21            }
22        }
23
24        new_ty
25    }
26}