Skip to main content

luaur_bytecode/records/
bc_load_nil.rs

1use core::marker::PhantomData;
2
3use luaur_common::enums::luau_opcode::LuauOpcode;
4
5use crate::methods::bc_function_as::BcInstType;
6use crate::methods::bc_inst_helper_create::BcInstHelperCreate;
7use crate::records::bc_function::VmConst;
8use crate::records::bc_inst_helper::BcInstHelper;
9use crate::records::bc_op::BcOp;
10use crate::type_aliases::reg::Reg;
11
12#[derive(Debug)]
13pub struct BcLoadNil<'a, T = VmConst> {
14    pub(crate) base: BcInstHelper<'a>,
15    _marker: PhantomData<T>,
16}
17
18impl<T> BcInstType for BcLoadNil<'_, T> {
19    const OPCODE: i32 = LuauOpcode::LOP_LOADNIL as i32;
20}
21
22impl<T> BcInstHelperCreate for BcLoadNil<'_, T> {
23    const OPCODE: LuauOpcode = LuauOpcode::LOP_LOADNIL;
24}
25
26impl<'a, T> BcLoadNil<'a, T> {
27    pub fn create(graph: &'a mut crate::records::bc_function::BcFunction) -> Self {
28        Self {
29            base: BcInstHelper::create::<Self>(graph),
30            _marker: PhantomData,
31        }
32    }
33
34    pub fn set_out_reg(&mut self, out: Reg) {
35        self.base.set_out_reg(out);
36    }
37
38    pub fn prepend_to(&mut self, block: BcOp) {
39        self.base.prepend_to(block);
40    }
41
42    pub fn append_to(&mut self, block: BcOp) {
43        self.base.append_to(block);
44    }
45
46    pub fn op(&self) -> BcOp {
47        self.base.op()
48    }
49}