ir library

Public entrypoint for the lualike IR toolset.

The exported IR surface is intentionally split into two layers:

The intended contract is that optimizations happen before lowering, while lowering itself stays mechanical and keeps the VM thin.

Classes

ABCInstruction
Instruction using the ABC mode (3 operands + optional k flag).
ABxInstruction
Instruction using the ABx mode (A + 17-bit unsigned operand).
AsBxInstruction
Instruction using the AsBx mode (A + 17-bit signed operand).
AsJInstruction
Instruction using the sJ mode (25-bit signed jump offset).
AvBCInstruction
Instruction using the vBC mode (variant-length operands + k flag).
AxInstruction
Instruction using the Ax mode (25-bit unsigned operand).
BooleanConstant
ChildPrototypeBuilder
IntegerConstant
IrBytecodeRegisterBudget
Shared limits for IR → Lua bytecode lowering.
LocalDebugEntry
Local variable debug entry attached to an IR prototype.
LongStringConstant
LualikeIrBasicBlock
A basic block in the existing lualike IR.
LualikeIrChunk
Complete lualike IR chunk ready for serialization/execution.
LualikeIrChunkBuilder
LualikeIrChunkFlags
Flags applied to a lualike IR chunk/header.
LualikeIrCompiler
Compiles AST programs into lualike IR chunks understood by the upcoming VM.
LualikeIrConstant
Representation of a constant used within a lualike IR prototype.
LualikeIrControlFlowGraph
A control-flow graph derived from a lualike IR prototype.
LualikeIrDebugInfo
Debug info associated with a prototype.
LualikeIrInstruction
Base class for lualike IR instructions expressed in structured form.
LualikeIrOpcode
Enumeration of the lualike IR instructions supported by the lualike VM.
LualikeIrPhi
An SSA phi node describing a value selected from predecessor blocks.
LualikeIrPrototype
A lualike IR prototype (function), mirroring Lua's Proto structure.
LualikeIrPrototypeBuilder
Utility for building lualike IR prototypes with automatic constant interning.
LualikeIrRuntime
Runtime wrapper that executes code via the lualike IR VM while satisfying the LuaRuntime contract expected by higher-level tooling.
LualikeIrSsaBlock
A CFG block with an SSA overlay.
LualikeIrSsaFunction
A placeholder SSA shape built on top of the existing IR control-flow graph.
LualikeIrSsaTypeAnalysis
Result of type-analyzing a single IR prototype (function).
LualikeIrSsaUse
A use of an SSA value at a particular control-flow location.
LualikeIrSsaValue
A single SSA value for one register version.
LualikeIrToDart
Emits Dart source from lualike IR using the existing Value runtime.
LualikeIrToLlvm
Lowers a lualike IR prototype to LLVM IR using lualike_rt C runtime calls.
LualikeIrUpvalueDescriptor
Descriptor for an upvalue captured by a prototype.
NilConstant
NumberConstant
PeepholePass
Applies peephole optimizations to an IR chunk after emission.
ShortStringConstant

Enums

LualikeIrSsaType
Classification of what a Lua value can be at runtime.

Functions

analyzeLualikeIrSsaTypes(LualikeIrPrototype prototype, LualikeIrSsaFunction ssaFunction) LualikeIrSsaTypeAnalysis
Runs type inference on an SSA function.
buildLualikeIrSsaFunction(LualikeIrPrototype prototype) LualikeIrSsaFunction
Builds a simplified SSA view for a compiled IR prototype.
deserializeLualikeIrBytes(List<int> bytes) LualikeIrChunk
disassembleChunk(LualikeIrChunk chunk, {bool includeSubPrototypes = true, bool includeConstants = true, bool includeLineInfo = true}) String
Human-readable dump of a LualikeIrChunk.
formatLualikeIrChunk(LualikeIrChunk chunk) String
formatLualikeIrSsaFunction(LualikeIrSsaFunction function) String
looksLikeLualikeIrBytes(List<int> bytes) bool
looksLikeLualikeIrString(String value) bool
lowerIrChunkToLuaBytecodeChunk(LualikeIrChunk chunk, {String? chunkName}) → LuaBytecodeBinaryChunk
Mechanically lowers finalized lualike IR into Lua 5.5 bytecode.
lowerIrPrototypeToLuaBytecodePrototype(LualikeIrPrototype prototype, {required String sourceName, bool isMainPrototype = false}) → LuaBytecodePrototype
Lowers one finalized IR prototype to a Lua bytecode prototype.
serializeLualikeIrChunk(LualikeIrChunk chunk) Uint8List
serializeLualikeIrChunkAsLuaString(LualikeIrChunk chunk) LuaString
validateIrChunkRegisterBudget(LualikeIrChunk chunk) → void
Validates chunk (and nested prototypes) for Lua bytecode register limits.

Exceptions / Errors

IrRegisterBudgetExceeded
Thrown when IR cannot be encoded as official Lua bytecode registers.