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::enums::bc_op_kind::BcOpKind;
use crate::records::bc_function::BcFunction;
use crate::records::bc_inst::BcInst;
use crate::records::bc_op::BcOp;

impl BcFunction {
    pub fn as_inst_op(&self, op: BcOp) -> *mut BcInst {
        if op.kind == BcOpKind::Inst {
            if (op.index as usize) < self.instructions.len() {
                &self.instructions[op.index as usize] as *const BcInst as *mut BcInst
            } else {
                core::ptr::null_mut()
            }
        } else {
            core::ptr::null_mut()
        }
    }
}