Skip to main content

luaur_analysis/methods/
clone_public_interface_clean_module_alt_b.rs

1use crate::functions::get_mutable_type_pack::get_mutable_type_pack_id;
2use crate::functions::get_type_pack::get_type_pack_id;
3use crate::records::blocked_type_pack::BlockedTypePack;
4use crate::records::clone_public_interface::ClonePublicInterface;
5use crate::records::free_type_pack::FreeTypePack;
6use crate::records::generic_type_pack::GenericTypePack;
7use crate::type_aliases::type_pack_id::TypePackId;
8
9impl ClonePublicInterface {
10    /// `TypePackId ClonePublicInterface::clean(TypePackId tp)`.
11    /// Reference: `Module.cpp:210-229`.
12    pub fn clean_type_pack_id(&mut self, tp: TypePackId) -> TypePackId {
13        if self.is_new_solver() {
14            if unsafe {
15                !get_type_pack_id::<FreeTypePack>(tp).is_null()
16                    || !get_type_pack_id::<BlockedTypePack>(tp).is_null()
17            } {
18                self.internal_type_escaped = true;
19                return unsafe { (*self.builtin_types).errorTypePack };
20            }
21
22            let cloned_tp = self.base.clone_type_pack_id(tp);
23            let gtp = unsafe { get_mutable_type_pack_id::<GenericTypePack>(cloned_tp) };
24            if !gtp.is_null() {
25                unsafe { (*gtp).scope = core::ptr::null_mut() };
26            }
27            cloned_tp
28        } else {
29            self.base.clone_type_pack_id(tp)
30        }
31    }
32}