Skip to main content

luaur_bytecode/methods/
bc_inst_helper_set_bc_op.rs

1use crate::records::bc_inst_helper::BcInstHelper;
2use crate::records::bc_op::BcOp;
3
4impl BcInstHelper<'_> {
5    pub(crate) fn set_bc_op(&mut self, input_idx: u32, op: BcOp) {
6        if input_idx >= self.operator_deref().ops.len() as u32 {
7            let inst_mut = unsafe {
8                &mut *(self.inst.operator_arrow() as *mut crate::records::bc_inst::BcInst)
9            };
10            inst_mut.ops.resize(input_idx + 1);
11        }
12        self.operator_deref_mut().ops[input_idx as usize] = op;
13    }
14
15    pub(crate) fn operator_deref_mut(&mut self) -> &mut crate::records::bc_inst::BcInst {
16        unsafe { &mut *self.inst.operator_arrow() }
17    }
18}