Skip to main content

luaur_compiler/records/
compiler.rs

1use crate::enums::global::Global;
2use crate::enums::table_constant_kind::TableConstantKind;
3use crate::records::builtin_ast_types::BuiltinAstTypes;
4use crate::records::capture::Capture;
5use crate::records::constant::Constant;
6use crate::records::function::Function;
7use crate::records::inline_frame::InlineFrame;
8use crate::records::local::Local;
9use crate::records::loop_jump::LoopJump;
10use crate::records::r#loop::Loop;
11use crate::records::table_shape::TableShape;
12use crate::records::variable::Variable;
13use alloc::string::String;
14use alloc::vec::Vec;
15use luaur_ast::records::ast_expr::AstExpr;
16use luaur_ast::records::ast_expr_call::AstExprCall;
17use luaur_ast::records::ast_expr_function::AstExprFunction;
18use luaur_ast::records::ast_expr_table::AstExprTable;
19use luaur_ast::records::ast_local::AstLocal;
20use luaur_ast::records::ast_name::AstName;
21use luaur_ast::records::ast_name_table::AstNameTable;
22use luaur_bytecode::records::bytecode_builder::BytecodeBuilder;
23use luaur_common::enums::luau_bytecode_type::LuauBytecodeType;
24use luaur_common::records::dense_hash_map::DenseHashMap;
25
26#[derive(Debug)]
27pub struct Compiler {
28    pub bytecode: *mut BytecodeBuilder,
29    pub options: crate::records::compile_options::CompileOptions,
30    pub functions: DenseHashMap<*mut AstExprFunction, Function>,
31    pub locals: DenseHashMap<*mut AstLocal, Local>,
32    pub globals: DenseHashMap<AstName, Global>,
33    pub variables: DenseHashMap<*mut AstLocal, Variable>,
34    pub constants: DenseHashMap<*mut AstExpr, Constant>,
35    pub locstants: DenseHashMap<*mut AstLocal, Constant>,
36    pub table_constants: DenseHashMap<*mut AstLocal, TableConstantKind>,
37    pub table_shapes: DenseHashMap<*mut AstExprTable, TableShape>,
38    pub builtins: DenseHashMap<*mut AstExprCall, i32>,
39    pub userdata_types: DenseHashMap<AstName, u8>,
40    pub function_types: DenseHashMap<*mut AstExprFunction, String>,
41    pub local_types: DenseHashMap<*mut AstLocal, LuauBytecodeType>,
42    pub expr_types: DenseHashMap<*mut AstExpr, LuauBytecodeType>,
43    pub inline_builtins: DenseHashMap<*mut AstExprCall, i32>,
44    pub inline_builtins_backup: DenseHashMap<*mut AstExprCall, i32>,
45    pub expr_changes: Vec<crate::records::expr_constant_change::ExprConstantChange>,
46    pub local_changes: Vec<crate::records::local_constant_change::LocalConstantChange>,
47    pub builtin_types: BuiltinAstTypes,
48    pub names: *mut AstNameTable,
49    pub export_table_local: luaur_ast::records::ast_local::AstLocal,
50    pub builtins_fold: *const DenseHashMap<*mut AstExprCall, i32>,
51    pub builtins_fold_library_k: bool,
52    pub reg_top: u32,
53    pub stack_size: u32,
54    pub arg_count: usize,
55    pub has_loops: bool,
56    pub current_function: *mut AstExprFunction,
57    pub block_depth: usize,
58    pub getfenv_used: bool,
59    pub setfenv_used: bool,
60    pub local_stack: Vec<*mut AstLocal>,
61    pub upvals: Vec<*mut AstLocal>,
62    pub loop_jumps: Vec<LoopJump>,
63    pub loops: Vec<Loop>,
64    pub inline_frames: Vec<InlineFrame>,
65    pub captures: Vec<Capture>,
66    pub exported_locals: Vec<*mut AstLocal>,
67    pub exported_classes: Vec<(AstName, u8)>,
68}