Skip to main content

luaur_analysis/methods/
constraint_generator_add_constraint_constraint_generator.rs

1use crate::records::constraint::Constraint;
2use crate::records::constraint_generator::ConstraintGenerator;
3use crate::type_aliases::constraint_v::ConstraintV;
4use crate::type_aliases::scope_ptr_constraint_generator::ScopePtr;
5use luaur_ast::records::location::Location;
6
7impl ConstraintGenerator {
8    pub fn add_constraint_scope_ptr_location_constraint_v(
9        &mut self,
10        scope: &ScopePtr,
11        location: Location,
12        cv: ConstraintV,
13    ) -> *mut Constraint {
14        let c = Box::new(Constraint {
15            scope: scope.as_ref() as *const _ as *mut _,
16            location,
17            c: cv,
18            deprecated_dependencies: alloc::vec::Vec::new(),
19        });
20        let c_ptr = Box::into_raw(c);
21        self.constraints.push(c_ptr);
22        c_ptr
23    }
24}