luaur_compiler/methods/
compiler_emit_load_k.rs1use crate::records::compiler::Compiler;
2use luaur_common::enums::luau_opcode::LuauOpcode;
3use luaur_common::macros::luau_assert::LUAU_ASSERT;
4
5impl Compiler {
6 pub fn emit_load_k(&mut self, target: u8, cid: i32) {
7 LUAU_ASSERT!(cid >= 0);
8
9 let bytecode = unsafe { &mut *self.bytecode };
10
11 if cid < 32768 {
12 bytecode.emit_ad(LuauOpcode::LOP_LOADK, target, cid as i16);
13 } else {
14 bytecode.emit_ad(LuauOpcode::LOP_LOADKX, target, 0);
15 bytecode.emit_aux(cid as u32);
16 }
17 }
18}