Skip to main content

luaur_bytecode/records/
bc_set_list.rs

1use core::marker::PhantomData;
2
3use alloc::vec::Vec;
4use luaur_common::enums::luau_opcode::LuauOpcode;
5
6use crate::methods::bc_function_as::BcInstType;
7use crate::methods::bc_inst_helper_create::BcInstHelperCreate;
8use crate::records::bc_function::{BcFunction, VmConst};
9use crate::records::bc_inst::BcInst;
10use crate::records::bc_inst_helper::BcInstHelper;
11use crate::records::bc_op::BcOp;
12use crate::records::bc_ref::BcRef;
13
14#[derive(Debug)]
15pub struct BcSetList<'a, T = VmConst> {
16    pub(crate) base: BcInstHelper<'a>,
17    _marker: PhantomData<T>,
18}
19
20impl<'a, T> BcSetList<'a, T> {
21    pub const K_PARAM_START_INPUT: u32 = 2;
22
23    pub fn from(graph: *mut BcFunction, inst: BcRef<'a, BcInst>) -> Self {
24        Self {
25            base: BcInstHelper::new(unsafe { &mut *graph }, inst),
26            _marker: PhantomData,
27        }
28    }
29
30    pub fn count(&mut self) -> i32 {
31        self.base.int_imm_input(1)
32    }
33
34    pub fn set_count(&mut self, value: u32) {
35        self.base.set_imm_input(1, value as i32);
36    }
37
38    pub fn params(&self) -> Vec<BcOp> {
39        self.base.slice_inputs(Self::K_PARAM_START_INPUT)
40    }
41}
42
43impl<T> BcInstType for BcSetList<'_, T> {
44    const OPCODE: i32 = LuauOpcode::LOP_SETLIST as i32;
45}
46
47impl<T> BcInstHelperCreate for BcSetList<'_, T> {
48    const OPCODE: LuauOpcode = LuauOpcode::LOP_SETLIST;
49}