luaur_bytecode/records/
bc_function.rs1use crate::records::bc_block::BcBlock;
2use crate::records::bc_imm::BcImm;
3use crate::records::bc_inst::BcInst;
4use crate::records::bc_op::BcOp;
5use crate::records::bc_phi::BcPhi;
6use crate::records::bc_proj::BcProj;
7use crate::records::bc_vm_const::BcVmConst;
8use crate::records::debug_local_bytecode_graph::DebugLocal;
9use crate::records::table_shape::TableShape;
10use crate::records::typed_local_bytecode_graph::TypedLocal;
11use crate::type_aliases::reg_map::RegMap;
12use alloc::string::String;
13use alloc::vec::Vec;
14use luaur_common::enums::luau_bytecode_type::LuauBytecodeType;
15
16pub type VmConst = BcVmConst;
17
18#[derive(Debug, Clone)]
19pub struct BcFunction {
20 pub maxstacksize: u8,
21 pub numparams: u8,
22 pub nups: u8,
23 pub is_vararg: bool,
24 pub flags: u8,
25
26 pub blocks: Vec<BcBlock>,
27 pub instructions: Vec<BcInst>,
28 pub constants: Vec<VmConst>,
29 pub immediates: Vec<BcImm>,
30 pub phis: Vec<BcPhi>,
31 pub projections: Vec<BcProj>,
32 pub table_shapes: Vec<TableShape>,
33
34 pub entry_block: BcOp,
35 pub exit_block: BcOp,
36
37 pub type_info: String,
38 pub upvalue_types: Vec<LuauBytecodeType>,
39 pub local_types: Vec<TypedLocal>,
40 pub protos: Vec<u32>,
41
42 pub debugname: String,
43 pub linedefined: u32,
44 pub upvalue_names: Vec<String>,
45 pub locals: Vec<DebugLocal<'static>>,
46
47 pub regs: RegMap,
48}
49
50impl Default for BcFunction {
51 fn default() -> Self {
52 Self {
53 maxstacksize: 0,
54 numparams: 0,
55 nups: 0,
56 is_vararg: false,
57 flags: 0,
58 blocks: Vec::new(),
59 instructions: Vec::new(),
60 constants: Vec::new(),
61 immediates: Vec::new(),
62 phis: Vec::new(),
63 projections: Vec::new(),
64 table_shapes: Vec::new(),
65 entry_block: BcOp::new(),
66 exit_block: BcOp::new(),
67 type_info: String::new(),
68 upvalue_types: Vec::new(),
69 local_types: Vec::new(),
70 protos: Vec::new(),
71 debugname: String::new(),
72 linedefined: 0,
73 upvalue_names: Vec::new(),
74 locals: Vec::new(),
75 regs: RegMap::default(),
76 }
77 }
78}