Skip to main content

luaur_analysis/methods/
constraint_generator_run.rs

1use crate::records::constraint_generator::ConstraintGenerator;
2use crate::records::constraint_set::ConstraintSet;
3use crate::records::type_ids::TypeIds;
4use luaur_ast::records::ast_stat_block::AstStatBlock;
5use luaur_common::records::dense_hash_map::DenseHashMap;
6
7impl ConstraintGenerator {
8    pub fn run(&mut self, block: *mut AstStatBlock) -> ConstraintSet {
9        self.visit_module_root(block);
10
11        ConstraintSet {
12            root_scope: self.root_scope,
13            constraints: core::mem::take(&mut self.constraints),
14            free_types: core::mem::replace(&mut self.free_types, TypeIds::type_ids()),
15            scope_to_function: core::mem::replace(
16                &mut self.scope_to_function,
17                DenseHashMap::new(core::ptr::null_mut()),
18            ),
19            errors: core::mem::take(&mut self.errors),
20        }
21    }
22}