luaur_analysis/methods/
stringifier_state_stringifier_state.rs1use crate::records::set::Set;
5use crate::records::stringifier_state::StringifierState;
6use crate::records::to_string_options::ToStringOptions;
7use crate::records::to_string_result::ToStringResult;
8use alloc::string::String;
9use luaur_common::records::dense_hash_map::DenseHashMap;
10use luaur_common::records::dense_hash_set::DenseHashSet;
11
12impl StringifierState {
13 pub fn stringifier_state_stringifier_state(
17 opts: *mut ToStringOptions,
18 result: *mut ToStringResult,
19 ) -> Self {
20 unsafe {
21 let o = &*opts;
22 let mut state = StringifierState {
23 opts,
24 result,
25 cycle_names: DenseHashMap::new(core::ptr::null()),
26 cycle_tp_names: DenseHashMap::new(core::ptr::null()),
27 seen: Set::new(core::ptr::null_mut()),
28 used_names: DenseHashSet::new(String::from("$$$")),
31 indentation: 0,
32 exhaustive: o.exhaustive,
33 ignore_synthetic_name: o.ignore_synthetic_name,
34 previous_name_index: 0,
35 };
36
37 for (_k, v) in o.name_map.types.iter() {
38 state.used_names.insert(v.clone());
39 }
40 for (_k, v) in o.name_map.type_packs.iter() {
41 state.used_names.insert(v.clone());
42 }
43
44 state
45 }
46 }
47}