luaur_analysis/methods/
dcr_logger_capture_generation_module.rs1use crate::records::annotation_types_at_location::AnnotationTypesAtLocation;
2use crate::records::dcr_logger::DcrLogger;
3use crate::records::expr_types_at_location::ExprTypesAtLocation;
4use crate::type_aliases::module_ptr_module::ModulePtr;
5
6impl DcrLogger {
7 pub fn capture_generation_module(&mut self, module: ModulePtr) {
8 let module_ref = &*module;
9
10 self.generation_log
11 .expr_type_locations
12 .reserve(module_ref.ast_types.size());
13 for (expr, ty) in module_ref.ast_types.iter() {
14 let expr = *expr;
15 let mut tys = ExprTypesAtLocation {
16 location: unsafe { (*expr).base.location },
17 ty: *ty,
18 expected_ty: None,
19 };
20
21 if let Some(expected_ty) = module_ref.ast_expected_types.find(&expr) {
22 tys.expected_ty = Some(*expected_ty);
23 }
24
25 self.generation_log.expr_type_locations.push(tys);
26 }
27
28 self.generation_log
29 .annotation_type_locations
30 .reserve(module_ref.ast_resolved_types.size());
31 for (annot, ty) in module_ref.ast_resolved_types.iter() {
32 let annot = *annot;
33 let tys = AnnotationTypesAtLocation {
34 location: unsafe { (*annot).base.location },
35 resolved_ty: *ty,
36 };
37
38 self.generation_log.annotation_type_locations.push(tys);
39 }
40 }
41}