Merge branch 'newarray' into nextversion

This commit is contained in:
Roberto Ierusalimschy
2023-11-07 17:26:15 -03:00
12 changed files with 529 additions and 274 deletions

View File

@@ -184,13 +184,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);
}