Skip to main content

luaur_compiler/methods/
compiler_are_locals_captured.rs

1use crate::records::compiler::Compiler;
2use luaur_common::macros::luau_assert::LUAU_ASSERT;
3
4impl Compiler {
5    pub fn are_locals_captured(&mut self, start: usize) -> bool {
6        LUAU_ASSERT!(start <= self.local_stack.len());
7
8        for i in start..self.local_stack.len() {
9            let local = self.local_stack[i];
10            let l = self.locals.find(&local);
11            LUAU_ASSERT!(l.is_some());
12
13            if l.map_or(false, |l| l.captured) {
14                return true;
15            }
16        }
17
18        false
19    }
20}