@@ -415,7 +415,7 @@ int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
415
415
/*
416
416
** Format and emit an 'iAsBx' instruction.
417
417
*/
418
- int luaK_codeAsBx (FuncState * fs , OpCode o , int a , int bc ) {
418
+ static int codeAsBx (FuncState * fs , OpCode o , int a , int bc ) {
419
419
unsigned int b = bc + OFFSET_sBx ;
420
420
lua_assert (getOpMode (o ) == iAsBx );
421
421
lua_assert (a <= MAXARG_A && b <= MAXARG_Bx );
@@ -671,7 +671,7 @@ static int fitsBx (lua_Integer i) {
671
671
672
672
void luaK_int (FuncState * fs , int reg , lua_Integer i ) {
673
673
if (fitsBx (i ))
674
- luaK_codeAsBx (fs , OP_LOADI , reg , cast_int (i ));
674
+ codeAsBx (fs , OP_LOADI , reg , cast_int (i ));
675
675
else
676
676
luaK_codek (fs , reg , luaK_intK (fs , i ));
677
677
}
@@ -680,7 +680,7 @@ void luaK_int (FuncState *fs, int reg, lua_Integer i) {
680
680
static void luaK_float (FuncState * fs , int reg , lua_Number f ) {
681
681
lua_Integer fi ;
682
682
if (luaV_flttointeger (f , & fi , F2Ieq ) && fitsBx (fi ))
683
- luaK_codeAsBx (fs , OP_LOADF , reg , cast_int (fi ));
683
+ codeAsBx (fs , OP_LOADF , reg , cast_int (fi ));
684
684
else
685
685
luaK_codek (fs , reg , luaK_numberK (fs , f ));
686
686
}
@@ -776,7 +776,8 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
776
776
break ;
777
777
}
778
778
case VLOCAL : { /* already in a register */
779
- e -> u .info = e -> u .var .ridx ;
779
+ int temp = e -> u .var .ridx ;
780
+ e -> u .info = temp ; /* (can't do a direct assignment; values overlap) */
780
781
e -> k = VNONRELOC ; /* becomes a non-relocatable value */
781
782
break ;
782
783
}
@@ -1025,7 +1026,7 @@ static int luaK_exp2K (FuncState *fs, expdesc *e) {
1025
1026
** in the range of R/K indices).
1026
1027
** Returns 1 iff expression is K.
1027
1028
*/
1028
- int luaK_exp2RK (FuncState * fs , expdesc * e ) {
1029
+ static int exp2RK (FuncState * fs , expdesc * e ) {
1029
1030
if (luaK_exp2K (fs , e ))
1030
1031
return 1 ;
1031
1032
else { /* not a constant in the right range: put it in a register */
@@ -1037,7 +1038,7 @@ int luaK_exp2RK (FuncState *fs, expdesc *e) {
1037
1038
1038
1039
static void codeABRK (FuncState * fs , OpCode o , int a , int b ,
1039
1040
expdesc * ec ) {
1040
- int k = luaK_exp2RK (fs , ec );
1041
+ int k = exp2RK (fs , ec );
1041
1042
luaK_codeABCk (fs , o , a , b , ec -> u .info , k );
1042
1043
}
1043
1044
@@ -1215,7 +1216,7 @@ static void codenot (FuncState *fs, expdesc *e) {
1215
1216
1216
1217
1217
1218
/*
1218
- ** Check whether expression 'e' is a small literal string
1219
+ ** Check whether expression 'e' is a short literal string
1219
1220
*/
1220
1221
static int isKstr (FuncState * fs , expdesc * e ) {
1221
1222
return (e -> k == VK && !hasjumps (e ) && e -> u .info <= MAXARG_B &&
@@ -1225,7 +1226,7 @@ static int isKstr (FuncState *fs, expdesc *e) {
1225
1226
/*
1226
1227
** Check whether expression 'e' is a literal integer.
1227
1228
*/
1228
- int luaK_isKint (expdesc * e ) {
1229
+ static int isKint (expdesc * e ) {
1229
1230
return (e -> k == VKINT && !hasjumps (e ));
1230
1231
}
1231
1232
@@ -1235,7 +1236,7 @@ int luaK_isKint (expdesc *e) {
1235
1236
** proper range to fit in register C
1236
1237
*/
1237
1238
static int isCint (expdesc * e ) {
1238
- return luaK_isKint (e ) && (l_castS2U (e -> u .ival ) <= l_castS2U (MAXARG_C ));
1239
+ return isKint (e ) && (l_castS2U (e -> u .ival ) <= l_castS2U (MAXARG_C ));
1239
1240
}
1240
1241
1241
1242
@@ -1244,7 +1245,7 @@ static int isCint (expdesc *e) {
1244
1245
** proper range to fit in register sC
1245
1246
*/
1246
1247
static int isSCint (expdesc * e ) {
1247
- return luaK_isKint (e ) && fitsC (e -> u .ival );
1248
+ return isKint (e ) && fitsC (e -> u .ival );
1248
1249
}
1249
1250
1250
1251
@@ -1283,15 +1284,17 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
1283
1284
if (t -> k == VUPVAL && !isKstr (fs , k )) /* upvalue indexed by non 'Kstr'? */
1284
1285
luaK_exp2anyreg (fs , t ); /* put it in a register */
1285
1286
if (t -> k == VUPVAL ) {
1286
- t -> u .ind .t = t -> u .info ; /* upvalue index */
1287
- t -> u .ind .idx = k -> u .info ; /* literal string */
1287
+ int temp = t -> u .info ; /* upvalue index */
1288
+ lua_assert (isKstr (fs , k ));
1289
+ t -> u .ind .t = temp ; /* (can't do a direct assignment; values overlap) */
1290
+ t -> u .ind .idx = k -> u .info ; /* literal short string */
1288
1291
t -> k = VINDEXUP ;
1289
1292
}
1290
1293
else {
1291
1294
/* register index of the table */
1292
1295
t -> u .ind .t = (t -> k == VLOCAL ) ? t -> u .var .ridx : t -> u .info ;
1293
1296
if (isKstr (fs , k )) {
1294
- t -> u .ind .idx = k -> u .info ; /* literal string */
1297
+ t -> u .ind .idx = k -> u .info ; /* literal short string */
1295
1298
t -> k = VINDEXSTR ;
1296
1299
}
1297
1300
else if (isCint (k )) {
@@ -1459,7 +1462,7 @@ static void codebinK (FuncState *fs, BinOpr opr,
1459
1462
*/
1460
1463
static int finishbinexpneg (FuncState * fs , expdesc * e1 , expdesc * e2 ,
1461
1464
OpCode op , int line , TMS event ) {
1462
- if (!luaK_isKint (e2 ))
1465
+ if (!isKint (e2 ))
1463
1466
return 0 ; /* not an integer constant */
1464
1467
else {
1465
1468
lua_Integer i2 = e2 -> u .ival ;
@@ -1592,7 +1595,7 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
1592
1595
op = OP_EQI ;
1593
1596
r2 = im ; /* immediate operand */
1594
1597
}
1595
- else if (luaK_exp2RK (fs , e2 )) { /* 2nd expression is constant? */
1598
+ else if (exp2RK (fs , e2 )) { /* 2nd expression is constant? */
1596
1599
op = OP_EQK ;
1597
1600
r2 = e2 -> u .info ; /* constant index */
1598
1601
}
@@ -1658,7 +1661,7 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
1658
1661
}
1659
1662
case OPR_EQ : case OPR_NE : {
1660
1663
if (!tonumeral (v , NULL ))
1661
- luaK_exp2RK (fs , v );
1664
+ exp2RK (fs , v );
1662
1665
/* else keep numeral, which may be an immediate operand */
1663
1666
break ;
1664
1667
}
0 commit comments