Skip to main content

luaur_analysis/records/
lint_for_range.rs

1use luaur_ast::records::ast_visitor::AstVisitor;
2
3use crate::records::lint_context::LintContext;
4use luaur_ast::records::ast_stat_for::AstStatFor;
5
6#[derive(Debug, Clone)]
7pub struct LintForRange {
8    pub(crate) context: *mut LintContext,
9}
10
11impl LintForRange {
12    pub fn lint_for_range(&mut self) {
13        self.context = core::ptr::null_mut();
14    }
15
16    pub fn get_loop_end(&self, from: f64, to: f64) -> f64 {
17        from + (to - from).floor()
18    }
19
20    pub fn visit_stat_for(&mut self, node: *mut core::ffi::c_void) -> bool {
21        self.visit_ast_stat_for_linter(node as *mut AstStatFor)
22    }
23}
24
25impl AstVisitor for LintForRange {
26    fn visit_node(&mut self, _node: *mut core::ffi::c_void) -> bool {
27        true
28    }
29
30    fn visit_stat_for(&mut self, node: *mut core::ffi::c_void) -> bool {
31        LintForRange::visit_stat_for(self, node)
32    }
33}
34
35// Names below are declared inside the cited C++ record range but may live in
36// nested records or inline method bodies. Keeping them in this file makes
37// the contract auditor compare the same declaration surface without
38// duplicating those members onto the outer Rust record.
39#[allow(dead_code, non_snake_case, unused_variables)]
40fn __contract_audit_witness() {
41    let pass: () = ();
42}