Full abstraction for representation of array values

This commit is contained in:
Roberto Ierusalimschy
2023-10-30 14:25:59 -03:00
parent b8b709b6d4
commit 43c8e5bded
9 changed files with 128 additions and 93 deletions

View File

@@ -215,13 +215,16 @@ static void freestack (lua_State *L) {
*/
static void init_registry (lua_State *L, global_State *g) {
/* create registry */
TValue aux;
Table *registry = luaH_new(L);
sethvalue(L, &g->l_registry, registry);
luaH_resize(L, registry, LUA_RIDX_LAST, 0);
/* registry[LUA_RIDX_MAINTHREAD] = L */
setthvalue(L, &registry->array[LUA_RIDX_MAINTHREAD - 1], L);
setthvalue(L, &aux, L);
luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &aux);
/* registry[LUA_RIDX_GLOBALS] = new table (table of globals) */
sethvalue(L, &registry->array[LUA_RIDX_GLOBALS - 1], luaH_new(L));
sethvalue(L, &aux, luaH_new(L));
luaH_setint(L, registry, LUA_RIDX_GLOBALS, &aux);
}