Lua.Compiler (Lua v1.0.0-rc.2)

View Source

Public API for the Lua compiler.

Transforms Lua AST into executable prototypes.

Summary

Functions

Compiles a Lua AST chunk into a prototype.

Compiles a Lua AST chunk, raising on error.

Types

compile_opts()

@type compile_opts() :: [{:source, binary()}]

Functions

compile(chunk, opts \\ [])

@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.

compile!(chunk, opts \\ [])

Compiles a Lua AST chunk, raising on error.