Skip to main content

luaur_analysis/methods/
constraint_graph_shift_references.rs

1use crate::records::constraint_graph::ConstraintGraph;
2use crate::records::reference_count_initializer::ReferenceCountInitializer;
3use crate::records::type_ids::TypeIds;
4use crate::type_aliases::constraint_vertex::ConstraintVertex;
5use crate::type_aliases::type_id::TypeId;
6use crate::type_aliases::type_pack_id::TypePackId;
7use crate::type_aliases::type_pack_ids::TypePackIds;
8
9impl ConstraintGraph {
10    pub fn shift_references_type_id(&mut self, source: TypeId, target: TypeId) {
11        if source == target {
12            return;
13        }
14
15        let source_dependencies = self.find_dependency_list(ConstraintVertex::V0(source));
16
17        let mut mutated_types = TypeIds::type_ids();
18        let mut mutated_type_packs = TypePackIds::new(core::ptr::null_mut());
19
20        let _rci =
21            ReferenceCountInitializer::reference_count_initializer_reference_count_initializer(
22                &mut mutated_types as *mut TypeIds,
23                &mut mutated_type_packs as *mut TypePackIds,
24            );
25
26        self.copy_dependencies_to_reachable_types(
27            Some(ConstraintVertex::V0(source)),
28            source_dependencies,
29            mutated_types,
30            mutated_type_packs,
31        );
32
33        self.clear_reverse_dependencies_of(ConstraintVertex::V0(source));
34
35        let _ = target;
36    }
37
38    pub fn shift_references_type_pack_id(&mut self, source: TypePackId, target: TypePackId) {
39        if source == target {
40            return;
41        }
42
43        let source_dependencies = self.find_dependency_list(ConstraintVertex::V1(source));
44
45        let mut mutated_types = TypeIds::type_ids();
46        let mut mutated_type_packs = TypePackIds::new(core::ptr::null_mut());
47
48        let _rci =
49            ReferenceCountInitializer::reference_count_initializer_reference_count_initializer(
50                &mut mutated_types as *mut TypeIds,
51                &mut mutated_type_packs as *mut TypePackIds,
52            );
53
54        self.copy_dependencies_to_reachable_types(
55            Some(ConstraintVertex::V1(source)),
56            source_dependencies,
57            mutated_types,
58            mutated_type_packs,
59        );
60
61        self.clear_reverse_dependencies_of(ConstraintVertex::V1(source));
62
63        let _ = target;
64    }
65}