Skip to main content

luaur_analysis/methods/
usage_finder_usage_finder.rs

1use crate::records::data_flow_graph::DataFlowGraph;
2use crate::records::usage_finder::UsageFinder;
3use crate::type_aliases::name_type::Name;
4use alloc::string::ToString;
5use alloc::vec::Vec;
6
7impl UsageFinder {
8    pub fn usage_finder(dfg: *mut DataFlowGraph) -> Self {
9        // Field initializers: referencedBindings{""}, referencedImportedBindings{{"", ""}}.
10        let mut referenced_bindings: Vec<Name> = Vec::new();
11        referenced_bindings.push("".to_string());
12
13        let mut referenced_imported_bindings: Vec<(Name, Name)> = Vec::new();
14        referenced_imported_bindings.push(("".to_string(), "".to_string()));
15
16        // We explicitly suggest that the usage finder populate types for instance and enum by default
17        // These are common enough types that sticking them in the environment is a good idea
18        // and it lets magic functions work correctly too.
19        referenced_bindings.push("Instance".to_string());
20        referenced_bindings.push("Enum".to_string());
21
22        UsageFinder {
23            dfg,
24            declared_aliases: Default::default(),
25            local_bindings_referenced: Vec::new(),
26            mentioned_defs: Default::default(),
27            referenced_bindings,
28            referenced_imported_bindings,
29            global_defs_to_pre_populate: Vec::new(),
30            global_functions_referenced: Vec::new(),
31            symbols_to_refine: Vec::new(),
32        }
33    }
34}