Skip to main content

luaur_bytecode/methods/
bytecode_graph_serializer_get_vm_const_input_raw.rs

1use crate::enums::bc_op_kind::BcOpKind;
2use crate::records::bc_inst::BcInst;
3use crate::records::bc_op::BcOp;
4use crate::records::bytecode_graph_serializer::BytecodeGraphSerializer;
5use luaur_common::macros::luau_assert::LUAU_ASSERT;
6
7impl<'a> BytecodeGraphSerializer<'a> {
8    pub fn get_vm_const_input_raw(&mut self, insn: &mut BcInst, index: u8) -> u32 {
9        LUAU_ASSERT!((index as usize) < insn.ops.len());
10        let inp: BcOp = insn.ops[index as usize];
11        LUAU_ASSERT!(inp.kind == BcOpKind::VmConst);
12        LUAU_ASSERT!((inp.index as usize) < self.func.constants.len());
13        if let Some(consts) = &self.consts {
14            LUAU_ASSERT!((inp.index as usize) < consts.len());
15            consts[inp.index as usize] as u32
16        } else {
17            inp.index
18        }
19    }
20}