luaur_analysis/methods/
constraint_graph_add_dependency_of_constraint_graph.rs1use crate::records::constraint_graph::ConstraintGraph;
2use crate::type_aliases::constraint_vertex::ConstraintVertex;
3use luaur_common::macros::luau_assert::LUAU_ASSERT;
4
5impl ConstraintGraph {
6 pub fn add_dependency_of_constraint_vertex_constraint_vertex(
7 &mut self,
8 dependency: ConstraintVertex,
9 target: ConstraintVertex,
10 ) -> bool {
11 let deps = self.find_dependency_list(target.clone());
12 let reverse_deps = self.find_reverse_dependency_list(dependency.clone());
13
14 let deps_ref = unsafe { &*deps.as_ptr() };
15 if deps_ref.contains(target.clone()) {
16 let reverse_deps_ref = unsafe { &*reverse_deps.as_ptr() };
17 LUAU_ASSERT!(reverse_deps_ref.contains(dependency.clone()));
18 return false;
19 }
20
21 let mut deps_mut = unsafe { &mut *deps.as_ptr() };
22 deps_mut.insert(dependency.clone());
23
24 let mut reverse_deps_mut = unsafe { &mut *reverse_deps.as_ptr() };
25 reverse_deps_mut.insert(target);
26
27 true
28 }
29}