@@ -335,7 +335,7 @@ static void savelineinfo (FuncState *fs, Proto *f, int line) {
335335 }
336336 luaM_growvector (fs -> ls -> L , f -> lineinfo , pc , f -> sizelineinfo , ls_byte ,
337337 INT_MAX , "opcodes" );
338- f -> lineinfo [pc ] = linedif ;
338+ f -> lineinfo [pc ] = cast ( ls_byte , linedif ) ;
339339 fs -> previousline = line ; /* last line saved */
340340}
341341
@@ -409,7 +409,7 @@ int luaK_codevABCk (FuncState *fs, OpCode o, int A, int B, int C, int k) {
409409/*
410410** Format and emit an 'iABx' instruction.
411411*/
412- int luaK_codeABx (FuncState * fs , OpCode o , int A , unsigned int Bc ) {
412+ int luaK_codeABx (FuncState * fs , OpCode o , int A , int Bc ) {
413413 lua_assert (getOpMode (o ) == iABx );
414414 lua_assert (A <= MAXARG_A && Bc <= MAXARG_Bx );
415415 return luaK_code (fs , CREATE_ABx (o , A , Bc ));
@@ -420,7 +420,7 @@ int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bc) {
420420** Format and emit an 'iAsBx' instruction.
421421*/
422422static int codeAsBx (FuncState * fs , OpCode o , int A , int Bc ) {
423- unsigned int b = cast_uint ( Bc ) + OFFSET_sBx ;
423+ int b = Bc + OFFSET_sBx ;
424424 lua_assert (getOpMode (o ) == iAsBx );
425425 lua_assert (A <= MAXARG_A && b <= MAXARG_Bx );
426426 return luaK_code (fs , CREATE_ABx (o , A , b ));
@@ -431,7 +431,7 @@ static int codeAsBx (FuncState *fs, OpCode o, int A, int Bc) {
431431** Format and emit an 'isJ' instruction.
432432*/
433433static int codesJ (FuncState * fs , OpCode o , int sj , int k ) {
434- unsigned int j = cast_uint ( sj ) + OFFSET_sJ ;
434+ int j = sj + OFFSET_sJ ;
435435 lua_assert (getOpMode (o ) == isJ );
436436 lua_assert (j <= MAXARG_sJ && (k & ~1 ) == 0 );
437437 return luaK_code (fs , CREATE_sJ (o , j , k ));
@@ -483,7 +483,7 @@ void luaK_checkstack (FuncState *fs, int n) {
483483*/
484484void luaK_reserveregs (FuncState * fs , int n ) {
485485 luaK_checkstack (fs , n );
486- fs -> freereg += n ;
486+ fs -> freereg = cast_byte ( fs -> freereg + n ) ;
487487}
488488
489489
@@ -1290,25 +1290,25 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
12901290 if (t -> k == VUPVAL && !isKstr (fs , k )) /* upvalue indexed by non 'Kstr'? */
12911291 luaK_exp2anyreg (fs , t ); /* put it in a register */
12921292 if (t -> k == VUPVAL ) {
1293- int temp = t -> u .info ; /* upvalue index */
1293+ lu_byte temp = cast_byte ( t -> u .info ) ; /* upvalue index */
12941294 lua_assert (isKstr (fs , k ));
12951295 t -> u .ind .t = temp ; /* (can't do a direct assignment; values overlap) */
1296- t -> u .ind .idx = k -> u .info ; /* literal short string */
1296+ t -> u .ind .idx = cast ( short , k -> u .info ) ; /* literal short string */
12971297 t -> k = VINDEXUP ;
12981298 }
12991299 else {
13001300 /* register index of the table */
1301- t -> u .ind .t = ( t -> k == VLOCAL ) ? t -> u .var .ridx : t -> u .info ;
1301+ t -> u .ind .t = cast_byte (( t -> k == VLOCAL ) ? t -> u .var .ridx : t -> u .info ) ;
13021302 if (isKstr (fs , k )) {
1303- t -> u .ind .idx = k -> u .info ; /* literal short string */
1303+ t -> u .ind .idx = cast ( short , k -> u .info ) ; /* literal short string */
13041304 t -> k = VINDEXSTR ;
13051305 }
1306- else if (isCint (k )) {
1307- t -> u .ind .idx = cast_int ( k -> u .ival ); /* int. constant in proper range */
1306+ else if (isCint (k )) { /* int. constant in proper range? */
1307+ t -> u .ind .idx = cast ( short , k -> u .ival );
13081308 t -> k = VINDEXI ;
13091309 }
13101310 else {
1311- t -> u .ind .idx = luaK_exp2anyreg (fs , k ); /* register */
1311+ t -> u .ind .idx = cast ( short , luaK_exp2anyreg (fs , k ) ); /* register */
13121312 t -> k = VINDEXED ;
13131313 }
13141314 }
@@ -1623,7 +1623,7 @@ void luaK_prefix (FuncState *fs, UnOpr opr, expdesc *e, int line) {
16231623 luaK_dischargevars (fs , e );
16241624 switch (opr ) {
16251625 case OPR_MINUS : case OPR_BNOT : /* use 'ef' as fake 2nd operand */
1626- if (constfolding (fs , opr + LUA_OPUNM , e , & ef ))
1626+ if (constfolding (fs , cast_int ( opr + LUA_OPUNM ) , e , & ef ))
16271627 break ;
16281628 /* else */ /* FALLTHROUGH */
16291629 case OPR_LEN :
@@ -1711,7 +1711,7 @@ static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) {
17111711void luaK_posfix (FuncState * fs , BinOpr opr ,
17121712 expdesc * e1 , expdesc * e2 , int line ) {
17131713 luaK_dischargevars (fs , e2 );
1714- if (foldbinop (opr ) && constfolding (fs , opr + LUA_OPADD , e1 , e2 ))
1714+ if (foldbinop (opr ) && constfolding (fs , cast_int ( opr + LUA_OPADD ) , e1 , e2 ))
17151715 return ; /* done by folding */
17161716 switch (opr ) {
17171717 case OPR_AND : {
@@ -1797,11 +1797,11 @@ void luaK_fixline (FuncState *fs, int line) {
17971797
17981798void luaK_settablesize (FuncState * fs , int pc , int ra , int asize , int hsize ) {
17991799 Instruction * inst = & fs -> f -> code [pc ];
1800- int rb = (hsize != 0 ) ? luaO_ceillog2 (hsize ) + 1 : 0 ; /* hash size */
18011800 int extra = asize / (MAXARG_vC + 1 ); /* higher bits of array size */
18021801 int rc = asize % (MAXARG_vC + 1 ); /* lower bits of array size */
18031802 int k = (extra > 0 ); /* true iff needs extra argument */
1804- * inst = CREATE_vABCk (OP_NEWTABLE , ra , rb , rc , k );
1803+ hsize = (hsize != 0 ) ? luaO_ceillog2 (cast_uint (hsize )) + 1 : 0 ;
1804+ * inst = CREATE_vABCk (OP_NEWTABLE , ra , hsize , rc , k );
18051805 * (inst + 1 ) = CREATE_Ax (OP_EXTRAARG , extra );
18061806}
18071807
@@ -1825,7 +1825,7 @@ void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
18251825 luaK_codevABCk (fs , OP_SETLIST , base , tostore , nelems , 1 );
18261826 codeextraarg (fs , extra );
18271827 }
1828- fs -> freereg = base + 1 ; /* free registers with list values */
1828+ fs -> freereg = cast_byte ( base + 1 ) ; /* free registers with list values */
18291829}
18301830
18311831
0 commit comments