luaur_bytecode/methods/
bc_function_as_inst_op.rs1use crate::enums::bc_op_kind::BcOpKind;
2use crate::records::bc_function::BcFunction;
3use crate::records::bc_inst::BcInst;
4use crate::records::bc_op::BcOp;
5
6impl BcFunction {
7 pub fn as_inst_op(&self, op: BcOp) -> *mut BcInst {
8 if op.kind == BcOpKind::Inst {
9 if (op.index as usize) < self.instructions.len() {
10 &self.instructions[op.index as usize] as *const BcInst as *mut BcInst
11 } else {
12 core::ptr::null_mut()
13 }
14 } else {
15 core::ptr::null_mut()
16 }
17 }
18}