benilla-re systems structs docs

addk

function · lua · boundary

Address
0x700ad0 · 189 bytes, up to 0x700b8c
Meaning
Returns a constant's index, adding the value with its context word when it is new
Confidence
verified, proof one
Finding
lua/codegen#constants-and-the-context-word

Finding: Constants and the context word in lua: the code generator

addk looks a constant up in the function's constant table, a Lua table from value to index, and returns the index it holds; a new constant is appended to the prototype's constants, at most 0x3ffff (constant table overflow), and its index stored in the table. The client stamps constants with the execution-context word (ui/luastate, The context word): luaK_stringK, luaK_numberK and nil_constant build the value with the current word s_scriptContext, and addk copies all 16 bytes into the prototype, makes a nonzero word current while s_scriptContextDepth is nonzero (test ecx,ecx; je, 0x700b54), and gives the table's index entry the current word. A chunk's constants carry the word current when they were first added.

functionnamedecided by
0x700ad0addkluaH_get (0x700adc), number gives __ftol (0x700ae1..0x700ae9), luaM_growaux (0x700b18), 16-byte copy (0x700b30..0x700b43), word made current (0x700b46..0x700b58), luaH_set with the word (0x700b64..0x700b7b)
0x700aa0luaK_stringKtag 4 (0x700ab5), word (0x700aa6, 0x700abc), addk (0x700abf)
0x700b90luaK_numberKtag 3 (0x700bae), word (0x700b99, 0x700ba4), addk (0x700bb8)
0x701070nil_constantnil value and the constant table as its key, each with the word (0x701076..0x701099), addk (0x70109c)

The derivation is in the doc.

Callers 3

Callees 4

Calls and jumps by a bare address, from tables/calls.tsv.