aboutsummaryrefslogtreecommitdiff
path: root/src/keeper.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/keeper.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/keeper.cpp b/src/keeper.cpp
index 43f3125..cad9207 100644
--- a/src/keeper.cpp
+++ b/src/keeper.cpp
@@ -315,9 +315,7 @@ static void PushKeysDB(KeeperState const K_, StackIndex const idx_)
315 StackIndex const _absidx{ luaG_absindex(K_, idx_) }; 315 StackIndex const _absidx{ luaG_absindex(K_, idx_) };
316 kLindasRegKey.pushValue(K_); // K_: ... LindasDB 316 kLindasRegKey.pushValue(K_); // K_: ... LindasDB
317 lua_pushvalue(K_, _absidx); // K_: ... LindasDB linda 317 lua_pushvalue(K_, _absidx); // K_: ... LindasDB linda
318 lua_rawget(K_, -2); // K_: ... LindasDB KeysDB 318 if (luaG_rawget(K_, StackIndex{ -2 }) == LuaType::NIL) { // K_: ... LindasDB KeysDB
319 STACK_CHECK(K_, 2);
320 if (lua_isnil(K_, -1)) {
321 lua_pop(K_, 1); // K_: ... LindasDB 319 lua_pop(K_, 1); // K_: ... LindasDB
322 // add a new KeysDB table for this linda 320 // add a new KeysDB table for this linda
323 lua_newtable(K_); // K_: ... LindasDB KeysDB 321 lua_newtable(K_); // K_: ... LindasDB KeysDB
@@ -372,8 +370,7 @@ int keepercall_count(lua_State* const L_)
372 case 2: // _K: linda key 370 case 2: // _K: linda key
373 PushKeysDB(_K, StackIndex{ 1 }); // _K: linda key KeysDB 371 PushKeysDB(_K, StackIndex{ 1 }); // _K: linda key KeysDB
374 lua_replace(_K, 1); // _K: KeysDB key 372 lua_replace(_K, 1); // _K: KeysDB key
375 lua_rawget(_K, -2); // _K: KeysDB KeyUD|nil 373 if (luaG_rawget(_K, StackIndex{ -2 }) == LuaType::NIL) { // the key is unknown // _K: KeysDB KeyUD|nil
376 if (lua_isnil(_K, -1)) { // the key is unknown // _K: KeysDB nil
377 lua_remove(_K, -2); // _K: nil 374 lua_remove(_K, -2); // _K: nil
378 } else { // the key is known // _K: KeysDB KeyUD 375 } else { // the key is known // _K: KeysDB KeyUD
379 KeyUD* const _key{ KeyUD::GetPtr(_K, kIdxTop) }; 376 KeyUD* const _key{ KeyUD::GetPtr(_K, kIdxTop) };
@@ -656,8 +653,7 @@ int keepercall_send(lua_State* const L_)
656 PushKeysDB(_K, StackIndex{ 1 }); // _K: linda key val... KeysDB 653 PushKeysDB(_K, StackIndex{ 1 }); // _K: linda key val... KeysDB
657 // get the fifo associated to this key in this linda, create it if it doesn't exist 654 // get the fifo associated to this key in this linda, create it if it doesn't exist
658 lua_pushvalue(_K, 2); // _K: linda key val... KeysDB key 655 lua_pushvalue(_K, 2); // _K: linda key val... KeysDB key
659 lua_rawget(_K, -2); // _K: linda key val... KeysDB KeyUD|nil 656 if (luaG_rawget(_K, StackIndex{ -2 }) == LuaType::NIL) { // _K: linda key val... KeysDB KeyUD|nil
660 if (lua_isnil(_K, -1)) {
661 lua_pop(_K, 1); // _K: linda key val... KeysDB 657 lua_pop(_K, 1); // _K: linda key val... KeysDB
662 std::ignore = KeyUD::Create(KeeperState{ _K }); // _K: linda key val... KeysDB KeyUD 658 std::ignore = KeyUD::Create(KeeperState{ _K }); // _K: linda key val... KeysDB KeyUD
663 // KeysDB[key] = KeyUD 659 // KeysDB[key] = KeyUD
@@ -853,9 +849,9 @@ int Keeper::PushLindaStorage(Linda& linda_, DestState const L_)
853 STACK_CHECK_START_REL(_K, 0); 849 STACK_CHECK_START_REL(_K, 0);
854 kLindasRegKey.pushValue(_K); // _K: LindasDB L_: 850 kLindasRegKey.pushValue(_K); // _K: LindasDB L_:
855 lua_pushlightuserdata(_K, &linda_); // _K: LindasDB linda L_: 851 lua_pushlightuserdata(_K, &linda_); // _K: LindasDB linda L_:
856 lua_rawget(_K, -2); // _K: LindasDB KeysDB L_: 852 LuaType const _type{ luaG_rawget(_K, StackIndex{ -2 }) }; // _K: LindasDB KeysDB L_:
857 lua_remove(_K, -2); // _K: KeysDB L_: 853 lua_remove(_K, -2); // _K: KeysDB L_:
858 if (!lua_istable(_K, -1)) { // possible if we didn't send anything through that linda 854 if (_type != LuaType::TABLE) { // possible if we didn't send anything through that linda
859 lua_pop(_K, 1); // _K: L_: 855 lua_pop(_K, 1); // _K: L_:
860 STACK_CHECK(_K, 0); 856 STACK_CHECK(_K, 0);
861 return 0; 857 return 0;