@@ -126,7 +126,7 @@ int FuncState::condjump(OpCode o, int A, int B, int C, int k) {
126126*/
127127Instruction *FuncState::getjumpcontrol (int position) {
128128 Instruction *pi = &getProto ()->getCode ()[position];
129- if (position >= 1 && testTMode ( InstructionView (*(pi-1 )).opcode () ))
129+ if (position >= 1 && InstructionView (*(pi-1 )).testTMode ( ))
130130 return pi-1 ;
131131 else
132132 return pi;
@@ -663,9 +663,10 @@ void FuncState::codeABRK(OpCode o, int A, int B, expdesc *ec) {
663663*/
664664void FuncState::negatecondition (expdesc *e) {
665665 Instruction *instr = getjumpcontrol (e->getInfo ());
666- lua_assert (testTMode (InstructionView (*instr).opcode ()) && InstructionView (*instr).opcode () != OP_TESTSET &&
667- InstructionView (*instr).opcode () != OP_TEST);
668- SETARG_k (*instr, static_cast <unsigned int >(InstructionView (*instr).k () ^ 1 ));
666+ InstructionView view (*instr);
667+ lua_assert (view.testTMode () && view.opcode () != OP_TESTSET &&
668+ view.opcode () != OP_TEST);
669+ SETARG_k (*instr, static_cast <unsigned int >(view.k () ^ 1 ));
669670}
670671
671672/*
@@ -732,52 +733,52 @@ int FuncState::isKstr(expdesc *e) {
732733/*
733734** Check whether expression 'e' is a literal integer.
734735*/
735- static int isKint (expdesc *e) {
736+ static bool isKint (expdesc *e) {
736737 return (e->getKind () == VKINT && !hasjumps (e));
737738}
738739
739740/*
740741** Check whether expression 'e' is a literal integer in
741742** proper range to fit in register C
742743*/
743- static int isCint (expdesc *e) {
744+ static bool isCint (expdesc *e) {
744745 return isKint (e) && (l_castS2U (e->getIntValue ()) <= l_castS2U (MAXARG_C));
745746}
746747
747748/*
748749** Check whether expression 'e' is a literal integer in
749750** proper range to fit in register sC
750751*/
751- static int isSCint (expdesc *e) {
752+ static bool isSCint (expdesc *e) {
752753 return isKint (e) && fitsC (e->getIntValue ());
753754}
754755
755756/*
756757** Check whether expression 'e' is a literal integer or float in
757758** proper range to fit in a register (sB or sC).
758759*/
759- static int isSCnumber (expdesc *e, int *pi, int *isfloat) {
760+ static bool isSCnumber (expdesc *e, int *pi, int *isfloat) {
760761 lua_Integer i;
761762 if (e->getKind () == VKINT)
762763 i = e->getIntValue ();
763764 else if (e->getKind () == VKFLT && luaV_flttointeger (e->getFloatValue (), &i, F2Imod::F2Ieq))
764765 *isfloat = 1 ;
765766 else
766- return 0 ; /* not a number */
767+ return false ; /* not a number */
767768 if (!hasjumps (e) && fitsC (i)) {
768769 *pi = int2sC (cast_int (i));
769- return 1 ;
770+ return true ;
770771 }
771772 else
772- return 0 ;
773+ return false ;
773774}
774775
775776/*
776777** Return false if folding can raise an error.
777778** Bitwise operations need operands convertible to integers; division
778779** operations cannot have 0 as divisor.
779780*/
780- static int validop (int op, TValue *v1, TValue *v2) {
781+ static bool validop (int op, TValue *v1, TValue *v2) {
781782 switch (op) {
782783 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
783784 case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
@@ -787,7 +788,7 @@ static int validop (int op, TValue *v1, TValue *v2) {
787788 }
788789 case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */
789790 return (nvalue (v2) != 0 );
790- default : return 1 ; /* everything else is valid */
791+ default : return true ; /* everything else is valid */
791792 }
792793}
793794
@@ -1485,8 +1486,7 @@ int FuncState::getlabel() {
14851486 return getPC ();
14861487}
14871488
1488- void FuncState::prefix (int opr, expdesc *e, int line) {
1489- UnOpr op = static_cast <UnOpr>(opr);
1489+ void FuncState::prefix (UnOpr op, expdesc *e, int line) {
14901490 expdesc ef;
14911491 ef.setKind (VKINT);
14921492 ef.setIntValue (0 );
@@ -1495,7 +1495,7 @@ void FuncState::prefix(int opr, expdesc *e, int line) {
14951495 dischargevars (e);
14961496 switch (op) {
14971497 case UnOpr::OPR_MINUS: case UnOpr::OPR_BNOT: /* use 'ef' as fake 2nd operand */
1498- if (constfolding (cast_int (opr + LUA_OPUNM) , e, &ef))
1498+ if (constfolding (cast_int (op) + LUA_OPUNM, e, &ef))
14991499 break ;
15001500 /* else */ /* FALLTHROUGH */
15011501 case UnOpr::OPR_LEN:
@@ -1506,8 +1506,7 @@ void FuncState::prefix(int opr, expdesc *e, int line) {
15061506 }
15071507}
15081508
1509- void FuncState::infix (int opr, expdesc *v) {
1510- BinOpr op = static_cast <BinOpr>(opr);
1509+ void FuncState::infix (BinOpr op, expdesc *v) {
15111510 dischargevars (v);
15121511 switch (op) {
15131512 case BinOpr::OPR_AND: {
@@ -1551,10 +1550,9 @@ void FuncState::infix(int opr, expdesc *v) {
15511550 }
15521551}
15531552
1554- void FuncState::posfix (int opr, expdesc *e1 , expdesc *e2 , int line) {
1555- BinOpr op = static_cast <BinOpr>(opr);
1553+ void FuncState::posfix (BinOpr op, expdesc *e1 , expdesc *e2 , int line) {
15561554 dischargevars (e2 );
1557- if (foldbinop (op) && constfolding (cast_int (opr + LUA_OPADD) , e1 , e2 ))
1555+ if (foldbinop (op) && constfolding (cast_int (op) + LUA_OPADD, e1 , e2 ))
15581556 return ; /* done by folding */
15591557 switch (op) {
15601558 case BinOpr::OPR_AND: {
0 commit comments