luaur-bytecode 0.1.3

Luau bytecode format and builder (Rust).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::records::bc_inst_helper::BcInstHelper;
use crate::records::bc_op::BcOp;

impl BcInstHelper<'_> {
    pub(crate) fn set_bc_op(&mut self, input_idx: u32, op: BcOp) {
        if input_idx >= self.operator_deref().ops.len() as u32 {
            let inst_mut = unsafe {
                &mut *(self.inst.operator_arrow() as *mut crate::records::bc_inst::BcInst)
            };
            inst_mut.ops.resize(input_idx + 1);
        }
        self.operator_deref_mut().ops[input_idx as usize] = op;
    }

    pub(crate) fn operator_deref_mut(&mut self) -> &mut crate::records::bc_inst::BcInst {
        unsafe { &mut *self.inst.operator_arrow() }
    }
}