Eliminate LuaStack::rawgeti, it's not safe

This commit is contained in:
2021-11-17 15:11:55 -05:00
parent fb043e9971
commit 0881e33c6f
5 changed files with 32 additions and 32 deletions

View File

@@ -263,7 +263,7 @@ static void set_transmitted_value(LuaStack &LS, LuaSlot tangibles, LuaSlot ntmap
return;
}
case LUA_TT_GENERAL: {
LS.rawgeti(target, ntmap, sb->read_int32());
LS.rawget(target, ntmap, sb->read_int32());
return;
}
case LUA_TT_CLASS: {
@@ -272,7 +272,7 @@ static void set_transmitted_value(LuaStack &LS, LuaSlot tangibles, LuaSlot ntmap
}
case LUA_TT_TANGIBLE: {
int64_t id = sb->read_int64();
LS.rawgeti(target, tangibles, id);
LS.rawget(target, tangibles, id);
if (LS.isnil(target)) {
World *w = World::fetch_global_pointer(LS.state());
w->tangible_make(LS.state(), id, "nowhere", true);
@@ -321,7 +321,7 @@ void World::patch_numbered_tables(StreamBuffer *sb) {
int nmodified = sb->read_int32();
for (int i = 0; i < nmodified; i++) {
int index = sb->read_int32();
LS.rawgeti(tab, ntmap, index);
LS.rawget(tab, ntmap, index);
assert(LS.istable(tab));
patch_table(LS, tangibles, ntmap, tab, sb);
}
@@ -347,9 +347,9 @@ void World::diff_numbered_tables(lua_State *master, StreamBuffer *sb) {
int s_top = lua_gettop(synch);
int m_top = lua_gettop(master);
for (int id = 1; id <= m_ntables; id++) {
MLS.rawgeti(mtab, mntmap, id);
MLS.rawget(mtab, mntmap, id);
if (MLS.istable(mtab)) {
SLS.rawgeti(stab, sntmap, id);
SLS.rawget(stab, sntmap, id);
assert(SLS.istable(stab));
int tw = sb->total_writes();
sb->write_int32(id);
@@ -379,7 +379,7 @@ void World::patch_tangible_databases(StreamBuffer *sb) {
int nmodified = sb->read_int32();
for (int i = 0; i < nmodified; i++) {
int64_t id = sb->read_int64();
LS.rawgeti(tab, tangibles, id);
LS.rawget(tab, tangibles, id);
assert(LS.istable(tab));
patch_table(LS, tangibles, ntmap, tab, sb);
}