@@ -89,7 +89,7 @@ Instruction *FuncState::previousinstruction() {
8989** a list of jumps.
9090*/
9191int FuncState::getjump (int position) {
92- int offset = InstructionView (getProto ()->getCode ()[position]).sj ();
92+ auto offset = InstructionView (getProto ()->getCode ()[position]).sj ();
9393 if (offset == NO_JUMP) /* point to itself represents end of list */
9494 return NO_JUMP; /* end of list */
9595 else
@@ -101,8 +101,8 @@ int FuncState::getjump(int position) {
101101** (Jump addresses are relative in Lua)
102102*/
103103void FuncState::fixjump (int position, int dest) {
104- Instruction *jmp = &getProto ()->getCode ()[position];
105- int offset = dest - (position + 1 );
104+ auto *jmp = &getProto ()->getCode ()[position];
105+ auto offset = dest - (position + 1 );
106106 lua_assert (dest != NO_JUMP);
107107 if (!(-OFFSET_sJ <= offset && offset <= MAXARG_sJ - OFFSET_sJ))
108108 getLexState ()->syntaxError (" control structure too long" );
@@ -125,7 +125,7 @@ int FuncState::condjump(OpCode o, int A, int B, int C, int k) {
125125** unconditional.
126126*/
127127Instruction *FuncState::getjumpcontrol (int position) {
128- Instruction *pi = &getProto ()->getCode ()[position];
128+ auto *pi = &getProto ()->getCode ()[position];
129129 if (position >= 1 && InstructionView (*(pi-1 )).testTMode ())
130130 return pi-1 ;
131131 else
@@ -140,7 +140,7 @@ Instruction *FuncState::getjumpcontrol(int position) {
140140** no register value)
141141*/
142142int FuncState::patchtestreg (int node, int reg) {
143- Instruction *i = getjumpcontrol (node);
143+ auto *i = getjumpcontrol (node);
144144 if (InstructionView (*i).opcode () != OP_TESTSET)
145145 return 0 ; /* cannot patch other instructions */
146146 if (reg != NO_REG && reg != InstructionView (*i).b ())
@@ -169,7 +169,7 @@ int FuncState::removevalues(int list) {
169169*/
170170void FuncState::patchlistaux (int list, int vtarget, int reg, int dtarget) {
171171 while (list != NO_JUMP) {
172- int next = getjump (list);
172+ auto next = getjump (list);
173173 if (patchtestreg (list, reg))
174174 fixjump (list, vtarget);
175175 else
@@ -189,8 +189,8 @@ void FuncState::patchlistaux(int list, int vtarget, int reg, int dtarget) {
189189** Otherwise, store the difference from last line in 'lineinfo'.
190190*/
191191void FuncState::savelineinfo (Proto *proto, int line) {
192- int linedif = line - getPreviousLine ();
193- int pcval = getPC () - 1 ; /* last instruction coded */
192+ auto linedif = line - getPreviousLine ();
193+ auto pcval = getPC () - 1 ; /* last instruction coded */
194194 if (abs (linedif) >= LIMLINEDIFF || postIncrementInstructionsWithAbs () >= MAXIWTHABS) {
195195 luaM_growvector (getLexState ()->getLuaState (), proto->getAbsLineInfoRef (), getNAbsLineInfo (),
196196 proto->getAbsLineInfoSizeRef (), AbsLineInfo, std::numeric_limits<int >::max (), " lines" );
@@ -212,8 +212,8 @@ void FuncState::savelineinfo(Proto *proto, int line) {
212212** absolute line info, too.
213213*/
214214void FuncState::removelastlineinfo () {
215- Proto *proto = getProto ();
216- int pcval = getPC () - 1 ; /* last instruction coded */
215+ auto *proto = getProto ();
216+ auto pcval = getPC () - 1 ; /* last instruction coded */
217217 if (proto->getLineInfo ()[pcval] != ABSLINEINFO) { /* relative line info? */
218218 setPreviousLine (getPreviousLine () - proto->getLineInfo ()[pcval]); /* correct last line saved */
219219 decrementInstructionsWithAbs (); /* undo previous increment */
@@ -238,7 +238,7 @@ void FuncState::removelastinstruction() {
238238** Format and emit an 'iAsBx' instruction.
239239*/
240240int FuncState::codeAsBx (OpCode o, int A, int Bc) {
241- int b = Bc + OFFSET_sBx;
241+ auto b = Bc + OFFSET_sBx;
242242 lua_assert (getOpMode (o) == OpMode::iAsBx);
243243 lua_assert (A <= MAXARG_A && b <= MAXARG_Bx);
244244 return code (CREATE_ABx (o, A, b));
@@ -261,7 +261,7 @@ int FuncState::codek(int reg, int k) {
261261 if (k <= MAXARG_Bx)
262262 return codeABx (OP_LOADK, reg, k);
263263 else {
264- int p = codeABx (OP_LOADKX, reg, 0 );
264+ auto p = codeABx (OP_LOADKX, reg, 0 );
265265 codeextraarg (k);
266266 return p;
267267 }
@@ -306,8 +306,8 @@ void FuncState::freeExpression(expdesc *e) {
306306** order.
307307*/
308308void FuncState::freeExpressions (expdesc *e1 , expdesc *e2 ) {
309- int r1 = (e1 ->getKind () == VNONRELOC) ? e1 ->getInfo () : -1 ;
310- int r2 = (e2 ->getKind () == VNONRELOC) ? e2 ->getInfo () : -1 ;
309+ auto r1 = (e1 ->getKind () == VNONRELOC) ? e1 ->getInfo () : -1 ;
310+ auto r2 = (e2 ->getKind () == VNONRELOC) ? e2 ->getInfo () : -1 ;
311311 freeRegisters (r1, r2);
312312}
313313
@@ -316,8 +316,8 @@ void FuncState::freeExpressions(expdesc *e1, expdesc *e2) {
316316*/
317317int FuncState::addk (Proto *proto, TValue *v) {
318318 lua_State *L = getLexState ()->getLuaState ();
319- int oldsize = proto->getConstantsSize ();
320- int k = getNK ();
319+ auto oldsize = proto->getConstantsSize ();
320+ auto k = getNK ();
321321 luaM_growvector (L, proto->getConstantsRef (), k, proto->getConstantsSizeRef (), TValue, MAXARG_Ax, " constants" );
322322 auto constantsSpan = proto->getConstantsSpan ();
323323 while (oldsize < static_cast <int >(constantsSpan.size ()))
@@ -339,13 +339,13 @@ int FuncState::k2proto(TValue *key, TValue *v) {
339339 Proto *proto = getProto ();
340340 LuaT tag = luaH_get (getKCache (), key, &val); /* query scanner table */
341341 if (!tagisempty (tag)) { /* is there an index there? */
342- int k = cast_int (ivalue (&val));
342+ auto k = cast_int (ivalue (&val));
343343 /* collisions can happen only for float keys */
344344 lua_assert (ttisfloat (key) || luaV_rawequalobj (&proto->getConstants ()[k], v));
345345 return k; /* reuse index */
346346 }
347347 else { /* constant not found; create a new entry */
348- int k = addk (proto, v);
348+ auto k = addk (proto, v);
349349 /* cache it for reuse; numerical value does not need GC barrier;
350350 table is not a metatable, so it does not need to invalidate cache */
351351 val.setInt (k);
@@ -398,7 +398,7 @@ int FuncState::numberK(lua_Number r) {
398398 lua_Integer ik;
399399 kv.setFloat (k); /* key as a TValue */
400400 if (!luaV_flttointeger (k, &ik, F2Imod::F2Ieq)) { /* not an integer value? */
401- int n = k2proto (&kv, &o); /* use key */
401+ auto n = k2proto (&kv, &o); /* use key */
402402 if (luaV_rawequalobj (&getProto ()->getConstants ()[n], &o)) /* correct value? */
403403 return n;
404404 }
@@ -575,7 +575,7 @@ int FuncState::code_loadbool(int A, OpCode op) {
575575*/
576576int FuncState::need_value (int list) {
577577 for (; list != NO_JUMP; list = getjump (list)) {
578- Instruction i = *getjumpcontrol (list);
578+ auto i = *getjumpcontrol (list);
579579 if (InstructionView (i).opcode () != OP_TESTSET) return 1 ;
580580 }
581581 return 0 ; /* not found */
@@ -593,16 +593,16 @@ void FuncState::exp2reg(expdesc *e, int reg) {
593593 if (e->getKind () == VJMP) /* expression itself is a test? */
594594 concat (e->getTrueListRef (), e->getInfo ()); /* put this jump in 't' list */
595595 if (hasjumps (e)) {
596- int p_f = NO_JUMP; /* position of an eventual LOAD false */
597- int p_t = NO_JUMP; /* position of an eventual LOAD true */
596+ auto p_f = NO_JUMP; /* position of an eventual LOAD false */
597+ auto p_t = NO_JUMP; /* position of an eventual LOAD true */
598598 if (need_value (e->getTrueList ()) || need_value (e->getFalseList ())) {
599- int fj = (e->getKind () == VJMP) ? NO_JUMP : jump ();
599+ auto fj = (e->getKind () == VJMP) ? NO_JUMP : jump ();
600600 p_f = code_loadbool (reg, OP_LFALSESKIP); /* skip next inst. */
601601 p_t = code_loadbool (reg, OP_LOADTRUE);
602602 /* jump around these booleans if 'e' is not a test */
603603 patchtohere (fj);
604604 }
605- int final = getlabel (); /* position after whole expression */
605+ auto final = getlabel (); /* position after whole expression */
606606 patchlistaux (e->getFalseList (), final , reg, p_f);
607607 patchlistaux (e->getTrueList (), final , reg, p_t );
608608 }
@@ -654,7 +654,7 @@ int FuncState::exp2RK(expdesc *e) {
654654}
655655
656656void FuncState::codeABRK (OpCode o, int A, int B, expdesc *ec) {
657- int k = exp2RK (ec);
657+ auto k = exp2RK (ec);
658658 codeABCk (o, A, B, ec->getInfo (), k);
659659}
660660
@@ -677,7 +677,7 @@ void FuncState::negatecondition(expdesc *e) {
677677*/
678678int FuncState::jumponcond (expdesc *e, int cond) {
679679 if (e->getKind () == VRELOC) {
680- Instruction ie = getinstruction (this , e);
680+ auto ie = getinstruction (this , e);
681681 if (InstructionView (ie).opcode () == OP_NOT) {
682682 removelastinstruction (); /* remove previous OP_NOT */
683683 return condjump (OP_TEST, InstructionView (ie).b (), 0 , 0 , !cond);
@@ -848,7 +848,7 @@ static inline TMS binopr2TM (BinOpr opr) {
848848** Expression to produce final result will be encoded in 'e'.
849849*/
850850void FuncState::codeunexpval (OpCode op, expdesc *e, int line) {
851- int r = exp2anyreg (e); /* opcodes operate only on registers */
851+ auto r = exp2anyreg (e); /* opcodes operate only on registers */
852852 freeExpression (e);
853853 e->setInfo (codeABC (op, 0 , r, 0 )); /* generate opcode */
854854 e->setKind (VRELOC); /* all those operations are relocatable */
@@ -863,8 +863,8 @@ void FuncState::codeunexpval(OpCode op, expdesc *e, int line) {
863863*/
864864void FuncState::finishbinexpval (expdesc *e1 , expdesc *e2 , OpCode op, int v2,
865865 int flip, int line, OpCode mmop, TMS event) {
866- int v1 = exp2anyreg (e1 );
867- int instrPos = codeABCk (op, 0 , v1, v2, 0 );
866+ auto v1 = exp2anyreg (e1 );
867+ auto instrPos = codeABCk (op, 0 , v1, v2, 0 );
868868 freeExpressions (e1 , e2 );
869869 e1 ->setInfo (instrPos);
870870 e1 ->setKind (VRELOC); /* all those operations are relocatable */
@@ -878,8 +878,8 @@ void FuncState::finishbinexpval(expdesc *e1, expdesc *e2, OpCode op, int v2,
878878** two registers.
879879*/
880880void FuncState::codebinexpval (BinOpr opr, expdesc *e1 , expdesc *e2 , int line) {
881- OpCode op = binopr2op (opr, BinOpr::OPR_ADD, OP_ADD);
882- int v2 = exp2anyreg (e2 ); /* make sure 'e2' is in a register */
881+ auto op = binopr2op (opr, BinOpr::OPR_ADD, OP_ADD);
882+ auto v2 = exp2anyreg (e2 ); /* make sure 'e2' is in a register */
883883 /* 'e1' must be already in a register or it is a constant */
884884 lua_assert ((VNIL <= e1 ->getKind () && e1 ->getKind () <= VKSTR) ||
885885 e1 ->getKind () == VNONRELOC || e1 ->getKind () == VRELOC);
0 commit comments