@@ -363,7 +363,7 @@ void VirtualMachine::execute(CallInfo *ci) {
363363 };
364364
365365 // Lambda: Order operations with immediate operand
366- auto op_orderI = [&](auto opi, auto opf, int inv, TMS tm , Instruction i) {
366+ auto op_orderI = [&](auto opi, auto opf, int inv, TMS metamethodEvent , Instruction i) {
367367 TValue *ra = getValueA (i);
368368 int cond;
369369 int im = InstructionView (i).sb ();
@@ -376,7 +376,7 @@ void VirtualMachine::execute(CallInfo *ci) {
376376 }
377377 else {
378378 int isf = InstructionView (i).c ();
379- protectCall ([&]() { cond = luaT_callorderiTM (L, ra, im, inv, isf, tm ); });
379+ protectCall ([&]() { cond = luaT_callorderiTM (L, ra, im, inv, isf, metamethodEvent ); });
380380 }
381381 performConditionalJump (cond, ci, i);
382382 };
@@ -746,30 +746,30 @@ void VirtualMachine::execute(CallInfo *ci) {
746746 auto ra = getRegisterA (i);
747747 auto pi = *(pc - 2 ); /* original arith. expression */
748748 auto *rb = getValueB (i);
749- auto tm = static_cast <TMS>(InstructionView (i).c ());
749+ auto metamethodEvent = static_cast <TMS>(InstructionView (i).c ());
750750 auto result = getRegisterA (pi);
751751 lua_assert (OP_ADD <= InstructionView (pi).opcode () && InstructionView (pi).opcode () <= OP_SHR);
752- protectCall ([&]() { luaT_trybinTM (L, s2v (ra), rb, result, tm ); });
752+ protectCall ([&]() { luaT_trybinTM (L, s2v (ra), rb, result, metamethodEvent ); });
753753 break ;
754754 }
755755 case OP_MMBINI: {
756756 auto ra = getRegisterA (i);
757757 auto pi = *(pc - 2 ); /* original arith. expression */
758758 auto imm = InstructionView (i).sb ();
759- auto tm = static_cast <TMS>(InstructionView (i).c ());
759+ auto metamethodEvent = static_cast <TMS>(InstructionView (i).c ());
760760 auto flip = InstructionView (i).k ();
761761 auto result = getRegisterA (pi);
762- protectCall ([&]() { luaT_trybiniTM (L, s2v (ra), imm, flip, result, tm ); });
762+ protectCall ([&]() { luaT_trybiniTM (L, s2v (ra), imm, flip, result, metamethodEvent ); });
763763 break ;
764764 }
765765 case OP_MMBINK: {
766766 auto ra = getRegisterA (i);
767767 auto pi = *(pc - 2 ); /* original arith. expression */
768768 auto *imm = getConstantB (i);
769- auto tm = static_cast <TMS>(InstructionView (i).c ());
769+ auto metamethodEvent = static_cast <TMS>(InstructionView (i).c ());
770770 auto flip = InstructionView (i).k ();
771771 auto result = getRegisterA (pi);
772- protectCall ([&]() { luaT_trybinassocTM (L, s2v (ra), imm, flip, result, tm ); });
772+ protectCall ([&]() { luaT_trybinassocTM (L, s2v (ra), imm, flip, result, metamethodEvent ); });
773773 break ;
774774 }
775775 case OP_UNM: {
@@ -1338,7 +1338,7 @@ int VirtualMachine::lessEqual(const TValue *l, const TValue *r) const {
13381338}
13391339
13401340int VirtualMachine::equalObj (const TValue *t1, const TValue *t2) const {
1341- const TValue *tm ;
1341+ const TValue *metamethod ;
13421342 if (ttype (t1) != ttype (t2)) /* not the same type? */
13431343 return 0 ;
13441344 else if (ttypetag (t1) != ttypetag (t2)) {
@@ -1376,28 +1376,28 @@ int VirtualMachine::equalObj(const TValue *t1, const TValue *t2) const {
13761376 case LuaT::USERDATA: {
13771377 if (uvalue (t1) == uvalue (t2)) return 1 ;
13781378 else if (L == nullptr ) return 0 ;
1379- tm = fasttm (L, uvalue (t1)->getMetatable (), TMS::TM_EQ);
1380- if (tm == nullptr )
1381- tm = fasttm (L, uvalue (t2)->getMetatable (), TMS::TM_EQ);
1379+ metamethod = fasttm (L, uvalue (t1)->getMetatable (), TMS::TM_EQ);
1380+ if (metamethod == nullptr )
1381+ metamethod = fasttm (L, uvalue (t2)->getMetatable (), TMS::TM_EQ);
13821382 break ; /* will try TM */
13831383 }
13841384 case LuaT::TABLE: {
13851385 if (hvalue (t1) == hvalue (t2)) return 1 ;
13861386 else if (L == nullptr ) return 0 ;
1387- tm = fasttm (L, hvalue (t1)->getMetatable (), TMS::TM_EQ);
1388- if (tm == nullptr )
1389- tm = fasttm (L, hvalue (t2)->getMetatable (), TMS::TM_EQ);
1387+ metamethod = fasttm (L, hvalue (t1)->getMetatable (), TMS::TM_EQ);
1388+ if (metamethod == nullptr )
1389+ metamethod = fasttm (L, hvalue (t2)->getMetatable (), TMS::TM_EQ);
13901390 break ; /* will try TM */
13911391 }
13921392 case LuaT::LCF:
13931393 return (fvalue (t1) == fvalue (t2));
13941394 default : /* functions and threads */
13951395 return (gcvalue (t1) == gcvalue (t2));
13961396 }
1397- if (tm == nullptr ) /* no TM? */
1397+ if (metamethod == nullptr ) /* no TM? */
13981398 return 0 ; /* objects are different */
13991399 else {
1400- auto tag = luaT_callTMres (L, tm , t1, t2, L->getTop ().p ); /* call TM */
1400+ auto tag = luaT_callTMres (L, metamethod , t1, t2, L->getTop ().p ); /* call TM */
14011401 return !tagisfalse (tag);
14021402 }
14031403 }
@@ -1406,28 +1406,28 @@ int VirtualMachine::equalObj(const TValue *t1, const TValue *t2) const {
14061406// === TABLE OPERATIONS ===
14071407
14081408LuaT VirtualMachine::finishGet (const TValue *t, TValue *key, StkId val, LuaT tag) const {
1409- const TValue *tm ; /* metamethod */
1409+ const TValue *metamethod ; /* metamethod */
14101410 for (int loop = 0 ; loop < MAXTAGLOOP; loop++) {
14111411 if (tag == LuaT::NOTABLE) { /* 't' is not a table? */
14121412 lua_assert (!ttistable (t));
1413- tm = luaT_gettmbyobj (L, t, TMS::TM_INDEX);
1414- if (l_unlikely (notm (tm )))
1413+ metamethod = luaT_gettmbyobj (L, t, TMS::TM_INDEX);
1414+ if (l_unlikely (notm (metamethod )))
14151415 luaG_typeerror (L, t, " index" ); /* no metamethod */
14161416 /* else will try the metamethod */
14171417 }
14181418 else { /* 't' is a table */
1419- tm = fasttm (L, hvalue (t)->getMetatable (), TMS::TM_INDEX); /* table's metamethod */
1420- if (tm == nullptr ) { /* no metamethod? */
1419+ metamethod = fasttm (L, hvalue (t)->getMetatable (), TMS::TM_INDEX); /* table's metamethod */
1420+ if (metamethod == nullptr ) { /* no metamethod? */
14211421 setnilvalue (s2v (val)); /* result is nil */
14221422 return LuaT::NIL;
14231423 }
14241424 /* else will try the metamethod */
14251425 }
1426- if (ttisfunction (tm )) { /* is metamethod a function? */
1427- tag = luaT_callTMres (L, tm , t, key, val); /* call it */
1426+ if (ttisfunction (metamethod )) { /* is metamethod a function? */
1427+ tag = luaT_callTMres (L, metamethod , t, key, val); /* call it */
14281428 return tag; /* return tag of the result */
14291429 }
1430- t = tm ; /* else try to access 'tm[key]' */
1430+ t = metamethod ; /* else try to access 'tm[key]' */
14311431 tag = fastget (t, key, s2v (val), [](Table* tbl, const TValue* k, TValue* res) { return tbl->get (k, res); });
14321432 if (!tagisempty (tag))
14331433 return tag; /* done */
@@ -1439,11 +1439,11 @@ LuaT VirtualMachine::finishGet(const TValue *t, TValue *key, StkId val, LuaT tag
14391439
14401440void VirtualMachine::finishSet (const TValue *t, TValue *key, TValue *val, int hres) const {
14411441 for (int loop = 0 ; loop < MAXTAGLOOP; loop++) {
1442- const TValue *tm ; /* '__newindex' metamethod */
1442+ const TValue *metamethod ; /* '__newindex' metamethod */
14431443 if (hres != HNOTATABLE) { /* is 't' a table? */
14441444 auto *h = hvalue (t); /* save 't' table */
1445- tm = fasttm (L, h->getMetatable (), TMS::TM_NEWINDEX); /* get metamethod */
1446- if (tm == nullptr ) { /* no metamethod? */
1445+ metamethod = fasttm (L, h->getMetatable (), TMS::TM_NEWINDEX); /* get metamethod */
1446+ if (metamethod == nullptr ) { /* no metamethod? */
14471447 sethvalue2s (L, L->getTop ().p , h); /* anchor 't' */
14481448 L->getStackSubsystem ().push (); /* assume EXTRA_STACK */
14491449 h->finishSet (L, key, val, hres); /* set new value */
@@ -1455,16 +1455,16 @@ void VirtualMachine::finishSet(const TValue *t, TValue *key, TValue *val, int hr
14551455 /* else will try the metamethod */
14561456 }
14571457 else { /* not a table; check metamethod */
1458- tm = luaT_gettmbyobj (L, t, TMS::TM_NEWINDEX);
1459- if (l_unlikely (notm (tm )))
1458+ metamethod = luaT_gettmbyobj (L, t, TMS::TM_NEWINDEX);
1459+ if (l_unlikely (notm (metamethod )))
14601460 luaG_typeerror (L, t, " index" );
14611461 }
14621462 /* try the metamethod */
1463- if (ttisfunction (tm )) {
1464- luaT_callTM (L, tm , t, key, val);
1463+ if (ttisfunction (metamethod )) {
1464+ luaT_callTM (L, metamethod , t, key, val);
14651465 return ;
14661466 }
1467- t = tm ; /* else repeat assignment over 'tm' */
1467+ t = metamethod ; /* else repeat assignment over 'tm' */
14681468 hres = fastset (t, key, val, [](Table* tbl, const TValue* k, TValue* v) { return tbl->pset (k, v); });
14691469 if (hres == HOK) {
14701470 finishfastset (t, val);
@@ -1554,12 +1554,12 @@ void VirtualMachine::concat(int total) {
15541554}
15551555
15561556void VirtualMachine::objlen (StkId ra, const TValue *rb) {
1557- const TValue *tm ;
1557+ const TValue *metamethod ;
15581558 switch (ttypetag (rb)) {
15591559 case LuaT::TABLE: {
15601560 Table *h = hvalue (rb);
1561- tm = fasttm (L, h->getMetatable (), TMS::TM_LEN);
1562- if (tm ) break ; /* metamethod? break switch to call it */
1561+ metamethod = fasttm (L, h->getMetatable (), TMS::TM_LEN);
1562+ if (metamethod ) break ; /* metamethod? break switch to call it */
15631563 s2v (ra)->setInt (l_castU2S (h->getn (L))); /* else primitive len */
15641564 return ;
15651565 }
@@ -1572,11 +1572,11 @@ void VirtualMachine::objlen(StkId ra, const TValue *rb) {
15721572 return ;
15731573 }
15741574 default : { /* try metamethod */
1575- tm = luaT_gettmbyobj (L, rb, TMS::TM_LEN);
1576- if (l_unlikely (notm (tm ))) /* no metamethod? */
1575+ metamethod = luaT_gettmbyobj (L, rb, TMS::TM_LEN);
1576+ if (l_unlikely (notm (metamethod ))) /* no metamethod? */
15771577 luaG_typeerror (L, rb, " get length of" );
15781578 break ;
15791579 }
15801580 }
1581- luaT_callTMres (L, tm , rb, rb, ra);
1581+ luaT_callTMres (L, metamethod , rb, rb, ra);
15821582}
0 commit comments