luaur_analysis/functions/
is_normalized_boolean.rs1use crate::functions::get_type::get_singleton_type;
2use crate::functions::get_type_alt_j::get_type_id;
3use crate::records::boolean_singleton::BooleanSingleton;
4use crate::records::never_type::NeverType;
5use crate::records::primitive_type::PrimitiveType;
6use crate::records::singleton_type::SingletonType;
7use crate::type_aliases::type_id::TypeId;
8
9pub fn is_normalized_boolean(ty: TypeId) -> bool {
10 unsafe {
11 if get_type_id::<NeverType>(ty).is_null() {
12 return true;
13 } else if let Some(ptv) = get_type_id::<PrimitiveType>(ty).as_ref() {
14 return ptv.r#type == PrimitiveType::Boolean;
15 } else if let Some(stv) = get_type_id::<SingletonType>(ty).as_ref() {
16 return !get_singleton_type::<BooleanSingleton>(stv as *const SingletonType).is_null();
17 } else {
18 return false;
19 }
20 }
21}