Bytecode
Bytecode codec, disassembler, verifier, opcode tables, and instruction helpers for Luau v3–v14 bytecode.
Types
BytecodeDecoder type
type BytecodeDecoder = ((number) -> number) | { decode: (self: any, code: { number }) -> () }ProtoModule type
type ProtoModule = {
version: number,
typesversion: number,
strings: { string },
protos: { Proto },
mainid: number,
userdataTypes: { string }?,
}In-memory decoded bytecode module produced by Bytecode.deserialize and Compiler.compileProto.
Properties
disassemble Re-export
Bytecode.disassembleDisassembles binary Luau bytecode or a ProtoModule into human-readable listings, throwing on corrupt input.
deserialize Re-export
Bytecode.deserializeDecodes binary Luau bytecode (v3–v14 and v100) into an immutable ProtoModule.
serialize Re-export
Bytecode.serializeEncodes a ProtoModule back into binary Luau bytecode with an optional opcode encoder.
decodeLineInfo Re-export
Bytecode.decodeLineInfoUnpacks delta-encoded line numbers and per-proto baseline offsets for a Proto.
encodeError Re-export
Bytecode.encodeErrorFormats a compiler or parser error message as a status-zero binary bytecode payload.
decodeError Re-export
Bytecode.decodeErrorExtracts the error message from a status-zero bytecode payload, or nil for valid bytecode.
getStringHash Re-export
Bytecode.getStringHashComputes the Luau bytecode string hash for an identifier or string constant.
getImportId Re-export
Bytecode.getImportIdPacks 1 to 3 string constant indices into a 32-bit LOP_GETIMPORT identifier.
decomposeImportId Re-export
Bytecode.decomposeImportIdUnpacks a 32-bit LOP_GETIMPORT identifier into (count, id0, id1, id2).
insnOp Re-export
Bytecode.insnOpExtracts the opcode byte (0..255) from a 32-bit bytecode instruction word.
insnA Re-export
Bytecode.insnAExtracts operand A (8-bit unsigned) from a 32-bit bytecode instruction word.
insnB Re-export
Bytecode.insnBExtracts operand B (8-bit unsigned) from a 32-bit bytecode instruction word.
insnC Re-export
Bytecode.insnCExtracts operand C (8-bit unsigned) from a 32-bit bytecode instruction word.
insnD Re-export
Bytecode.insnDExtracts signed 16-bit operand D from a 32-bit bytecode instruction word.
insnE Re-export
Bytecode.insnEExtracts signed 24-bit operand E from a 32-bit bytecode instruction word.
Opcodes Re-export
Bytecode.OpcodesMap of upstream LOP_* instruction names to numeric opcodes.
opcodeNames Re-export
Bytecode.opcodeNamesReverse lookup table from numeric opcode to instruction name.
opLengths Re-export
Bytecode.opLengthsInstruction word length (1 or 2) keyed by numeric opcode.
Builtins Re-export
Bytecode.BuiltinsMap of upstream LBF_* fastcall builtin names to numeric IDs.
builtinNames Re-export
Bytecode.builtinNamesReverse lookup table from numeric builtin ID to function name.
Tags Re-export
Bytecode.TagsBytecode format version limits and constant/type tag constants (LBC_*).
Types Re-export
Bytecode.TypesEncoded bytecode type tags (LBC_TYPE_*).
Captures Re-export
Bytecode.CapturesUpvalue capture mode tags (LCT_*).
ProtoFlags Re-export
Bytecode.ProtoFlagsFunction prototype flag bitmasks (LPF_*).
FeedbackTypes Re-export
Bytecode.FeedbackTypesInline feedback entry type tags (LFT_*).
DumpFlags Re-export
Bytecode.DumpFlagsBitmask flags controlling disassemble and compiler dump output.
Functions
verify
Bytecode.verify(input: string | buffer | ProtoModule, decoder: BytecodeDecoder?): (boolean, string?)Validates binary bytecode or a ProtoModule statically without instantiating a closure.