luaur-analysis 0.1.1

Luau type checker and type inference (Rust).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::records::lint_table_operations::LintTableOperations;
use luaur_ast::records::ast_expr::AstExpr;
use luaur_ast::records::ast_expr_constant_number::AstExprConstantNumber;
use luaur_ast::rtti::ast_node_as;

impl LintTableOperations {
    pub fn is_constant(&mut self, expr: *mut AstExpr, value: f64) -> bool {
        let n = unsafe { ast_node_as::<AstExprConstantNumber>(expr as *mut _) };
        if !n.is_null() {
            unsafe { (*n).value == value }
        } else {
            false
        }
    }
}