luaur_analysis/functions/
is_normalized_string.rs1use crate::functions::get_singleton_type::get_singleton_type;
2use crate::functions::get_type_alt_j::get_type_id;
3use crate::records::normalized_string_type::NormalizedStringType;
4use crate::records::singleton_type::SingletonType;
5use crate::records::string_singleton::StringSingleton;
6
7pub fn is_normalized_string(ty: &NormalizedStringType) -> bool {
8 if ty.is_string() {
9 return true;
10 }
11
12 for (str, &type_id) in &ty.singletons {
13 unsafe {
14 let stv = get_type_id::<SingletonType>(type_id);
15 if stv.is_null() {
16 return false;
17 }
18
19 let sstv = get_singleton_type::<StringSingleton>(stv);
20 if sstv.is_null() {
21 return false;
22 }
23
24 if (*sstv).value != *str {
25 return false;
26 }
27 }
28 }
29
30 true
31}