hongweifei/lua/src/core does not have a README file

    LuaRaised

    pub(all) suberror LuaRaised {
    LuaRaised(Value)
    LuaYield(Array[Value])
    }

    The channel every jump out of a nested call travels on. It carries errors and, as its second case, a coroutine.yield that happened while the host had called back into Lua: the MoonBit frames in between are the only way out of such a call, so a yield rides the same channel. It is not an error -- nothing unwinds, the frames stay where they are -- and execute turns it back into a yield of the frame it came from. Every handler that would swallow an error must let this one through.

    BuiltinResult

    pub(all) enum BuiltinResult {
    Nothing
    One(Value)
    Two(Value, Value)
    Many(Array[Value])
    }

    What a builtin answers with.

    A builtin used to build a list on every call -- one heap allocation, and the reference counting that comes with it, in the path of every standard library call -- even though nearly all of them answer with one value or none. These say what the answer is without building anything; Many is for the answers that are genuinely a list, either because their number is not known until the call runs or because there are more than two of them.

    Cont

    pub(all) enum Cont {
    ContPCall
    ContXPCall(Value)
    }

    The continuation a frame performs when the call it represents finishes. This is what makes pcall resumable: instead of a native function waiting on the MoonBit stack, the protection is recorded on the frame and applied when the call returns -- normally or with an error.

    Frame

    pub(all) struct Frame {
    pc : Int
    func_slot : Int
    base : Int
    nargs : Int
    ret_slot : Int
    nres_wanted : Int
    top : Int
    closure : LClosure?
    builtin : LBuiltin?
    varargs : Array[Value]
    prots : Array[Cont]
    tbc : Array[Int]
    tailcalls : Int
    patched_builtin : Int
    hook_frame : Bool
    trap : Bool
    mm_name : String
    ftransfer : Int
    ntransfer : Int
    protect_frame : Bool
    saved_errfunc : Value
    pending_finish : Int
    pending_slot : Int
    pending_top : Int
    pending_closes : Array[Frame]?
    pending_err : Value
    pending_room : Int
    pending_result : (Int, Int)?
    }

    A call frame. All of the mutable state of a running function lives here, so that a coroutine can be suspended and resumed simply by stopping and restarting the interpreter loop.

    Frame::is_lua

    fn Frame::is_lua(self : Frame) -> Bool

    Frame::push_prot

    fn Frame::push_prot(self : Frame, c : Cont) -> Unit

    Adds a protection to the frame, giving it a private list if it still holds the shared empty one.

    Frame::push_tbc

    fn Frame::push_tbc(self : Frame, reg : Int) -> Unit

    Registers a to-be-closed variable on the frame, giving it a private list if it still holds the shared empty one.

    Instr

    pub(all) struct Instr {
    op : Int
    a : Int
    b : Int
    c : Int
    }

    A single instruction. Fields are named rather than bit packed so that the compiler and the interpreter read the same way the manuals describe them.

    Instr::to_text

    fn Instr::to_text(self : Instr) -> String

    IntConv

    pub(all) enum IntConv {
    ConvInt(Int64)
    ConvNoInt
    }

    A value coerced to an integer: an integer itself, or a float that holds one.

    Key

    pub(all) enum Key {
    KInt(Int64)
    KNum(UInt64)
    KStr(LStr)
    KBool(Bool)
    KObj(Value)
    KNil
    KEmpty
    }

    impl Eq for Key
    impl Hash for Key

    LBuiltin

    pub(all) struct LBuiltin {
    name : String
    kind : Int
    arity : Int
    body : (LuaState, Array[Value], ArrayView[Value]) -> BuiltinResult raise LuaRaised
    upvals : Array[Value]
    id : Int
    mark_epoch : Int
    }

    A native (host) function. upvals are the values a native closure captured when it was created, which is how functions like string.gmatch iterators keep their state.

    LBuiltin::make

    fn LBuiltin::make(name : String, arity : Int, body : (LuaState, Array[Value], ArrayView[Value]) -> BuiltinResult raise LuaRaised) -> LBuiltin

    LBuiltin::make_kind

    fn LBuiltin::make_kind(name : String, kind : Int, arity : Int, body : (LuaState, Array[Value], ArrayView[Value]) -> BuiltinResult raise LuaRaised) -> LBuiltin

    LClosure

    pub(all) struct LClosure {
    proto : LProto
    upvals : Array[LUpval]
    id : Int
    mark_epoch : Int
    }

    A Lua closure: a prototype together with the upvalue cells it captured.

    LFile

    pub(all) struct LFile {
    handle : Int64
    closed : Bool
    standard : Bool
    popened : Bool
    name : String
    }

    A host file. handle is the C FILE *; 0 means the file is closed.

    LProto

    pub(all) struct LProto {
    code : Array[Instr]
    lines : Array[Int]
    constants : Array[Value]
    protos : Array[LProto]
    upvals : Array[UpvalDesc]
    numparams : Int
    is_vararg : Bool
    maxstack : Int
    source : LStr
    line_defined : Int
    last_line_defined : Int
    locvars : Array[LocVar]
    name : String
    }

    A compiled function.

    LStr

    pub(all) struct LStr {
    bytes : Bytes
    hash : Int
    id : Int
    }

    impl Compare for LStr
    impl Eq for LStr
    impl Hash for LStr
    impl Show for LStr

    LStr::byte_at

    fn LStr::byte_at(self : LStr, i : Int) -> Int

    LStr::concat

    fn LStr::concat(self : LStr, other : LStr) -> LStr

    LStr::data

    fn LStr::data(self : LStr) -> Bytes

    The byte sequence itself. Lua strings are never converted to text when used as values, only when they are handed to the host.

    LStr::empty

    fn LStr::empty() -> LStr

    LStr::equal

    fn LStr::equal(self : LStr, other : LStr) -> Bool

    Equality is by content. A mismatching hash is a definitive answer, so the byte comparison only runs for strings that hash alike.

    LStr::is_empty

    fn LStr::is_empty(self : LStr) -> Bool

    LStr::length

    fn LStr::length(self : LStr) -> Int

    LStr::of_bytes

    fn LStr::of_bytes(b : Bytes) -> LStr

    LStr::of_string

    fn LStr::of_string(s : String) -> LStr

    LStr::sub

    fn LStr::sub(self : LStr, start : Int, len : Int) -> LStr

    LTable

    pub(all) struct LTable {
    arr : Array[Value]
    hkeys : Array[Key]
    hvals : Array[Value]
    hlive : Int
    hdead : Int
    meta : LTable?
    id : Int
    mark_epoch : Int
    }

    LTable::array_size

    fn LTable::array_size(self : LTable) -> Int

    LTable::as_value

    fn LTable::as_value(self : LTable) -> Value

    The value form of this table.

    LTable::count_entries

    fn LTable::count_entries(self : LTable) -> Int

    Number of entries, counting the array part slots that are not nil.

    LTable::get

    fn LTable::get(self : LTable, key : Value) -> Value

    Raw read. A nil or NaN key simply yields nil, like in the reference implementation.

    LTable::get_int

    fn LTable::get_int(self : LTable, i : Int64) -> Value

    LTable::get_int_key

    fn LTable::get_int_key(self : LTable, i : Int64) -> Value

    Raw read with an integer key.

    LTable::get_lstr

    fn LTable::get_lstr(self : LTable, name : LStr) -> Value

    Raw read with an interned string key, for a caller that already holds one.

    LTable::get_str

    fn LTable::get_str(self : LTable, name : String) -> Value

    Raw read with a string key.

    LTable::hash_delete

    fn LTable::hash_delete(self : LTable, key : Key) -> Unit

    Clears the value of key, keeping its key in place so that a traversal can still be resumed with it. The slot is not reclaimed here: the reference only rebuilds the hash part when it grows, and a traversal that deletes the key it is on relies on the key staying where it was.

    LTable::hash_find

    fn LTable::hash_find(self : LTable, key : Key) -> Int

    LTable::hash_find_key

    fn LTable::hash_find_key(self : LTable, key : Key) -> Int

    The lookup next uses: a key whose value has been cleared is still a place to continue from.

    LTable::hash_get

    fn LTable::hash_get(self : LTable, key : Key) -> Value

    LTable::hash_next_from

    fn LTable::hash_next_from(self : LTable, from : Int) -> NextResult

    LTable::hash_put

    fn LTable::hash_put(self : LTable, key : Key, value : Value) -> Unit

    Inserts into a table that is known to have a free slot. Used by the rehash path, which must not recurse back into the growth check.

    LTable::hash_rehash

    fn LTable::hash_rehash(self : LTable, min_cap : Int) -> Unit

    Rebuilds the hash part with a capacity that leaves at least a quarter of the slots free. Cleared slots are dropped, which is why a traversal must not hold on to a key across a growth of the table.

    LTable::hash_set

    fn LTable::hash_set(self : LTable, key : Key, value : Value) -> Unit

    LTable::metatable

    fn LTable::metatable(self : LTable) -> LTable?

    The metatable, ignoring __metatable hiding. Use the VM level helper when Lua code may observe the value.

    LTable::migrate_following

    fn LTable::migrate_following(self : LTable) -> Unit

    Moves the integer keys n+1, n+2, ... from the hash part into the array part while they are present in sequence. Called after the array part grows so that a table filled in an unusual order still ends up dense.

    LTable::new

    fn LTable::new() -> LTable

    LTable::next

    fn LTable::next(self : LTable, key : Value) -> NextResult

    Implements next. NextBadKey is reported when the given key is not present in the table.

    LTable::raw_len

    fn LTable::raw_len(self : LTable) -> Int64

    The # operator. A border is any index i such that t[i] is not nil and t[i+1] is nil; this finds one of them, preferring a border inside the array part, exactly like luaH_getn.

    LTable::set

    fn LTable::set(self : LTable, key : Value, value : Value) -> Bool

    Raw write. Returns false when the key is neither a value nor a valid key (nil or NaN), which the caller reports as an error.

    LTable::set_int

    fn LTable::set_int(self : LTable, i : Int64, value : Value) -> Unit

    LTable::set_key_keyed

    fn LTable::set_key_keyed(self : LTable, key : Key, value : Value) -> Unit

    LTable::set_lstr

    fn LTable::set_lstr(self : LTable, name : LStr, value : Value) -> Unit

    LTable::set_metatable

    fn LTable::set_metatable(self : LTable, mt : LTable?) -> Unit

    LTable::set_str

    fn LTable::set_str(self : LTable, name : String, value : Value) -> Unit

    LThread

    pub(all) struct LThread {
    stack : Array[Value]
    frames : Array[Frame]
    open_upvals : Array[LUpval]
    meta : LTable?
    status : Int
    ny : Int
    ccalls : Int
    func : Value
    started : Bool
    dead_error : Value
    resume_vals : Array[Value]?
    hook_fn : Value
    hook_mask : Int
    hook_count : Int
    hook_base_count : Int
    hook_running : Bool
    hook_old_pc : Int
    mm_pending : String
    errfunc : Value
    in_errfunc : Bool
    fresh_error : Bool
    id : Int
    mark_epoch : Int
    }

    A coroutine.

    LThread::current_frame

    fn LThread::current_frame(self : LThread) -> Frame?

    LThread::ensure_stack

    fn LThread::ensure_stack(self : LThread, n : Int) -> Unit

    LThread::new

    fn LThread::new() -> LThread

    LUpval

    pub(all) struct LUpval {
    open : Bool
    value : Value
    index : Int
    owner : LThread?
    id : Int
    id_tag : Value
    }

    An upvalue cell. While the enclosing function is running and the variable still lives on the stack, the cell points into the thread stack; once the scope ends the value is copied out and the cell becomes independent.

    LUpval::close

    fn LUpval::close(self : LUpval) -> Unit

    Releases the cell from the stack, copying the current value out.

    LUpval::get

    fn LUpval::get(self : LUpval) -> Value

    LUpval::new_closed

    fn LUpval::new_closed(v : Value) -> LUpval

    LUpval::set

    fn LUpval::set(self : LUpval, v : Value) -> Unit

    LUserData

    pub(all) struct LUserData {
    meta : LTable?
    kind : UserDataKind
    uservalues : Array[Value]
    id : Int
    light : Bool
    mark_epoch : Int
    }

    A block of host data with an optional metatable and the user values debug.setuservalue can reach. A light one is only an identifier: it has neither.

    LUserData::new_file

    fn LUserData::new_file(f : LFile) -> LUserData

    LUserData::new_light

    fn LUserData::new_light(k : UserDataKind) -> LUserData

    The light userdata debug.upvalueid hands out to name an upvalue cell.

    LoadOutcome

    pub(all) enum LoadOutcome {
    LoadOk(Value)
    LoadError(Bytes)
    }

    LocVar

    pub(all) struct LocVar {
    name : LStr
    start_pc : Int
    end_pc : Int
    attrib : Int
    }

    A local variable, kept for diagnostics and for the debug library.

    LuaState

    pub(all) struct LuaState {
    globals : LTable
    registry : LTable
    type_metas : Array[LTable?]
    main_thread : LThread
    current_thread : LThread
    native_depth : Int
    error_handler : Value
    memory_units : Int
    memory_limit : Int
    in_error_handling : Bool
    gc_running : Bool
    gc_finalizing : Bool
    gc_mode : String
    gc_pause : Int
    gc_stepmul : Int
    warn_enabled : Bool
    last_error : Bytes
    mm_name : String
    slot_x : Int
    slot_y : Int
    err_room : Int
    gc_epoch : Int
    weak_tables : Array[LTable]
    finalizers : Array[Value]
    gc_threshold : Int
    gc_debt : Int
    gc_units_done : Int
    gc_marked : Int
    gc_marked_size : Int
    gc_counted_strings : Map[Int, Unit]
    gc_object_base : Int
    gc_string_base : Int
    }

    NextResult

    pub(all) enum NextResult {
    NextPair(Value, Value)
    NextEnd
    NextBadKey
    }

    Traversal

    NumConv

    pub(all) enum NumConv {
    ConvNum(Double)
    ConvNoNum
    }

    A value coerced to a float.

    NumValue

    pub(all) enum NumValue {
    NInt(Int64)
    NFloat(Double)
    }

    ObjName

    pub struct ObjName {
    kind : String
    name : String
    }

    A recovered name: the sort of thing the value is, and what it is called.

    RunStatus

    pub(all) enum RunStatus {
    RFinished(Array[Value])
    RYield(Array[Value])
    }

    Why the interpreter loop stopped.

    UpvalDesc

    pub(all) struct UpvalDesc {
    name : LStr
    in_stack : Bool
    index : Int
    attrib : Int
    }

    How a descriptor describes the origin of an upvalue.

    UserDataKind

    pub(all) enum UserDataKind {
    UDFile(LFile)
    UDUpvalTag(Int)
    UDCUpvalTag(Int, Int)
    }

    The kind of payload a userdata carries.

    Value

    pub(all) enum Value {
    VNil
    VBool(Bool)
    VInt(Int64)
    VNum(Double)
    VStr(LStr)
    VTable(LTable)
    VFunc(LClosure)
    VBuiltin(LBuiltin)
    VThread(LThread)
    VUserData(LUserData)
    }

    Value::as_builtin

    fn Value::as_builtin(self : Value) -> LBuiltin?

    Value::as_bytes

    fn Value::as_bytes(self : Value) -> Bytes?

    The bytes of a string value, with no coercion at all. lua_tostring also turns a number into a string, but it rewrites the stack while doing so; reading a value here must not change what Lua sees, so a number answers None.

    Value::as_double

    fn Value::as_double(self : Value) -> Double?

    The value as a float. An integer widens, and so does a string that spells a number; a value outside 2^53 loses precision in the widening, as it does in the reference.

    Value::as_file

    fn Value::as_file(self : Value) -> LFile?

    Value::as_integer

    fn Value::as_integer(self : Value) -> Int64?

    The integer a value stands for: an integer answers itself, a float only while it holds an integral value, and a string that spells one of those does too. This is math.tointeger's rule, and lua_tointegerx's.

    Value::as_number

    fn Value::as_number(self : Value) -> NumValue?

    The number a value stands for when Lua coerces it: a number answers itself, a string answers as the number it spells, and nothing else is a number. This is tonumber's rule (lua_tonumberx on a string).

    Value::as_text

    fn Value::as_text(self : Value) -> String?

    A string value as MoonBit text. Lua strings are bytes, so bytes that are not UTF-8 come back replaced; as_bytes is the exact reader.

    Value::is_nil

    fn Value::is_nil(self : Value) -> Bool

    Value::is_number

    fn Value::is_number(self : Value) -> Bool

    Value::is_truthy

    fn Value::is_truthy(self : Value) -> Bool

    Value::meta_slot

    fn Value::meta_slot(self : Value) -> Int

    The slot in LuaState.type_metas holding the metatable this value shares with its whole type, or -1 for a table or a userdata, which carry their own and are not addressed this way.

    Value::obj_id

    fn Value::obj_id(self : Value) -> Int

    The identity of an object used as a table key.

    Value::object_id

    fn Value::object_id(self : Value) -> Int

    Identity of an object value, for __eq bookkeeping and for registry keys.

    Value::raw_equal

    fn Value::raw_equal(self : Value, other : Value) -> Bool

    Raw equality (== without metamethods). Numbers compare across subtypes, strings by content, everything else by identity.

    Value::table

    fn Value::table() -> Value

    A fresh, empty table.

    Value::text

    fn Value::text(s : String) -> Value

    A string value holding MoonBit text, encoded as UTF-8 as Lua would store it.

    Value::type_name

    fn Value::type_name(self : Value) -> String

    BINOP_ADD

    let BINOP_ADD : Int

    BINOP_AND

    let BINOP_AND : Int

    BINOP_BAND

    let BINOP_BAND : Int

    BINOP_BOR

    let BINOP_BOR : Int

    BINOP_BXOR

    let BINOP_BXOR : Int

    BINOP_CONCAT

    let BINOP_CONCAT : Int

    BINOP_DIV

    let BINOP_DIV : Int

    BINOP_EQ

    let BINOP_EQ : Int

    BINOP_GE

    let BINOP_GE : Int

    BINOP_GT

    let BINOP_GT : Int

    BINOP_IDIV

    let BINOP_IDIV : Int

    BINOP_LE

    let BINOP_LE : Int

    BINOP_LT

    let BINOP_LT : Int

    BINOP_MOD

    let BINOP_MOD : Int

    BINOP_MUL

    let BINOP_MUL : Int

    BINOP_NE

    let BINOP_NE : Int

    BINOP_OR

    let BINOP_OR : Int

    BINOP_POW

    let BINOP_POW : Int

    BINOP_SHL

    let BINOP_SHL : Int

    BINOP_SHR

    let BINOP_SHR : Int

    BINOP_SUB

    let BINOP_SUB : Int

    BK_NORMAL

    let BK_NORMAL : Int

    Behaviour that the virtual machine must give special treatment.

    BK_PAIRS

    let BK_PAIRS : Int

    pairs, which is yieldable when the table has a __pairs: its whole remaining work is to return the three values the metamethod produced, so a yield inside it is finished by handing those values to the call instead of running the builtin again.

    BK_PCALL

    let BK_PCALL : Int

    pcall: call the target under protection so that the error can be caught without unwinding the native stack.

    BK_XPCALL

    let BK_XPCALL : Int

    BK_YIELD

    let BK_YIELD : Int

    coroutine.yield: suspend the running thread.

    CCALLS_LIMIT_LATE

    let CCALLS_LIMIT_LATE : Int

    How deep past the limit a call may get while an overflow is still being handled, before the reference gives up on error handling altogether.

    GCPARAM_ADJ

    let GCPARAM_ADJ : Int

    GCPARAM_ADJ: the reference keeps its collector parameters divided by this and multiplies them back when it reports them, so a parameter a program sets comes back rounded down to a multiple of it -- setstepmul(50) reports 48 the next time it is asked for. A parameter large enough to overflow the byte the reference stores it in wraps there; here it is kept as it is, which is why an extreme multiplier is clamped rather than wrapped.

    GC_MAX_DEBT

    let GC_MAX_DEBT : Int64

    A bound on the debt a step can be given, so that an extreme step size a program passes cannot wrap the arithmetic. The reference has no such bound because its l_mem is wider than the figures a program passes.

    GC_STEP

    let GC_STEP : Int

    How many allocation units pass between two automatic collections. The reference's pause parameter scales a similar distance from the live size; this is a plain step, which is enough to make a loop that only allocates reach a collection.

    GC_STEP_SHIFT

    let GC_STEP_SHIFT : Int

    LUAI_GCSTEPSIZE: the granularity one step is worth is 2^13 bytes, which in the units above is 512.

    HOOK_CALL

    let HOOK_CALL : Int

    Debug hook event masks, matching the reference implementation.

    HOOK_COUNT

    let HOOK_COUNT : Int

    HOOK_COUNT_MAX

    let HOOK_COUNT_MAX : Int

    Upper bound for the count-hook period (2^24 - 1).

    HOOK_LINE

    let HOOK_LINE : Int

    HOOK_RETURN

    let HOOK_RETURN : Int

    MAX_BX

    let MAX_BX : Int

    Largest value of a Bx operand.

    MAX_CALL_DEPTH

    let MAX_CALL_DEPTH : Int

    MAX_CCALLS

    let MAX_CCALLS : Int

    LUAI_MAXCCALLS in the reference implementation.

    MAX_INDEX_RK

    let MAX_INDEX_RK : Int

    Largest constant index usable inside an RK operand.

    MAX_LUA_FRAMES

    let MAX_LUA_FRAMES : Int

    Maximum number of Lua frames on one thread. The interpreter loop is iterative, so this is only bounded by memory.

    MAX_NATIVE_DEPTH

    let MAX_NATIVE_DEPTH : Int

    Maximum nesting of calls that re-enter the interpreter from the host. Each of those consumes host stack, so the limit is much lower. This is the reference's own shape (LUAI_MAXCCALLS, which it also counts in levels); what actually stops the recursion is MIN_HOST_STACK below, since what one level costs is a property of the generated code rather than of the language.

    MAX_PARAMS

    let MAX_PARAMS : Int

    Maximum number of parameters.

    MAX_REGS

    let MAX_REGS : Int

    MAXREGS in lcode.c: the register window a function may need, limited by the byte-wide fields of the instruction encoding.

    MAX_UPVALS

    let MAX_UPVALS : Int

    Maximum number of upvalues of a single function.

    MAX_VARS

    let MAX_VARS : Int

    Maximum number of active local variables.

    MEMORY_LIMIT

    let MEMORY_LIMIT : Int

    How much the live set may hold before the interpreter refuses to grow further, in bytes. The reference has no such figure: its allocator fails (luaM_realloc_ raising "not enough memory") when the host cannot give it more, which on a 16 GB machine happens around 8.6 GB. Memory here is owned by the host runtime, which cannot refuse gracefully, so the interpreter keeps its own budget and raises the reference's message. heavy.lua fills a table until that happens; it is also what keeps a runaway program from taking the process down with it.

    MIN_HOST_STACK

    let MIN_HOST_STACK : Int

    How much host stack has to remain below a call that re-enters the interpreter, in bytes. The check that uses it is in call_value, and it is what keeps a program that recurses through host callbacks (string.gsub with a replacement function, a __index that calls back) from running the real stack out: the reference's fixed count of C levels assumes a level costs a few hundred bytes, which is true of C code and not of the code this backend produces. The margin is what the unwinding of that recursion needs -- the message handler, the tracebacks and the __close runs all happen while the deep frames are still standing.

    OP_ADD

    let OP_ADD : Int

    OP_BAND

    let OP_BAND : Int

    OP_BNOT

    let OP_BNOT : Int

    R[A] := ~R[B]

    OP_BOR

    let OP_BOR : Int

    OP_BXOR

    let OP_BXOR : Int

    OP_CALL

    let OP_CALL : Int

    R[A], ..., R[A+C-2] := R[A](R[A+1], ..., R[A+B-1])

    OP_CLOSE

    let OP_CLOSE : Int

    Close every upvalue and to-be-closed variable at or above register A.

    OP_CLOSURE

    let OP_CLOSURE : Int

    R[A] := closure(KPROTO[Bx])

    OP_CONCAT

    let OP_CONCAT : Int

    R[A] := R[A] .. ... .. R[B]

    OP_COUNT

    let OP_COUNT : Int

    OP_DIV

    let OP_DIV : Int

    OP_EQ

    let OP_EQ : Int

    if (RK(B) == RK(C)) != A then pc++

    OP_FORLOOP

    let OP_FORLOOP : Int

    R[A] += R[A+2]; if R[A] <= R[A+1] then { R[A+3] := R[A]; pc += C }

    OP_FORPREP

    let OP_FORPREP : Int

    R[A] -= R[A+2]; pc += C (numeric for prologue; C lands on the loop test)

    OP_GETTABLE

    let OP_GETTABLE : Int

    R[A] := R[B][RK(C)]

    OP_GETTABUP

    let OP_GETTABUP : Int

    R[A] := U[B][RK(C)]

    OP_GETUPVAL

    let OP_GETUPVAL : Int

    R[A] := U[B]

    OP_IDIV

    let OP_IDIV : Int

    OP_JMP

    let OP_JMP : Int

    pc += sBx

    OP_LE

    let OP_LE : Int

    if (RK(B) <= RK(C)) != A then pc++

    OP_LEN

    let OP_LEN : Int

    R[A] := #R[B]

    OP_LOADBOOL

    let OP_LOADBOOL : Int

    R[A] := (B != 0)

    OP_LOADK

    let OP_LOADK : Int

    R[A] := K[Bx]

    OP_LOADNIL

    let OP_LOADNIL : Int

    R[A], ..., R[A+B-1] := nil

    OP_LT

    let OP_LT : Int

    if (RK(B) < RK(C)) != A then pc++

    OP_MOD

    let OP_MOD : Int

    OP_MOVE

    let OP_MOVE : Int

    R[A] := R[B]

    OP_MUL

    let OP_MUL : Int

    OP_NEWTABLE

    let OP_NEWTABLE : Int

    R[A] := {}

    OP_NOT

    let OP_NOT : Int

    R[A] := not R[B]

    OP_POW

    let OP_POW : Int

    OP_RETURN

    let OP_RETURN : Int

    return R[A], ..., R[A+B-2] (B == 0 returns everything up to the top)

    OP_SELF

    let OP_SELF : Int

    R[A+1] := R[B]; R[A] := R[B][RK(C)]

    OP_SETLIST

    let OP_SETLIST : Int

    R[A][C*i + j] := R[A+j]

    OP_SETTABLE

    let OP_SETTABLE : Int

    R[A][RK(B)] := RK(C)

    OP_SETTABUP

    let OP_SETTABUP : Int

    U[A][RK(B)] := RK(C)

    OP_SETUPVAL

    let OP_SETUPVAL : Int

    U[B] := R[A]

    OP_SHL

    let OP_SHL : Int

    OP_SHR

    let OP_SHR : Int

    OP_SUB

    let OP_SUB : Int

    OP_TAILCALL

    let OP_TAILCALL : Int

    return R[A](R[A+1], ..., R[A+B-1])

    OP_TBC

    let OP_TBC : Int

    Mark R[A] as a to-be-closed variable.

    OP_TEST

    let OP_TEST : Int

    if not (R[A] == C) then pc++

    OP_TESTSET

    let OP_TESTSET : Int

    if (R[B] == C) then R[A] := R[B] else pc++

    OP_TFORCALL

    let OP_TFORCALL : Int

    R[A+3], ..., R[A+2+B] := R[A](R[A+1], R[A+2])

    OP_TFORLOOP

    let OP_TFORLOOP : Int

    if R[A+3] ~= nil then { R[A+2] := R[A+3]; pc += C }

    OP_UNM

    let OP_UNM : Int

    R[A] := -R[B]

    OP_VARARG

    let OP_VARARG : Int

    R[A], ..., R[A+B-2] := vararg

    RK_OFFSET

    let RK_OFFSET : Int

    Base of the RK encoding: operands at or above this value index constants.

    THREAD_DEAD

    let THREAD_DEAD : Int

    Finished normally or with an error.

    THREAD_NORMAL

    let THREAD_NORMAL : Int

    Resumed another coroutine and waiting for it.

    THREAD_OK

    let THREAD_OK : Int

    THREAD_RUNNING

    let THREAD_RUNNING : Int

    Currently executing.

    THREAD_SUSPENDED

    let THREAD_SUSPENDED : Int

    Not started yet (created by coroutine.create).

    UNOP_BNOT

    let UNOP_BNOT : Int

    UNOP_LEN

    let UNOP_LEN : Int

    UNOP_MINUS

    let UNOP_MINUS : Int

    UNOP_NOT

    let UNOP_NOT : Int

    WORK2MEM

    let WORK2MEM : Int

    WORK2MEM: the reference counts a step's debt in units of one slot (TValue), so a byte figure reaches the same units by dividing by this.

    arg_error

    fn[T] arg_error(st : LuaState, n : Int, fname : String, msg : String) -> T raise LuaRaised

    bad argument #n to 'fname' (msg)

    arg_message

    fn arg_message(st : LuaState, n : Int, fname : String, msg : String) -> String

    The whole "bad argument" phrase, as luaL_argerror builds it: the function is named as its call site names it, then as a path among the fields of package.loaded, and ? when neither can name it -- the reference never reports the name a function was registered under, so a file method reached as a value (pcall(f.read, f)) is ? rather than read. For a method call the self argument is not counted, so a bad self reads as a failed call instead.

    binop_metamethod

    fn binop_metamethod(op : Int) -> String

    The metamethod that implements an arithmetic or comparison operator.

    binop_text

    fn binop_text(op : Int) -> String

    The textual form of a binary operator, for diagnostics.

    bump_locale_generation

    fn bump_locale_generation() -> Unit

    byte_of

    fn byte_of(n : Int) -> Byte

    A byte from an integer value, for readability where a literal would be ambiguous.

    bytes_add

    fn bytes_add(a : Bytes, b : String) -> Bytes

    Appends a textual suffix to a byte string, for building messages.

    bytes_concat

    fn bytes_concat(parts : Array[Bytes]) -> Bytes

    Concatenation of any number of byte sequences.

    bytes_equal_range

    fn bytes_equal_range(a : Bytes, ai : Int, b : Bytes, bi : Int, len : Int) -> Bool

    Whether len bytes of a from ai are the same as those of b from bi. The host's memcmp, for the same reason as bytes_index_of.

    bytes_index_of

    fn bytes_index_of(b : Bytes, from : Int, len : Int, byte : Int) -> Int

    The index of the first byte among the len bytes at from, or -1 when there is none. The search is the host's memchr, as in the reference implementation: a byte-at-a-time loop written here would be a call per byte. The window is given rather than taken to the end of b because the callers that search a pattern need it -- lmemfind only considers positions a match could still start at.

    bytes_of

    fn bytes_of(s : String) -> Bytes

    bytes_one

    fn bytes_one(v : Int) -> Bytes

    Builds a one element byte sequence.

    bytes_repeat

    fn bytes_repeat(b : Bytes, n : Int) -> Bytes

    Repeats a byte sequence n times.

    bytes_slice

    fn bytes_slice(b : Bytes, start : Int, len : Int) -> Bytes

    Copies len bytes starting at start. The range must be valid.

    callee_name

    fn callee_name(st : LuaState) -> ObjName?

    The name the running call has at its call site, as lua_getinfo with "n" reports it for a library function: the instruction is taken from the frame below the running one, which is the caller.

    charge_object_bytes

    fn charge_object_bytes(n : Int) -> Unit

    Charges one object to the clock, where the object is made. A creator that can reach the state charges its own accounting instead (the interpreter's OP_NEWTABLE and OP_CLOSURE, and what a table grows by); this is for the objects a library function makes, which has no state in hand.

    check_any

    fn check_any(st : LuaState, args : ArrayView[Value], n : Int, fname : String) -> Value raise LuaRaised

    check_decimal_float

    fn check_decimal_float(s : Bytes) -> Bool

    Validates the syntax of a decimal float: [+-]? (digits[.digits?] | .digits)([eE][+-]?digits)?.

    check_function

    fn check_function(st : LuaState, args : ArrayView[Value], n : Int, fname : String) -> Value raise LuaRaised

    check_hex_float

    fn check_hex_float(s : Bytes) -> Bool

    Validates the syntax of a hexadecimal float: [+-]? 0[xX] (hexdigits[.hexdigits?] | .hexdigits) ([pP][+-]?digits)?.

    check_int

    fn check_int(st : LuaState, args : ArrayView[Value], n : Int, fname : String) -> Int64 raise LuaRaised

    check_number

    fn check_number(st : LuaState, args : ArrayView[Value], n : Int, fname : String) -> Double raise LuaRaised

    check_option

    fn check_option(st : LuaState, args : ArrayView[Value], n : Int, fname : String, options : Array[String], dflt : String) -> String raise LuaRaised

    check_present

    fn check_present(st : LuaState, args : ArrayView[Value], n : Int, fname : String, expected : String) -> Value raise LuaRaised

    The value at n, or an argument error naming the type that was expected. A typed check cannot share check_any's message: the reference reports a missing argument as "no value" through luaL_typeerror, so string.rep() says "string expected, got no value" while pcall() says "value expected".

    check_str

    fn check_str(st : LuaState, args : ArrayView[Value], n : Int, fname : String) -> LStr raise LuaRaised

    check_table

    fn check_table(st : LuaState, args : ArrayView[Value], n : Int, fname : String) -> LTable raise LuaRaised

    check_thread

    fn check_thread(st : LuaState, args : ArrayView[Value], n : Int, fname : String) -> LThread raise LuaRaised

    The thread at n, or an argument error naming the expected type -- the reference's getco, which is what every coroutine function that takes one uses.

    chunk_id_of

    fn chunk_id_of(source : Bytes) -> String

    const_key

    fn const_key(v : Value) -> Key

    Builds the pool key for a constant. Unlike a table key, nil and NaN are valid here because a constant only has to be compared with itself.

    current_position

    fn current_position(st : LuaState) -> String

    describe

    fn describe(p : LProto) -> String

    Where a closure may be entered from, used to build readable names.

    disassemble

    fn disassemble(p : LProto) -> String

    The disassembly of a prototype as a string, for embedding in diagnostics.

    double_to_g14

    fn double_to_g14(d : Double) -> Bytes

    Formats a float the way the reference implementation does: %.14g, with .0 appended when the result would otherwise read as an integer.

    dump_proto

    fn dump_proto(p : LProto) -> Unit

    Prints the instructions of a prototype and of every function it contains. Used to inspect what the code generator produced.

    errno_message

    fn errno_message() -> Bytes

    The message for the current value of the host error indicator.

    find_set_reg

    fn find_set_reg(p : LProto, last_pc : Int, reg : Int) -> Int

    findsetreg: the last instruction before last_pc that wrote register reg, or -1 when it cannot be determined.

    float_ceil_to_int64

    fn float_ceil_to_int64(d : Double) -> Int64?

    Rounds a float away from zero, keeping the result inside the integer range.

    float_floor_to_int64

    fn float_floor_to_int64(d : Double) -> Int64?

    float_is_int64

    fn float_is_int64(d : Double) -> Bool

    True when a float holds an integral value representable as an Int64.

    float_le_int

    fn float_le_int(f : Double, i : Int64) -> Bool

    float_lt_int

    fn float_lt_int(f : Double, i : Int64) -> Bool

    float_mod

    fn float_mod(a : Double, b : Double) -> Double

    Float remainder with the sign of the divisor: fmod follows the dividend, so a mismatched sign needs one correction. A zero remainder keeps whatever sign fmod produced, and a zero divisor yields NaN.

    float_to_int64

    fn float_to_int64(d : Double) -> Int64

    Converts an integral float to Int64. The caller must have checked float_is_int64.

    flush_stdout

    fn flush_stdout() -> Unit

    Flushes standard output. The reference flushes it wherever its lua_writeline is used -- after a prompt, after a line of results, and after every print -- which is what makes a prompt appear before the interpreter waits for input and what keeps output and errors in order when both are redirected to the same file. Only standard output is flushed: a file a program has open keeps whatever the host has buffered for it, exactly as it does in the reference.

    format_obj

    fn format_obj(o : ObjName?) -> String

    Formats a name as the parenthesised part of an error message.

    format_with_cstr

    fn format_with_cstr(v : Bytes, fmt : Bytes) -> Bytes

    Runs the host formatter for a NUL terminated C string.

    format_with_double

    fn format_with_double(v : Double, fmt : Bytes) -> Bytes

    Runs the host formatter, growing the buffer once if the host reports that the output did not fit.

    format_with_int

    fn format_with_int(v : Int, fmt : Bytes) -> Bytes

    Runs the host formatter for a machine sized integer, used by %c.

    format_with_int64

    fn format_with_int64(v : Int64, fmt : Bytes) -> Bytes

    Runs the host formatter for a 64 bit integer.

    format_with_uint64

    fn format_with_uint64(v : UInt64, fmt : Bytes) -> Bytes

    Runs the host formatter for an unsigned 64 bit integer.

    gc_collect

    fn gc_collect(st : LuaState) -> Array[Value]

    One collection cycle. Returns the objects whose __gc has to run, in the order they should be called: the host layer runs them, because calling a Lua function is not something this layer can do.

    gc_collectable

    fn gc_collectable(v : Value) -> Bool

    Whether a value is one the collector can carry an opinion about. Strings and numbers are values, not objects: a weak table never drops them, and a __gc on them is not a thing.

    gc_register

    fn gc_register(st : LuaState, v : Value) -> Unit

    Notes an object whose metatable asks for attention, which is where a weak table or a finalizable object enters the collector's view. Called whenever a metatable is attached.

    global_func_name

    fn global_func_name(st : LuaState, obj : Value) -> String?

    pushglobalfuncname: where the running function lives in the globals, which is how a call made through the library tables names itself ("table.sort") when its call site does not.

    has_source

    fn has_source(s : LStr) -> Bool

    Whether a prototype was given a source at all.

    hash_slot

    fn hash_slot(key : Key, mask : Int) -> Int

    hex_address

    fn hex_address(n : Int64) -> String

    A pointer as the reference's %p prints it on this platform: sixteen lowercase hexadecimal digits with no 0x. Objects here have no real address, so their identity number stands in for one -- the shape is what print shows either way.

    hex_digit_value

    fn hex_digit_value(c : Int) -> Int

    hex_float_value

    fn hex_float_value(s : Bytes) -> Double

    The value of a hexadecimal float, read the way C99's strtod does: at most max_sig_digits digits enter the accumulator, and every further digit only moves the binary exponent. Each digit is worth four bits, and a digit after the point contributes -4.

    host_ctype

    fn host_ctype(which : Int, c : Int) -> Int

    The C ctype classification for one byte under the current locale.

    host_exit

    fn host_exit(code : Int) -> Unit

    Terminates the process, flushing standard streams first.

    host_stack_left

    fn host_stack_left() -> Int

    How much of the host stack is left below this call, in bytes, or -1 when the host cannot say. A call that re-enters the interpreter costs host stack, so what stops such a recursion is this measurement (MIN_HOST_STACK) and not only a count of levels.

    instr

    fn instr(op : Int, a : Int, b : Int, c : Int) -> Instr

    instr_a

    fn instr_a(op : Int, a : Int) -> Instr

    instr_ab

    fn instr_ab(op : Int, a : Int, b : Int) -> Instr

    Builds an instruction whose third operand is unused.

    int64_to_bytes

    fn int64_to_bytes(v : Int64) -> Bytes

    Decimal representation of an integer. Handled here rather than through the host so that the minimum 64 bit value, whose magnitude does not fit in an Int64, needs no special casing at the call site.

    int_equals_float

    fn int_equals_float(a : Int64, b : Double) -> Bool

    a == b where one side is an integer and the other a float, using the exact mathematical comparison rather than a lossy conversion.

    int_fits_double

    fn int_fits_double(a : Int64) -> Bool

    Whether a survives a conversion to a double unchanged, which lets an integer and a float be compared as floats.

    int_le_float

    fn int_le_float(i : Int64, f : Double) -> Bool

    int_lt_float

    fn int_lt_float(i : Int64, f : Double) -> Bool

    i < f for an integer and a float. A float that is out of the integer range is bigger or smaller than every integer, which is what the fallback reports.

    is_alnum_byte

    fn is_alnum_byte(c : Int) -> Bool

    is_alpha_byte

    fn is_alpha_byte(c : Int) -> Bool

    is_digit_byte

    fn is_digit_byte(c : Int) -> Bool

    is_hex_digit_byte

    fn is_hex_digit_byte(c : Int) -> Bool

    is_no_source

    fn is_no_source(source : Bytes) -> Bool

    Whether these bytes are that marker rather than a real name.

    is_space_byte

    fn is_space_byte(c : Int) -> Bool

    is_truthy_arg

    fn is_truthy_arg(st : LuaState, args : ArrayView[Value], n : Int) -> Bool

    key_hash

    fn key_hash(k : Key) -> Int

    key_of_value

    fn key_of_value(v : Value) -> Key?

    Builds the hash key for a value. None means the value cannot be used as a key (nil, or NaN).

    key_to_value

    fn key_to_value(k : Key) -> Value

    Rebuilds the original key value from a hash key.

    line_at

    fn line_at(p : LProto, pc : Int) -> Int

    live_size

    fn live_size(st : LuaState) -> Int

    What collectgarbage("count") reports, in bytes: the live size the last cycle measured, plus everything allocated since. A collection here is atomic, so the second part is exactly the garbage that has not been looked at yet -- which is what makes the count fall when a cycle runs.

    The two allocation clocks are read here rather than through an accessor each: this runs once per instruction, to decide whether a cycle is due, so the calls it makes are part of the dispatch cost.

    local_name

    fn local_name(p : LProto, reg : Int, pc : Int) -> String?

    luaF_getlocalname: the name of the reg-th local that is active at pc.

    locale_decpoint

    fn locale_decpoint() -> Int

    The current locale's decimal mark, for locale-aware number conversions.

    locale_generation

    let locale_generation :
    Ref
    [Int]

    Incremented whenever the C locale changes, so that cached locale tables (character classes and the like) can notice and rebuild.

    looks_like_integer_text

    fn looks_like_integer_text(b : Bytes) -> Bool

    True when every byte is a digit or a sign, i.e. the text would be taken for an integer.

    lstrcmp

    fn lstrcmp(a : Bytes, b : Bytes) -> Int

    Segment-wise locale comparison, as l_strcmp in the reference VM.

    lua_state_new

    fn lua_state_new() -> LuaState

    lua_state_raise_value

    fn[T] lua_state_raise_value(st : LuaState, v : Value) -> T raise LuaRaised

    Raises a value as an error, leaving it untouched.

    lua_str2num

    fn lua_str2num(s : Bytes) -> NumValue?

    The full numeral conversion: integer first, then float. A failed conversion is retried with the locale's decimal mark replaced by a dot, mirroring the fallback of l_str2d.

    make_builtin

    fn make_builtin(name : String, kind : Int, arity : Int, body : (LuaState, Array[Value], ArrayView[Value]) -> BuiltinResult raise LuaRaised, upvals : Array[Value]) -> LBuiltin

    max_before_mul10

    let max_before_mul10 : UInt64

    The largest power of ten that can be multiplied into a 64 bit integer without overflowing, and the largest digit allowed after it.

    max_last_digit

    let max_last_digit : UInt64

    metamethod_info

    fn metamethod_info(tm : String) -> String

    The phrase naming the metamethod an operation tried to call.

    next_object_id

    fn next_object_id() -> Int

    no_prots

    let no_prots : Array[Cont]

    no_source

    fn no_source() -> LStr

    The source of a chunk that has none: the one that was dumped stripped. An empty source is not the same thing -- load(s, "") names a chunk with the empty string, which the reference reports as [string ""], while a stripped one is reported as ?.

    no_tbc

    let no_tbc : Array[Int]

    no_values

    let no_values : Array[Value]

    The empty list of values that a frame with no varargs holds. Nothing ever writes to it -- a frame's varargs are only touched for a vararg prototype, and debug.setlocal only reaches one that is longer than the index it is given -- so a single shared list saves an allocation on every call.

    num_int

    fn num_int(d : Double) -> Value

    A float as the value to hand back to Lua: an integer when it holds one, a float otherwise. This is the reference's pushnumint, which is what makes math.floor(3.5) and the integral part of math.modf an integer while math.floor(math.huge) stays a float.

    number_to_bytes

    fn number_to_bytes(v : Value) -> Bytes

    The default textual form of a number, used by tostring and print.

    obj_counter

    let obj_counter :
    Ref
    [Int]

    obj_name

    fn obj_name(p : LProto, last_pc : Int, reg : Int) -> ObjName?

    getobjname: what register reg of p was loaded from at last_pc.

    op_name

    fn op_name(op : Int) -> String

    operand_info

    fn operand_info(st : LuaState, src : Int) -> String

    The phrase describing an operand encoded as above.

    opt_int

    fn opt_int(st : LuaState, args : ArrayView[Value], n : Int, fname : String, dflt : Int64) -> Int64 raise LuaRaised

    Optional integer argument.

    opt_number

    fn opt_number(st : LuaState, args : ArrayView[Value], n : Int, fname : String, dflt : Double) -> Double raise LuaRaised

    Optional number argument.

    position_at_level

    fn position_at_level(st : LuaState, level : Int) -> Bytes

    The chunk:line: prefix of the frame level steps up the stack. Level 1 is the function that called the running native function, which is what error(msg, level) reports.

    raise_fresh

    fn[T] raise_fresh(st : LuaState, v : Value) -> T raise LuaRaised

    Raises a value as an error that has just been created, which is the only kind the message handler of an enclosing xpcall is called for. Everything that invents an error goes through here; code that puts an error back in flight while the stack unwinds does not, so it is reported once.

    read_stdin_all

    fn read_stdin_all() -> Bytes

    Reads the standard input to the end. This is what lua does with no script named and what a chunk with no text is compiled from, and it reads the host's stream rather than the io library's handle for the standard input, as the reference does.

    read_whole_file

    fn read_whole_file(path : Bytes) -> Result[Bytes, Bytes]

    Reads a whole file, returning its contents together with an error message when it cannot be read.

    rk_index

    fn rk_index(rk : Int) -> Int

    rk_is_const

    fn rk_is_const(rk : Int) -> Bool

    runtime_error

    fn[T] runtime_error(st : LuaState, msg : String) -> T raise LuaRaised

    Raises a runtime error, prefixed with the current position.

    runtime_error_bytes

    fn[T] runtime_error_bytes(st : LuaState, msg : Bytes) -> T raise LuaRaised

    Raises a runtime error whose message is already a byte string.

    scan_float

    fn scan_float(s : Bytes) -> Double?

    Converts text to a float. Returns None when the text is not a float, or when it spells inf/nan, which Lua deliberately refuses.

    scan_integer

    fn scan_integer(s : Bytes) -> Int64?

    Converts text to an integer, or None when the text is not exactly an integer (a decimal value that overflows, a fractional part, trailing characters). Hexadecimal values wrap around modulo 2^64.

    source_for_message

    fn source_for_message(source : Bytes) -> String

    The source of a chunk as it appears in error messages. A function loaded from a stripped binary chunk has no source and reports '?'.

    src_iterator

    let src_iterator : Int

    src_none

    let src_none : Int

    Encodes where an operand was read from, so that names are computed only when an error is raised: a non-negative value is a stack slot, src_none means unknown, a value from up_src an upvalue, and src_iterator the implicit call a generic-for makes.

    str_is_shared

    fn str_is_shared(len : Int) -> Bool

    Whether equal strings of this length are one object. Short strings are interned; longer ones are not, so a caller that needs two equal strings to be the same object -- the lexer, whose anchored literals literals.lua compares by address -- has to know which case it is in.

    table_bytes

    fn table_bytes(t : LTable) -> Int

    The bytes a table's parts hold. This is the bulk of what a program that only fills a table allocates, so it is also what the interpreter's budget is spent on.

    text_of

    fn text_of(b : Bytes) -> String

    Decodes bytes as UTF-8, replacing malformed sequences. Used for diagnostics only; Lua values never round trip through this.

    tolower_byte

    fn tolower_byte(c : Int) -> Byte

    toupper_byte

    fn toupper_byte(c : Int) -> Byte

    two_pow_63

    let two_pow_63 : Double

    two_pow_63_neg

    let two_pow_63_neg : Double

    type_error_name

    fn type_error_name(_st : LuaState, v : Value) -> String

    The type name of a value as reported in argument errors. Values with a __name field report that name instead, which is how userdata types announce themselves.

    ubyte_at

    fn ubyte_at(b : Bytes, i : Int) -> Int

    Byte at i as an unsigned value in 0..255.

    up_src

    fn up_src(idx : Int) -> Int

    upvalue_info

    fn upvalue_info(st : LuaState, idx : Int) -> String

    The phrase describing the value in upvalue idx of the running frame.

    upvalue_name

    fn upvalue_name(p : LProto, i : Int) -> String

    The declared name of upvalue i.

    utf8_ident_size

    fn utf8_ident_size(c0 : Int, c1 : Int, c2 : Int, c3 : Int) -> Int

    The size in bytes of the name character whose code point starts at the bytes c0..c3, or 0 when no name character starts there. A byte that is not there is -1.

    ASCII letters, digits and _ count, as they do in the reference implementation; so does a well formed non-ASCII code point that is not one of the invisible ones, which is what lets a source file written in UTF-8 name things in its own language. That second clause is a deliberate extension: a chunk that uses it is not accepted by the reference's lislalpha, which knows only ASCII.

    value_to_double

    fn value_to_double(v : Value) -> NumConv

    Converts a value to a Double if it is a number.

    value_to_double_or_string

    fn value_to_double_or_string(v : Value) -> Double?

    Numeric coercion for check_number, which accepts numeric strings.

    value_to_int64

    fn value_to_int64(v : Value) -> IntConv

    Converts a value to an Int64 if it denotes an integral number.

    var_info

    fn var_info(st : LuaState, slot : Int) -> String

    The phrase describing the value in stack slot slot of the running frame, empty when no reasonable name exists.

    vm_error

    fn[T] vm_error(st : LuaState, msg : String) -> T raise LuaRaised

    Raises a runtime error, prefixed with the position vm_position gives.

    vm_position

    fn vm_position(st : LuaState) -> String

    The position a runtime error carries: the current frame's, and only when that frame is a Lua function. The reference's luaG_runerror adds source information only for a Lua frame, so an error raised while a host function is current -- pcall(nil) calling a value it cannot call -- has none, while a library function adds its caller's position instead (current_position).

    with_position

    fn with_position(st : LuaState, v : Value, level : Int) -> Value

    A string error value with a position in front of it. This is what error, assert and coroutine.wrap all do -- the reference's luaB_error -- so a value that is not a string is handed back unchanged, and level decides which frame the position comes from (position_at_level).

    write_stderr

    fn write_stderr(b : Bytes) -> Unit

    Writes bytes to standard error.

    write_stdout

    fn write_stdout(b : Bytes) -> Unit

    write_whole_file

    fn write_whole_file(path : Bytes, data : Bytes) -> Result[Unit, Bytes]

    Writes a whole file.

    writes_a

    fn writes_a(op : Int) -> Bool

    Whether the instruction writes its a register.