Skip to main content

luaur_analysis/records/
find_simplification_blockers.rs

1use crate::records::blocked_type::BlockedType;
2use crate::records::extern_type::ExternType;
3use crate::records::free_type::FreeType;
4use crate::records::function_type::FunctionType;
5use crate::records::iterative_type_visitor::IterativeTypeVisitor;
6use crate::records::pending_expansion_type::PendingExpansionType;
7use crate::type_aliases::type_id::TypeId;
8
9#[derive(Debug, Clone)]
10pub struct FindSimplificationBlockers {
11    pub base: IterativeTypeVisitor,
12    pub found: bool,
13}
14
15impl FindSimplificationBlockers {
16    pub fn find_simplification_blockers(&mut self) {
17        self.base.visit_once = true;
18    }
19
20    pub fn visit(&mut self, _ty: TypeId) -> bool {
21        !self.found
22    }
23
24    pub fn visit_blocked_type(&mut self, _ty: TypeId, _btv: &BlockedType) -> bool {
25        self.found = true;
26        false
27    }
28
29    pub fn visit_free_type(&mut self, _ty: TypeId, _ftv: &FreeType) -> bool {
30        self.found = true;
31        false
32    }
33
34    pub fn visit_pending_expansion_type(
35        &mut self,
36        _ty: TypeId,
37        _petv: &PendingExpansionType,
38    ) -> bool {
39        self.found = true;
40        false
41    }
42
43    pub fn visit_function_type(&mut self, _ty: TypeId, _ftv: &FunctionType) -> bool {
44        false
45    }
46
47    pub fn visit_extern_type(&mut self, _ty: TypeId, _etv: &ExternType) -> bool {
48        false
49    }
50}