Skip to main content

luaur_compiler/methods/
compiler_compile_expr_varargs.rs

1use crate::records::compiler::Compiler;
2use luaur_ast::records::ast_expr_varargs::AstExprVarargs;
3use luaur_common::enums::luau_opcode::LuauOpcode;
4use luaur_common::macros::luau_assert::LUAU_ASSERT;
5
6impl Compiler {
7    pub fn compile_expr_varargs(
8        &mut self,
9        expr: *mut AstExprVarargs,
10        target: u8,
11        target_count: u8,
12        mult_ret: bool,
13    ) {
14        LUAU_ASSERT!(target_count < 255);
15        LUAU_ASSERT!(!mult_ret || u32::from(target) + u32::from(target_count) == self.reg_top);
16
17        self.set_debug_line_ast_node(expr as *mut luaur_ast::records::ast_node::AstNode);
18
19        unsafe {
20            let bytecode = &mut *self.bytecode;
21            bytecode.emit_abc(
22                LuauOpcode::LOP_GETVARARGS,
23                target,
24                if mult_ret {
25                    0
26                } else {
27                    target_count.wrapping_add(1)
28                },
29                0,
30            );
31        }
32    }
33}