Skip to main content

luaur_analysis/methods/
normalizer_intersect_functions_with_function.rs

1use crate::functions::get_type_alt_j::get_type_id;
2use crate::records::normalized_function_type::NormalizedFunctionType;
3use crate::records::normalizer::Normalizer;
4use crate::records::type_ids::TypeIds;
5use crate::type_aliases::error_type::ErrorType;
6use crate::type_aliases::type_id::TypeId;
7
8impl Normalizer {
9    pub fn intersect_functions_with_function(
10        &mut self,
11        heres: &mut NormalizedFunctionType,
12        there: TypeId,
13    ) {
14        self.consume_fuel();
15
16        if heres.is_never() {
17            return;
18        }
19
20        heres.is_top = false;
21
22        let current_parts = heres.parts.order.clone();
23        for here in current_parts {
24            let error_ptr = unsafe { get_type_id::<ErrorType>(here) };
25            if !error_ptr.is_null() {
26                continue;
27            }
28
29            if let Some(tmp) = self.intersection_of_functions(here, there) {
30                heres.parts.erase_type_id(here);
31                heres.parts.insert_type_id(tmp);
32                return;
33            }
34        }
35
36        let mut tmps = TypeIds::type_ids();
37        for here in &heres.parts.order {
38            if let Some(tmp) = self.union_saturated_functions(*here, there) {
39                tmps.insert_type_id(tmp);
40            }
41        }
42        heres.parts.insert_type_id(there);
43        for ty in tmps.order {
44            heres.parts.insert_type_id(ty);
45        }
46    }
47}