Skip to main content

luaur_analysis/methods/
constraint_graph_dump_blocked.rs

1use crate::functions::to_string_to_string_alt_m::to_string_type_id_to_string_options;
2use crate::functions::to_string_to_string_alt_n::to_string_type_pack_id_to_string_options;
3use crate::functions::to_string_to_string_alt_q::to_string_constraint_to_string_options;
4use crate::records::constraint::Constraint;
5use crate::records::constraint_graph::ConstraintGraph;
6use crate::records::to_string_options::ToStringOptions;
7use crate::type_aliases::constraint_vertex::ConstraintVertex;
8use core::ptr::NonNull;
9
10impl ConstraintGraph {
11    pub fn dump_blocked(&mut self, c: NonNull<Constraint>, opts: &mut ToStringOptions) {
12        std::print!("Blocked on:\n");
13        let c_ptr = c.as_ptr() as *const Constraint;
14        let deps = self.find_dependency_list(ConstraintVertex::V2(c_ptr));
15        let deps_ref = unsafe { deps.as_ref() };
16        for dep in deps_ref.order.iter() {
17            // The C++ `for (auto dep : *deps)` iterates only present entries.
18            if !deps_ref.contains(dep.clone()) {
19                continue;
20            }
21
22            if let Some(ty) = dep.get_if_0() {
23                std::print!(
24                    "\tType {}\n",
25                    to_string_type_id_to_string_options(*ty, opts)
26                );
27            } else if let Some(tp) = dep.get_if_1() {
28                std::print!(
29                    "\tPack {}\n",
30                    to_string_type_pack_id_to_string_options(*tp, opts)
31                );
32            } else if let Some(cons) = dep.get_if_2() {
33                std::print!(
34                    "\tCons {}\n",
35                    to_string_constraint_to_string_options(unsafe { &**cons }, opts)
36                );
37            }
38        }
39    }
40}