Expand description
Auxiliary functions to manipulate prototypes and closures.
Port of reference/lua-5.4.7/src/lfunc.c (295 lines, 16 functions).
The companion header lfunc.h is merged here per PORTING.md §1.
§Design notes
The C implementation uses two intrusive linked lists managed through pointer fields embedded in stack slots and upvalue objects:
openupval: a singly-linked list ofUpVals sorted by stack level (highest first), threaded throughUpVal.u.open.next / .previous.tbclist: a to-be-closed variable list encoded asunsigned shortdelta offsets stored insideStackValue.tbclist.delta.
Both are replaced in the Rust port:
openupval→LuaState.openupval: Vec<GcRef<UpVal>>(descending by StackIdx).tbclist→LuaState.tbclist: Vec<StackIdx>(back = most recent entry).
The delta-encoding machinery (MAXDELTA, dummy nodes) is an artifact of the u16
delta field and is entirely superseded by the Vec<StackIdx> model.
Structs§
- Call
Info Idx - Index into the call-info stack.
- Stack
Idx - Index into the Lua value stack. Never a pointer or borrow. Stack reallocates; only indices are stable across mutations.