|
static int | absidx (lua_State *L, int idx) |
|
static bool | uses_sdata (int type) |
|
static bool | uses_union (int type) |
|
static bool | can_set_into (int ktype, int vtype) |
|
static bool | suitable_key (lua_State *L, int idx) |
|
static bool | get_known_lua_metatables (lua_State *L) |
| Push core.known_metatables to the stack if it exists.
|
|
static auto | emplace (PackedValue &pv, s16 type) |
| Append instruction to end.
|
|
void | script_register_packer (lua_State *L, const char *regname, PackInFunc fin, PackOutFunc fout) |
|
static bool | find_packer (const char *regname, PackerTuple &out) |
| Find a packer for a metatable.
|
|
static bool | find_packer (lua_State *L, int idx, PackerTuple &out) |
| Find a packer matching the metatable of the Lua value.
|
|
static VectorRef< PackedInstr > | record_object (lua_State *L, int idx, PackedValue &pv, std::unordered_map< const void *, s32 > &seen) |
| Keeps track of seen objects, which is needed to make circular references work.
|
|
static VectorRef< PackedInstr > | pack_inner (lua_State *L, int idx, int vidx, PackedValue &pv, std::unordered_map< const void *, s32 > &seen) |
| Pack a single Lua value and add it to the instruction stream.
|
|
PackedValue * | script_pack (lua_State *L, int idx) |
|
void | script_unpack (lua_State *L, PackedValue *pv) |
|
void | script_dump_packed (const PackedValue *val) |
|
static VectorRef< PackedInstr > pack_inner |
( |
lua_State * | L, |
|
|
int | idx, |
|
|
int | vidx, |
|
|
PackedValue & | pv, |
|
|
std::unordered_map< const void *, s32 > & | seen ) |
|
static |
Pack a single Lua value and add it to the instruction stream.
- Parameters
-
L | Lua state |
idx | Index of value on Lua stack. Must be positive, use absidx if not! |
vidx | Next free index on the stack as it would look during unpacking. (v = virtual) |
pv | target |
seen | Map of seen objects (see record_object) |
- Returns
- reference to the instruction that creates the value
References absidx(), call_string_dump(), can_set_into(), PackedValue::contains_userdata, emplace(), find_packer(), get_known_lua_metatables(), idx, INSTR_POP, INSTR_SETMETATABLE, INSTR_SETTABLE, pack_inner(), record_object(), and suitable_key().
Referenced by pack_inner(), and script_pack().
static VectorRef< PackedInstr > record_object |
( |
lua_State * | L, |
|
|
int | idx, |
|
|
PackedValue & | pv, |
|
|
std::unordered_map< const void *, s32 > & | seen ) |
|
static |
Keeps track of seen objects, which is needed to make circular references work.
The first time an object is seen it remembers the instruction index. The caller is expected to add instructions that produce the value immediately after. For second, third, ... calls it pushes an instruction that references the already created value.
- Parameters
-
L | Lua state |
idx | Index of value on Lua stack |
pv | target |
seen | Map of seen objects |
- Returns
- empty reference (first time) or reference to instruction that reproduces the value (otherwise)
References emplace(), PackedValue::i, idx, INSTR_PUSHREF, and S32_MAX.
Referenced by pack_inner().