luaur_analysis/methods/
dfg_scope_inherit.rs1use crate::records::def::Def;
2use crate::records::dfg_scope::DfgScope;
3use crate::records::symbol::Symbol;
4use alloc::string::String;
5
6impl DfgScope {
7 pub fn inherit(&mut self, child_scope: *const DfgScope) {
8 unsafe {
15 let child_bindings: alloc::vec::Vec<(Symbol, *const Def)> = (*child_scope)
16 .bindings
17 .iter()
18 .map(|(k, a)| (k.clone(), *a))
19 .collect();
20 for (k, a) in child_bindings {
21 if self.lookup_symbol(k.clone()).is_some() {
22 *self.bindings.get_or_insert(k) = a;
23 }
24 }
25
26 let child_props: alloc::vec::Vec<(*const Def, alloc::vec::Vec<(String, *const Def)>)> =
27 (*child_scope)
28 .props
29 .iter()
30 .map(|(k1, a1)| (*k1, a1.iter().map(|(k2, a2)| (k2.clone(), *a2)).collect()))
31 .collect();
32 for (k1, a1) in child_props {
33 let entry = self.props.get_or_insert(k1);
34 for (k2, a2) in a1 {
35 entry.insert(k2, a2);
36 }
37 }
38 }
39 }
40}