1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Annotate Lua packer with more comments

This commit is contained in:
sfan5 2024-02-15 16:24:15 +01:00
parent 2b97fead9e
commit 933432e62d
2 changed files with 85 additions and 23 deletions

View file

@ -39,30 +39,31 @@ extern "C" {
#define INSTR_PUSHREF (-12)
/**
* Represents a single instruction that pushes a new value or works with existing ones.
* Represents a single instruction that pushes a new value or operates with existing ones.
*/
struct PackedInstr
{
s16 type; // LUA_T* or INSTR_*
u16 set_into; // set into table on stack
bool keep_ref; // is referenced later by INSTR_PUSHREF?
bool keep_ref; // referenced later by INSTR_PUSHREF?
bool pop; // remove from stack?
// Note: the remaining members are named by type, not usage
union {
bool bdata; // boolean: value
lua_Number ndata; // number: value
struct {
u16 uidata1, uidata2; // table: narr, nrec
u16 uidata1, uidata2; // table: narr | nrec
};
struct {
/*
SETTABLE: key index, value index
SETTABLE: key index | value index
POP: indices to remove
otherwise w/ set_into: numeric key, -
PUSHREF: index of referenced instr | unused
otherwise w/ set_into: numeric key | unused
*/
s32 sidata1, sidata2;
};
void *ptrdata; // userdata: implementation defined
s32 ref; // PUSHREF: index of referenced instr
};
/*
- string: value
@ -78,7 +79,7 @@ struct PackedInstr
/**
* A packed value can be a primitive like a string or number but also a table
* including all of its contents. It is made up of a linear stream of
* 'instructions' that build the final value when executed.
* instructions that build the final value when executed.
*/
struct PackedValue
{