Skip to main content

luaur_analysis/methods/
txn_log_queue_txn_log.rs

1use crate::records::pending_type::PendingType;
2use crate::records::txn_log::TxnLog;
3use crate::type_aliases::type_id::TypeId;
4
5impl TxnLog {
6    pub fn queue_type_id(&mut self, ty: TypeId) -> *mut PendingType {
7        unsafe {
8            if (*ty).persistent {
9                self.radioactive = true;
10            }
11
12            if let Some(existing) = self.type_var_changes.find_mut(&ty) {
13                if !existing.dead {
14                    return existing.as_mut() as *mut PendingType;
15                }
16
17                let mut pending = (*ty).clone();
18                pending.owning_arena = core::ptr::null_mut();
19                *existing = Box::new(PendingType {
20                    pending,
21                    dead: false,
22                });
23                return existing.as_mut() as *mut PendingType;
24            }
25
26            let mut pending = (*ty).clone();
27            pending.owning_arena = core::ptr::null_mut();
28            let (entry, _) = self.type_var_changes.try_insert(
29                ty,
30                Box::new(PendingType {
31                    pending,
32                    dead: false,
33                }),
34            );
35
36            entry.as_mut() as *mut PendingType
37        }
38    }
39}