aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/lcode.c b/lcode.c
index 0799306e..47e5424e 100644
--- a/lcode.c
+++ b/lcode.c
@@ -335,7 +335,7 @@ static void savelineinfo (FuncState *fs, Proto *f, int line) {
335 } 335 }
336 luaM_growvector(fs->ls->L, f->lineinfo, pc, f->sizelineinfo, ls_byte, 336 luaM_growvector(fs->ls->L, f->lineinfo, pc, f->sizelineinfo, ls_byte,
337 INT_MAX, "opcodes"); 337 INT_MAX, "opcodes");
338 f->lineinfo[pc] = linedif; 338 f->lineinfo[pc] = cast(ls_byte, linedif);
339 fs->previousline = line; /* last line saved */ 339 fs->previousline = line; /* last line saved */
340} 340}
341 341
@@ -409,7 +409,7 @@ int luaK_codevABCk (FuncState *fs, OpCode o, int A, int B, int C, int k) {
409/* 409/*
410** Format and emit an 'iABx' instruction. 410** Format and emit an 'iABx' instruction.
411*/ 411*/
412int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bc) { 412int luaK_codeABx (FuncState *fs, OpCode o, int A, int Bc) {
413 lua_assert(getOpMode(o) == iABx); 413 lua_assert(getOpMode(o) == iABx);
414 lua_assert(A <= MAXARG_A && Bc <= MAXARG_Bx); 414 lua_assert(A <= MAXARG_A && Bc <= MAXARG_Bx);
415 return luaK_code(fs, CREATE_ABx(o, A, Bc)); 415 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) {
420** Format and emit an 'iAsBx' instruction. 420** Format and emit an 'iAsBx' instruction.
421*/ 421*/
422static int codeAsBx (FuncState *fs, OpCode o, int A, int Bc) { 422static 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;
424 lua_assert(getOpMode(o) == iAsBx); 424 lua_assert(getOpMode(o) == iAsBx);
425 lua_assert(A <= MAXARG_A && b <= MAXARG_Bx); 425 lua_assert(A <= MAXARG_A && b <= MAXARG_Bx);
426 return luaK_code(fs, CREATE_ABx(o, A, b)); 426 return luaK_code(fs, CREATE_ABx(o, A, b));
@@ -431,7 +431,7 @@ static int codeAsBx (FuncState *fs, OpCode o, int A, int Bc) {
431** Format and emit an 'isJ' instruction. 431** Format and emit an 'isJ' instruction.
432*/ 432*/
433static int codesJ (FuncState *fs, OpCode o, int sj, int k) { 433static 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;
435 lua_assert(getOpMode(o) == isJ); 435 lua_assert(getOpMode(o) == isJ);
436 lua_assert(j <= MAXARG_sJ && (k & ~1) == 0); 436 lua_assert(j <= MAXARG_sJ && (k & ~1) == 0);
437 return luaK_code(fs, CREATE_sJ(o, j, k)); 437 return luaK_code(fs, CREATE_sJ(o, j, k));
@@ -483,7 +483,7 @@ void luaK_checkstack (FuncState *fs, int n) {
483*/ 483*/
484void luaK_reserveregs (FuncState *fs, int n) { 484void luaK_reserveregs (FuncState *fs, int n) {
485 luaK_checkstack(fs, n); 485 luaK_checkstack(fs, n);
486 fs->freereg += n; 486 fs->freereg = cast_byte(fs->freereg + n);
487} 487}
488 488
489 489
@@ -1290,25 +1290,25 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
1290 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ 1290 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */
1291 luaK_exp2anyreg(fs, t); /* put it in a register */ 1291 luaK_exp2anyreg(fs, t); /* put it in a register */
1292 if (t->k == VUPVAL) { 1292 if (t->k == VUPVAL) {
1293 int temp = t->u.info; /* upvalue index */ 1293 lu_byte temp = cast_byte(t->u.info); /* upvalue index */
1294 lua_assert(isKstr(fs, k)); 1294 lua_assert(isKstr(fs, k));
1295 t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */ 1295 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 */
1297 t->k = VINDEXUP; 1297 t->k = VINDEXUP;
1298 } 1298 }
1299 else { 1299 else {
1300 /* register index of the table */ 1300 /* 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);
1302 if (isKstr(fs, k)) { 1302 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 */
1304 t->k = VINDEXSTR; 1304 t->k = VINDEXSTR;
1305 } 1305 }
1306 else if (isCint(k)) { 1306 else if (isCint(k)) { /* int. constant in proper range? */
1307 t->u.ind.idx = cast_int(k->u.ival); /* int. constant in proper range */ 1307 t->u.ind.idx = cast(short, k->u.ival);
1308 t->k = VINDEXI; 1308 t->k = VINDEXI;
1309 } 1309 }
1310 else { 1310 else {
1311 t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */ 1311 t->u.ind.idx = cast(short, luaK_exp2anyreg(fs, k)); /* register */
1312 t->k = VINDEXED; 1312 t->k = VINDEXED;
1313 } 1313 }
1314 } 1314 }
@@ -1623,7 +1623,7 @@ void luaK_prefix (FuncState *fs, UnOpr opr, expdesc *e, int line) {
1623 luaK_dischargevars(fs, e); 1623 luaK_dischargevars(fs, e);
1624 switch (opr) { 1624 switch (opr) {
1625 case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */ 1625 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))
1627 break; 1627 break;
1628 /* else */ /* FALLTHROUGH */ 1628 /* else */ /* FALLTHROUGH */
1629 case OPR_LEN: 1629 case OPR_LEN:
@@ -1711,7 +1711,7 @@ static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) {
1711void luaK_posfix (FuncState *fs, BinOpr opr, 1711void luaK_posfix (FuncState *fs, BinOpr opr,
1712 expdesc *e1, expdesc *e2, int line) { 1712 expdesc *e1, expdesc *e2, int line) {
1713 luaK_dischargevars(fs, e2); 1713 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))
1715 return; /* done by folding */ 1715 return; /* done by folding */
1716 switch (opr) { 1716 switch (opr) {
1717 case OPR_AND: { 1717 case OPR_AND: {
@@ -1797,11 +1797,11 @@ void luaK_fixline (FuncState *fs, int line) {
1797 1797
1798void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize) { 1798void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize) {
1799 Instruction *inst = &fs->f->code[pc]; 1799 Instruction *inst = &fs->f->code[pc];
1800 int rb = (hsize != 0) ? luaO_ceillog2(hsize) + 1 : 0; /* hash size */
1801 int extra = asize / (MAXARG_vC + 1); /* higher bits of array size */ 1800 int extra = asize / (MAXARG_vC + 1); /* higher bits of array size */
1802 int rc = asize % (MAXARG_vC + 1); /* lower bits of array size */ 1801 int rc = asize % (MAXARG_vC + 1); /* lower bits of array size */
1803 int k = (extra > 0); /* true iff needs extra argument */ 1802 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);
1805 *(inst + 1) = CREATE_Ax(OP_EXTRAARG, extra); 1805 *(inst + 1) = CREATE_Ax(OP_EXTRAARG, extra);
1806} 1806}
1807 1807
@@ -1825,7 +1825,7 @@ void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
1825 luaK_codevABCk(fs, OP_SETLIST, base, tostore, nelems, 1); 1825 luaK_codevABCk(fs, OP_SETLIST, base, tostore, nelems, 1);
1826 codeextraarg(fs, extra); 1826 codeextraarg(fs, extra);
1827 } 1827 }
1828 fs->freereg = base + 1; /* free registers with list values */ 1828 fs->freereg = cast_byte(base + 1); /* free registers with list values */
1829} 1829}
1830 1830
1831 1831