Skip to main content

luaur_bytecode/records/
bc_get_table_ks.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::{BcFunction, VmConst};
8use crate::records::bc_inst::BcInst;
9use crate::records::bc_inst_helper::BcInstHelper;
10use crate::records::bc_op::BcOp;
11use crate::records::bc_ref::BcRef;
12use crate::type_aliases::reg::Reg;
13
14#[derive(Debug)]
15pub struct BcGetTableKS<'a, T = VmConst> {
16    pub(crate) base: BcInstHelper<'a>,
17    _marker: PhantomData<T>,
18}
19
20impl<'a, T> BcGetTableKS<'a, T> {
21    pub fn from(graph: *mut BcFunction, inst: BcRef<'a, BcInst>) -> Self {
22        Self {
23            base: BcInstHelper::new(unsafe { &mut *graph }, inst),
24            _marker: PhantomData,
25        }
26    }
27
28    pub fn source(&mut self) -> BcOp {
29        self.base.get_bc_op(0)
30    }
31
32    pub fn set_source(&mut self, value: BcOp) {
33        self.base.set_bc_op(0, value);
34    }
35
36    pub fn set_hint(&mut self, value: u32) {
37        self.base.set_imm_input(1, value as i32);
38    }
39
40    pub fn set_key(&mut self, value: u32) {
41        self.base.set_vm_const(2, value);
42    }
43
44    pub fn create(graph: &'a mut BcFunction) -> Self {
45        Self {
46            base: BcInstHelper::create::<Self>(graph),
47            _marker: PhantomData,
48        }
49    }
50
51    pub fn set_out_reg(&mut self, out: Reg) {
52        self.base.set_out_reg(out);
53    }
54
55    pub fn append_to(&mut self, block: BcOp) {
56        self.base.append_to(block);
57    }
58
59    pub fn op(&self) -> BcOp {
60        self.base.op()
61    }
62}
63
64impl<T> BcInstType for BcGetTableKS<'_, T> {
65    const OPCODE: i32 = LuauOpcode::LOP_GETTABLEKS as i32;
66}
67
68impl<T> BcInstHelperCreate for BcGetTableKS<'_, T> {
69    const OPCODE: LuauOpcode = LuauOpcode::LOP_GETTABLEKS;
70}