luaur_compiler/methods/
compiler_close_locals.rs1use crate::records::compiler::Compiler;
2use luaur_common::enums::luau_opcode::LuauOpcode;
3use luaur_common::macros::luau_assert::LUAU_ASSERT;
4
5impl Compiler {
6 pub fn close_locals(&mut self, start: usize) {
7 LUAU_ASSERT!(start <= self.local_stack.len());
8 let mut captured = false;
9 let mut capture_reg = 255u8;
10 for i in start..self.local_stack.len() {
11 let local_ptr = self.local_stack[i];
12 if let Some(l) = self.locals.find(&local_ptr) {
13 if l.captured {
14 captured = true;
15 capture_reg = capture_reg.min(l.reg);
16 }
17 }
18 }
19 if captured {
20 unsafe {
21 (*self.bytecode).emit_abc(LuauOpcode::LOP_CLOSEUPVALS, capture_reg, 0, 0);
22 }
23 }
24 }
25}