diff --git a/luprex/eris-master/src/eris.c b/luprex/eris-master/src/eris.c index 5fa7c691..d02f44e7 100644 --- a/luprex/eris-master/src/eris.c +++ b/luprex/eris-master/src/eris.c @@ -905,6 +905,9 @@ static void p_literaltable(Info *info) { /* ... tbl */ eris_checkstack(info->L, 3); + unsigned char bits = lua_getflagbits(info->L, -1); + WRITE_VALUE(bits, uint8_t); + /* Persist all key / value pairs. */ lua_pushnil(info->L); /* ... tbl nil */ while (lua_next(info->L, -2)) { /* ... tbl k v */ @@ -943,6 +946,8 @@ u_literaltable(Info *info) { /* ... */ eris_checkstack(info->L, 3); lua_newtable(info->L); /* ... tbl */ + unsigned char bits = READ_VALUE(uint8_t); + lua_setflagbits(info->L, -1, bits); /* Preregister table for handling of cycles (keys, values or metatable). */ registerobject(info); diff --git a/luprex/eris-master/src/lapi.c b/luprex/eris-master/src/lapi.c index 310078d2..801619f0 100644 --- a/luprex/eris-master/src/lapi.c +++ b/luprex/eris-master/src/lapi.c @@ -898,6 +898,38 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) { } +LUA_API void lua_setflagbits (lua_State *L, int idx, unsigned char bits) { + TValue *obj; + Table *tab; + lua_lock(L); + obj = index2addr(L, idx); + api_check(L, ttistable(obj), "table expected"); + tab = hvalue(obj); + tab->flagbits = bits; + lua_unlock(L); +} + +LUA_API void lua_modflagbits (lua_State *L, int idx, unsigned char set, unsigned char clear) { + TValue *obj; + Table *tab; + lua_lock(L); + obj = index2addr(L, idx); + api_check(L, ttistable(obj), "table expected"); + tab = hvalue(obj); + tab->flagbits |= set; + tab->flagbits &= (~clear); + lua_unlock(L); +} + +LUA_API unsigned char lua_getflagbits (lua_State *L, int idx) { + TValue *obj; + Table *tab; + obj = index2addr(L, idx); + api_check(L, ttistable(obj), "table expected"); + tab = hvalue(obj); + return tab->flagbits; +} + /* ** `load' and `call' functions (run Lua code) */ diff --git a/luprex/eris-master/src/lobject.h b/luprex/eris-master/src/lobject.h index 1d1db9dd..9ce9bbc5 100644 --- a/luprex/eris-master/src/lobject.h +++ b/luprex/eris-master/src/lobject.h @@ -556,6 +556,7 @@ typedef struct Node { typedef struct Table { CommonHeader; lu_byte flags; /* 1<

h; t->metatable = NULL; t->flags = cast_byte(~0); + t->flagbits = 0; t->array = NULL; t->sizearray = 0; t->node = cast(Node *, dummynode); diff --git a/luprex/eris-master/src/lua.h b/luprex/eris-master/src/lua.h index a7f54051..64ccaa14 100644 --- a/luprex/eris-master/src/lua.h +++ b/luprex/eris-master/src/lua.h @@ -237,15 +237,17 @@ LUA_API void (lua_getuservalue) (lua_State *L, int idx); /* ** set functions (stack -> Lua) */ -LUA_API void (lua_setglobal) (lua_State *L, const char *var); -LUA_API void (lua_settable) (lua_State *L, int idx); -LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); -LUA_API void (lua_rawset) (lua_State *L, int idx); -LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); -LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); -LUA_API int (lua_setmetatable) (lua_State *L, int objindex); -LUA_API void (lua_setuservalue) (lua_State *L, int idx); - +LUA_API void (lua_setglobal) (lua_State *L, const char *var); +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API void (lua_setuservalue) (lua_State *L, int idx); +LUA_API void (lua_setflagbits) (lua_State *L, int idx, unsigned char bits); +LUA_API void (lua_modflagbits) (lua_State *L, int idx, unsigned char set, unsigned char clear); +LUA_API unsigned char (lua_getflagbits) (lua_State *L, int idx); /* ** 'load' and 'call' functions (load and run Lua code)