luaur_analysis/methods/
constraint_graph_find_reverse_dependency_list.rs1use crate::records::constraint_graph::ConstraintGraph;
2use crate::records::constraint_list::ConstraintList;
3use crate::records::r#type::Type;
4use crate::type_aliases::constraint_vertex::ConstraintVertex;
5use core::ptr::NonNull;
6use luaur_common::macros::luau_assert::LUAU_ASSERT;
7use luaur_common::records::dense_hash_map::DenseHashMap;
8
9impl ConstraintGraph {
10 pub fn find_reverse_dependency_list(
11 &mut self,
12 vertex: ConstraintVertex,
13 ) -> NonNull<ConstraintList> {
14 if let Some(rdep) = self.reverse_dependencies.find(&vertex) {
15 return NonNull::new(*rdep).unwrap();
16 }
17
18 self.constraint_lists.push(Box::new(ConstraintList {
19 present: DenseHashMap::new(ConstraintVertex::V0(core::ptr::null::<Type>())),
20 order: Vec::new(),
21 entries: 0,
22 }));
23 let newlist =
24 NonNull::new(&mut **self.constraint_lists.last_mut().unwrap() as *mut ConstraintList)
25 .unwrap();
26
27 let (_it, fresh) = self
28 .reverse_dependencies
29 .try_insert(vertex, newlist.as_ptr());
30 LUAU_ASSERT!(fresh);
31 newlist
32 }
33}