Skip to main content

luaur_analysis/methods/
normalizer_normalizer_normalize_alt_e.rs

1use crate::enums::solver_mode::SolverMode;
2use crate::records::builtin_types::BuiltinTypes;
3use crate::records::normalizer::Normalizer;
4use crate::records::type_arena::TypeArena;
5use crate::records::unifier_shared_state::UnifierSharedState;
6use luaur_common::records::dense_hash_map::DenseHashMap;
7
8impl Normalizer {
9    /// C++ `Normalizer::Normalizer(TypeArena*, NotNull<BuiltinTypes>,
10    /// NotNull<UnifierSharedState>, SolverMode, bool cacheInhabitance = false)`
11    /// (`Analysis/src/Normalize.cpp:858`). Owned constructor: the five
12    /// collaborators are stored; every cache is default-empty (the
13    /// `DenseHashMap`s take their `nullptr` empty-key, matching the C++
14    /// member initializers `{nullptr}` / `{{nullptr, nullptr}}`).
15    pub fn new(
16        arena: *mut TypeArena,
17        builtin_types: *mut BuiltinTypes,
18        shared_state: *mut UnifierSharedState,
19        solver_mode: SolverMode,
20        cache_inhabitance: bool,
21    ) -> Self {
22        Normalizer {
23            cached_normals: alloc::collections::BTreeMap::new(),
24            cached_intersections: alloc::collections::BTreeMap::new(),
25            cached_unions: alloc::collections::BTreeMap::new(),
26            cached_type_ids: alloc::collections::BTreeMap::new(),
27            cached_is_inhabited: DenseHashMap::new(core::ptr::null()),
28            cached_is_inhabited_intersection: DenseHashMap::new((
29                core::ptr::null(),
30                core::ptr::null(),
31            )),
32            fuel: None,
33            arena,
34            builtin_types,
35            shared_state,
36            cache_inhabitance,
37            solver_mode,
38        }
39    }
40
41    pub fn normalizer_type_arena_not_null_builtin_types_not_null_unifier_shared_state_solver_mode_bool(
42        &mut self,
43        arena: *mut TypeArena,
44        builtin_types: *mut BuiltinTypes,
45        shared_state: *mut UnifierSharedState,
46        solver_mode: SolverMode,
47        cache_inhabitance: bool,
48    ) {
49        self.arena = arena;
50        self.builtin_types = builtin_types;
51        self.shared_state = shared_state;
52        self.cache_inhabitance = cache_inhabitance;
53        self.solver_mode = solver_mode;
54    }
55}