Skip to main content

luaur_code_gen/functions/
vm_const_op.rs

1use crate::enums::ir_op_kind::IrOpKind;
2use crate::records::ir_op::IrOp;
3
4pub fn vm_const_op(op: IrOp) -> i32 {
5    // The CODEGEN_ASSERT macro in this crate's current state has compilation issues
6    // with its internal calls to luaur_common and core::arch.
7    // We mirror the behavior of vmUpvalueOp by using a standard debug_assert!
8    // to ensure the IR operand is of the expected kind before returning the index.
9    debug_assert!(op.kind() == IrOpKind::VmConst);
10    op.index() as i32
11}