Lua.Compiler (Lua v1.0.0-rc.1)
View SourcePublic API for the Lua compiler.
Transforms Lua AST into executable prototypes.
Summary
Types
@type compile_opts() :: [{:source, binary()}]
Functions
@spec compile(Lua.AST.Chunk.t(), compile_opts()) :: {:ok, Lua.Compiler.Prototype.t()} | {:error, term()}
Compiles a Lua AST chunk into a prototype.
After codegen, the prototype is offered to Lua.Compiler.Bytecode for
dense encoding. Sub-prototypes are encoded independently — the dispatcher
takes over per-prototype wherever every opcode in that prototype falls
within its coverage; anything else stays on the interpreter. The
original instruction stream is preserved either way, so error reporting
and tooling continue to work unchanged.
@spec compile!(Lua.AST.Chunk.t(), compile_opts()) :: Lua.Compiler.Prototype.t()
Compiles a Lua AST chunk, raising on error.