Compiler
Bytecode compiler lowering Ouro ParseResult arenas or Luau source strings across optimization levels 0–2.
Types
CompileOptions type
luau
type CompileOptions = {
optimizationLevel: number?, -- `0` = none, `1` = baseline folding & fastcalls (default), `2` = inlining & unrolling
debugLevel: number?, -- `0` = stripped, `1` = line info & function names (default), `2` = locals & upvalues
typeInfoLevel: number?, -- `0` = annotated functions only (default), `1` = all functions
coverageLevel: number?, -- `0` = disabled (default), `1` = statements, `2` = statements & expressions
vectorLib: string?, -- global library name for vector constructor lowering (e.g. `"Vector3"`)
vectorCtor: string?, -- constructor member name on `vectorLib` (e.g. `"new"`)
vectorType: string?, -- vector annotation name used for typed local specialization
vectorPrecision: number?, -- `0` = 32-bit float vectors (default), `1` = 64-bit doubles
mutableGlobals: { string }?, -- globals excluded from immutable builtin optimization
userdataTypes: { string }?, -- known host userdata type names for type-info emission
librariesWithKnownMembers: { string }?, -- library names eligible for `libraryMember*Cb` callbacks
libraryMemberTypeCb: ((library: string, member: string) -> number)?, -- returns `Ouro.Bytecode.Types` tag (`0..255`)
libraryMemberConstantCb: ((library: string, member: string) -> CompileConstant?)?,
disabledBuiltins: { string }?, -- builtin names or wildcards (`"math.*"`, `"*"`) excluded from fastcalls
encoder: BytecodeEncoder?, -- custom instruction opcode encoder for serialized bytecode
dumpFlags: number?, -- bitmask of `Ouro.Bytecode.DumpFlags` for remarks and disassembly dumps
flags: { [string]: boolean | number }?, -- overrides matching `Ouro.Compiler.CompilerFlags`
parseOptions: ParseOptions?, -- forwarded to the parser when input is source text
maxInstructions: number?, -- maximum total instruction words emitted across all protos (default `2,000,000`)
allowDirectives: boolean?, -- allow `--!optimize`/`--!native`/`@native` to raise levels above caller options (defaults `true` in `compile` and `load`; `false` in `"strict"` and `"balanced"` sandboxes)
}Configuration options for Ouro.compile, Ouro.compileResult, and Ouro.Compiler.compileProto.
CompileResult type
luau
type CompileResult = {
status: "ok" | "parseError" | "compileError",
bytecode: string, -- compiled bytecode, or status-zero encoded error readable via `Bytecode.decodeError`
builder: BytecodeBuilder?,
error: string?,
diagnostics: { Diagnostic },
parseResult: ParseResult,
}Structured result returned by Ouro.compileResult.
Properties
CompilerFlags Re-export
luau
Compiler.CompilerFlagsDefault Luau 0.748 compiler flags, overridable per call through CompileOptions.flags.
Functions
compile
luau
Compiler.compile(sourceOrParseResult: string | PublicTypes.ParseResult, compileOpts: CompileOptions?): (string?, string?)Compiles Luau source or a ParseResult into binary bytecode, returning (bytecode, nil) or (nil, err).
compileResult
luau
Compiler.compileResult(sourceOrParseResult: string | PublicTypes.ParseResult, compileOpts: CompileOptions?): CompileResultCompiles Luau source or a ParseResult and returns a structured CompileResult with diagnostics and optional builder.
compileProto
luau
Compiler.compileProto(sourceOrParseResult: string | PublicTypes.ParseResult, compileOpts: CompileOptions?): (PublicTypes.ProtoModule?, string?)Compiles Luau source or a ParseResult directly into an in-memory ProtoModule without binary serialization.