luaur_analysis/functions/
is_being_defined.rs1use luaur_ast::records::ast_local::AstLocal;
2use luaur_ast::records::ast_node::AstNode;
3use luaur_ast::records::ast_stat_local::AstStatLocal;
4use luaur_ast::rtti::ast_node_as;
5
6use crate::records::symbol::Symbol;
7
8pub fn is_being_defined(ancestry: &alloc::vec::Vec<*mut AstNode>, symbol: &Symbol) -> bool {
9 if symbol.local.is_null() {
10 return false;
11 }
12
13 let mut iter = ancestry.len();
14 while iter > 0 {
15 iter -= 1;
16 let node = ancestry[iter];
17 let stat_local = unsafe { ast_node_as::<AstStatLocal>(node as *mut AstNode) };
18 if stat_local.is_null() {
19 continue;
20 }
21
22 let vars = unsafe { &(*stat_local).vars };
23 for var in vars {
24 if *var == symbol.local {
25 return true;
26 }
27 }
28 }
29
30 false
31}