luaur_analysis/methods/
txn_log_get_level.rs1use crate::enums::table_state::TableState;
2use crate::functions::get_mutable_type::get_mutable_type_id;
3use crate::records::free_type::FreeType;
4use crate::records::function_type::FunctionType;
5use crate::records::table_type::TableType;
6use crate::records::txn_log::TxnLog;
7use crate::records::type_level::TypeLevel;
8use crate::type_aliases::type_id::TypeId;
9
10impl TxnLog {
11 pub fn get_level(&self, ty: TypeId) -> Option<TypeLevel> {
12 unsafe {
13 if let Some(ftv) = get_mutable_type_id::<FreeType>(ty).as_ref() {
15 return Some(ftv.level);
16 }
17
18 if let Some(ttv) = get_mutable_type_id::<TableType>(ty).as_ref() {
20 if ttv.state == TableState::Free || ttv.state == TableState::Generic {
21 return Some(ttv.level);
22 }
23 }
24
25 if let Some(ftv) = get_mutable_type_id::<FunctionType>(ty).as_ref() {
27 return Some(ftv.level);
28 }
29
30 None
31 }
32 }
33}