Skip to main content

luaur_analysis/methods/
dfg_scope_lookup_data_flow_graph_alt_b.rs

1use crate::records::dfg_scope::DfgScope;
2use crate::type_aliases::def_id_def::DefId;
3use alloc::string::String;
4
5impl DfgScope {
6    pub fn lookup_def_id_string(&self, def: DefId, key: &String) -> Option<DefId> {
7        // C++: for (current = this; current; current = current->parent)
8        //          if (auto props = current->props.find(def))
9        //              if (auto it = props->find(key); it != props->end())
10        //                  return NotNull{it->second};
11        let mut current: Option<&DfgScope> = Some(self);
12        while let Some(scope) = current {
13            if let Some(props) = scope.props.find(&def) {
14                if let Some(value) = props.get(key) {
15                    return Some(*value);
16                }
17            }
18            current = unsafe { scope.parent.as_ref() };
19        }
20        None
21    }
22}