Skip to main content

luaur_analysis/functions/
match_assert.rs

1use luaur_ast::records::ast_expr_call::AstExprCall;
2use luaur_ast::records::ast_expr_global::AstExprGlobal;
3
4pub fn match_assert(call: &AstExprCall) -> bool {
5    if call.args.len() < 1 {
6        return false;
7    }
8
9    let func_as_global = unsafe {
10        luaur_ast::rtti::ast_node_as::<AstExprGlobal>(
11            call.func as *mut luaur_ast::records::ast_node::AstNode,
12        )
13    };
14
15    if func_as_global.is_null() {
16        return false;
17    }
18
19    unsafe {
20        let name = (*func_as_global).name.value;
21        if name.is_null() {
22            return false;
23        }
24
25        let name_bytes = core::ffi::CStr::from_ptr(name).to_bytes();
26        name_bytes == b"assert"
27    }
28}