Skip to main content

ruau_bytecode/
lib.rs

1//! Luau bytecode codec and compiler entry points.
2//!
3//! Application embedders usually compile through `ruau::surface::Surface`, or
4//! through `ruau::vm::RuntimeCapabilities` when using the lower-level VM API
5//! directly. Those paths apply runtime-capability restrictions before calling
6//! into this crate.
7
8mod builder;
9mod codec;
10mod compile;
11mod disassemble;
12#[path = "opcodes.rs"]
13mod opcodes_inner;
14mod types;
15mod validate;
16
17pub use builder::{DEFAULT_TYPE_VERSION, DEFAULT_VERSION};
18pub use codec::{DecodeError, EncodeError, decode_chunk, encode_chunk};
19pub use compile::{
20    CompileError, CompileErrorKind, CompileOptions, CompilerOptions, FastFlag, FastInt,
21    KnownMember, KnownMemberValue, compile_source, compile_source_bytes,
22    compile_source_bytes_strict, compile_source_bytes_strict_with_cancel,
23    compile_source_bytes_strict_with_compiler_options,
24    compile_source_bytes_strict_with_compiler_options_and_cancel, compile_source_bytes_with_cancel,
25    compile_source_bytes_with_compiler_options,
26    compile_source_bytes_with_compiler_options_and_cancel, compile_source_strict,
27    compile_source_strict_with_cancel, compile_source_strict_with_compiler_options,
28    compile_source_strict_with_compiler_options_and_cancel, compile_source_with_cancel,
29    compile_source_with_compiler_options, compile_source_with_compiler_options_and_cancel,
30    effective_compile_options,
31};
32/// Opcode constants and instruction operand helpers.
33pub mod opcodes {
34    pub use crate::opcodes_inner::{
35        BuiltinFunction, CaptureType, ConstantTag, FORGLOOP_INEXT_BIT, FORGLOOP_VARS_MASK,
36        FeedbackType, IMPORT_PATH_COMPONENT_BITS, IMPORT_PATH_COMPONENT_MASK,
37        IMPORT_PATH_COUNT_SHIFT, JUMPX_K_INDEX_MASK, JUMPX_K_NOT_BIT, Opcode, ProtoFlag, TypeTag,
38        import_component_shift,
39    };
40}
41/// Human-readable bytecode disassembly.
42pub mod disasm {
43    pub use crate::disassemble::disassemble_chunk;
44}
45pub use types::{
46    BytecodeChunk, ClassShape, Constant, DebugInfo, DebugLocal, FeedbackSlot, Instruction,
47    LineInfo, Proto, TableEntry, TypeInfo, UserdataTypeMapping, code_word_count,
48    instruction_word_offsets, jump_target_instruction_index,
49};
50pub use validate::{ValidationError, ValidationErrorKind, validate_chunk};