Skip to main content

luaur_analysis/methods/
unifier_make_child_unifier.rs

1use crate::records::txn_log::TxnLog;
2use crate::records::unifier::Unifier;
3use alloc::boxed::Box;
4use alloc::vec::Vec;
5use luaur_common::records::dense_hash_map::DenseHashMap;
6
7impl Unifier {
8    pub fn unifier_make_child_unifier(&mut self) -> Box<Unifier> {
9        let parent_log: *mut TxnLog = &mut self.log;
10
11        let u = Box::new(Unifier {
12            types: self.types,
13            builtin_types: self.builtin_types,
14            normalizer: self.normalizer,
15            scope: self.scope,
16            log: TxnLog {
17                type_var_changes: DenseHashMap::new(core::ptr::null()),
18                type_pack_changes: DenseHashMap::new(core::ptr::null()),
19                parent: parent_log,
20                owned_seen: Vec::new(),
21                // Child borrows the parent's seen set; it does not own/free it.
22                shared_seen: self.log.shared_seen,
23                owned_seen_box: None,
24                radioactive: false,
25            },
26            failure: false,
27            errors: Vec::new(),
28            location: self.location,
29            variance: self.variance,
30            normalize: self.normalize,
31            check_inhabited: self.check_inhabited,
32            ctx: self.ctx,
33            shared_state: self.shared_state,
34            blocked_types: Vec::new(),
35            blocked_type_packs: Vec::new(),
36            first_pack_error_pos: None,
37        });
38
39        u
40    }
41}