luaur_analysis/methods/
constraint_graph_find_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_dependency_list(&mut self, vertex: ConstraintVertex) -> NonNull<ConstraintList> {
11 if let Some(dep) = self.dependencies.find(&vertex) {
12 return NonNull::new(*dep).unwrap();
13 }
14
15 self.constraint_lists.push(Box::new(ConstraintList {
16 present: DenseHashMap::new(ConstraintVertex::V0(core::ptr::null::<Type>())),
17 order: Vec::new(),
18 entries: 0,
19 }));
20 let newlist =
21 NonNull::new(&mut **self.constraint_lists.last_mut().unwrap() as *mut ConstraintList)
22 .unwrap();
23
24 let (_it, fresh) = self.dependencies.try_insert(vertex, newlist.as_ptr());
25 LUAU_ASSERT!(fresh);
26 newlist
27 }
28}