luaur_bytecode/records/
bc_jump.rs1use core::marker::PhantomData;
2
3use luaur_common::enums::luau_opcode::LuauOpcode;
4
5use crate::methods::bc_function_as::BcInstType;
6use crate::methods::bc_inst_helper_create::BcInstHelperCreate;
7use crate::records::bc_function::{BcFunction, VmConst};
8use crate::records::bc_inst_helper::BcInstHelper;
9use crate::records::bc_op::BcOp;
10
11#[derive(Debug)]
12pub struct BcJump<'a, T = VmConst> {
13 pub(crate) base: BcInstHelper<'a>,
14 _marker: PhantomData<T>,
15}
16
17impl<'a, T> BcJump<'a, T> {
18 pub fn create(graph: &'a mut BcFunction) -> Self {
19 Self {
20 base: BcInstHelper::create::<Self>(graph),
21 _marker: PhantomData,
22 }
23 }
24
25 pub fn set_target(&mut self, block: BcOp) {
26 self.base.set_bc_op(0, block);
27 }
28
29 pub fn append_to(&mut self, block: BcOp) {
30 self.base.append_to(block);
31 }
32}
33
34impl<T> BcInstType for BcJump<'_, T> {
35 const OPCODE: i32 = LuauOpcode::LOP_JUMP as i32;
36}
37
38impl<T> BcInstHelperCreate for BcJump<'_, T> {
39 const OPCODE: LuauOpcode = LuauOpcode::LOP_JUMP;
40}