Skip to main content

luaur_bytecode/methods/
bc_inst_helper_set_vm_const.rs

1use crate::enums::bc_op_kind::BcOpKind;
2use crate::records::bc_inst_helper::BcInstHelper;
3use crate::records::bc_op::BcOp;
4use luaur_common::macros::luau_assert::LUAU_ASSERT;
5
6impl BcInstHelper<'_> {
7    pub fn set_vm_const(&mut self, input_idx: u32, cid: u32) {
8        LUAU_ASSERT!(cid < self.graph.constants.len() as u32);
9        self.set_bc_op(
10            input_idx,
11            BcOp::bc_op_bc_op_kind_u32(BcOpKind::VmConst, cid),
12        );
13    }
14}
15
16impl<'a, T> crate::records::bc_ref::BcRef<'a, T> {
17    pub(crate) fn operator_deref_mut(&mut self) -> &mut T {
18        unsafe { &mut *(self.vec.as_ptr().add(self.op.index as usize) as *mut T) }
19    }
20}