Clear interface between references and predefines

The reference system has a defined way to add initial values to the
table where it operates.
This commit is contained in:
Roberto Ierusalimschy
2024-01-15 11:31:49 -03:00
parent 8eb0abc9db
commit 17e0c29d9b
7 changed files with 92 additions and 43 deletions

View File

@@ -189,6 +189,9 @@ static void init_registry (lua_State *L, global_State *g) {
Table *registry = luaH_new(L);
sethvalue(L, &g->l_registry, registry);
luaH_resize(L, registry, LUA_RIDX_LAST, 0);
/* registry[1] = false */
setbfvalue(&aux);
luaH_setint(L, registry, 1, &aux);
/* registry[LUA_RIDX_MAINTHREAD] = L */
setthvalue(L, &aux, L);
luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &aux);