diff options
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 37 |
1 files changed, 19 insertions, 18 deletions
| @@ -288,8 +288,8 @@ static int floatforloop (StkId ra) { | |||
| 288 | /* | 288 | /* |
| 289 | ** Finish the table access 'val = t[key]' and return the tag of the result. | 289 | ** Finish the table access 'val = t[key]' and return the tag of the result. |
| 290 | */ | 290 | */ |
| 291 | int luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, | 291 | lu_byte luaV_finishget (lua_State *L, const TValue *t, TValue *key, |
| 292 | int tag) { | 292 | StkId val, lu_byte tag) { |
| 293 | int loop; /* counter to avoid infinite loops */ | 293 | int loop; /* counter to avoid infinite loops */ |
| 294 | const TValue *tm; /* metamethod */ | 294 | const TValue *tm; /* metamethod */ |
| 295 | for (loop = 0; loop < MAXTAGLOOP; loop++) { | 295 | for (loop = 0; loop < MAXTAGLOOP; loop++) { |
| @@ -690,7 +690,7 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { | |||
| 690 | Table *h = hvalue(rb); | 690 | Table *h = hvalue(rb); |
| 691 | tm = fasttm(L, h->metatable, TM_LEN); | 691 | tm = fasttm(L, h->metatable, TM_LEN); |
| 692 | if (tm) break; /* metamethod? break switch to call it */ | 692 | if (tm) break; /* metamethod? break switch to call it */ |
| 693 | setivalue(s2v(ra), luaH_getn(h)); /* else primitive len */ | 693 | setivalue(s2v(ra), l_castU2S(luaH_getn(h))); /* else primitive len */ |
| 694 | return; | 694 | return; |
| 695 | } | 695 | } |
| 696 | case LUA_VSHRSTR: { | 696 | case LUA_VSHRSTR: { |
| @@ -698,7 +698,7 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { | |||
| 698 | return; | 698 | return; |
| 699 | } | 699 | } |
| 700 | case LUA_VLNGSTR: { | 700 | case LUA_VLNGSTR: { |
| 701 | setivalue(s2v(ra), tsvalue(rb)->u.lnglen); | 701 | setivalue(s2v(ra), cast_st2S(tsvalue(rb)->u.lnglen)); |
| 702 | return; | 702 | return; |
| 703 | } | 703 | } |
| 704 | default: { /* try metamethod */ | 704 | default: { /* try metamethod */ |
| @@ -1255,7 +1255,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1255 | TValue *upval = cl->upvals[GETARG_B(i)]->v.p; | 1255 | TValue *upval = cl->upvals[GETARG_B(i)]->v.p; |
| 1256 | TValue *rc = KC(i); | 1256 | TValue *rc = KC(i); |
| 1257 | TString *key = tsvalue(rc); /* key must be a short string */ | 1257 | TString *key = tsvalue(rc); /* key must be a short string */ |
| 1258 | int tag; | 1258 | lu_byte tag; |
| 1259 | luaV_fastget(upval, key, s2v(ra), luaH_getshortstr, tag); | 1259 | luaV_fastget(upval, key, s2v(ra), luaH_getshortstr, tag); |
| 1260 | if (tagisempty(tag)) | 1260 | if (tagisempty(tag)) |
| 1261 | Protect(luaV_finishget(L, upval, rc, ra, tag)); | 1261 | Protect(luaV_finishget(L, upval, rc, ra, tag)); |
| @@ -1265,7 +1265,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1265 | StkId ra = RA(i); | 1265 | StkId ra = RA(i); |
| 1266 | TValue *rb = vRB(i); | 1266 | TValue *rb = vRB(i); |
| 1267 | TValue *rc = vRC(i); | 1267 | TValue *rc = vRC(i); |
| 1268 | int tag; | 1268 | lu_byte tag; |
| 1269 | if (ttisinteger(rc)) { /* fast track for integers? */ | 1269 | if (ttisinteger(rc)) { /* fast track for integers? */ |
| 1270 | luaV_fastgeti(rb, ivalue(rc), s2v(ra), tag); | 1270 | luaV_fastgeti(rb, ivalue(rc), s2v(ra), tag); |
| 1271 | } | 1271 | } |
| @@ -1279,7 +1279,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1279 | StkId ra = RA(i); | 1279 | StkId ra = RA(i); |
| 1280 | TValue *rb = vRB(i); | 1280 | TValue *rb = vRB(i); |
| 1281 | int c = GETARG_C(i); | 1281 | int c = GETARG_C(i); |
| 1282 | int tag; | 1282 | lu_byte tag; |
| 1283 | luaV_fastgeti(rb, c, s2v(ra), tag); | 1283 | luaV_fastgeti(rb, c, s2v(ra), tag); |
| 1284 | if (tagisempty(tag)) { | 1284 | if (tagisempty(tag)) { |
| 1285 | TValue key; | 1285 | TValue key; |
| @@ -1293,7 +1293,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1293 | TValue *rb = vRB(i); | 1293 | TValue *rb = vRB(i); |
| 1294 | TValue *rc = KC(i); | 1294 | TValue *rc = KC(i); |
| 1295 | TString *key = tsvalue(rc); /* key must be a short string */ | 1295 | TString *key = tsvalue(rc); /* key must be a short string */ |
| 1296 | int tag; | 1296 | lu_byte tag; |
| 1297 | luaV_fastget(rb, key, s2v(ra), luaH_getshortstr, tag); | 1297 | luaV_fastget(rb, key, s2v(ra), luaH_getshortstr, tag); |
| 1298 | if (tagisempty(tag)) | 1298 | if (tagisempty(tag)) |
| 1299 | Protect(luaV_finishget(L, rb, rc, ra, tag)); | 1299 | Protect(luaV_finishget(L, rb, rc, ra, tag)); |
| @@ -1359,14 +1359,15 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1359 | } | 1359 | } |
| 1360 | vmcase(OP_NEWTABLE) { | 1360 | vmcase(OP_NEWTABLE) { |
| 1361 | StkId ra = RA(i); | 1361 | StkId ra = RA(i); |
| 1362 | int b = GETARG_vB(i); /* log2(hash size) + 1 */ | 1362 | unsigned b = cast_uint(GETARG_vB(i)); /* log2(hash size) + 1 */ |
| 1363 | int c = GETARG_vC(i); /* array size */ | 1363 | unsigned c = cast_uint(GETARG_vC(i)); /* array size */ |
| 1364 | Table *t; | 1364 | Table *t; |
| 1365 | if (b > 0) | 1365 | if (b > 0) |
| 1366 | b = 1 << (b - 1); /* hash size is 2^(b - 1) */ | 1366 | b = 1u << (b - 1); /* hash size is 2^(b - 1) */ |
| 1367 | if (TESTARG_k(i)) { /* non-zero extra argument? */ | 1367 | if (TESTARG_k(i)) { /* non-zero extra argument? */ |
| 1368 | lua_assert(GETARG_Ax(*pc) != 0); | 1368 | lua_assert(GETARG_Ax(*pc) != 0); |
| 1369 | c += GETARG_Ax(*pc) * (MAXARG_vC + 1); /* add it to array size */ | 1369 | /* add it to array size */ |
| 1370 | c += cast_uint(GETARG_Ax(*pc)) * (MAXARG_vC + 1); | ||
| 1370 | } | 1371 | } |
| 1371 | pc++; /* skip extra argument */ | 1372 | pc++; /* skip extra argument */ |
| 1372 | L->top.p = ra + 1; /* correct top in case of emergency GC */ | 1373 | L->top.p = ra + 1; /* correct top in case of emergency GC */ |
| @@ -1379,7 +1380,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1379 | } | 1380 | } |
| 1380 | vmcase(OP_SELF) { | 1381 | vmcase(OP_SELF) { |
| 1381 | StkId ra = RA(i); | 1382 | StkId ra = RA(i); |
| 1382 | int tag; | 1383 | lu_byte tag; |
| 1383 | TValue *rb = vRB(i); | 1384 | TValue *rb = vRB(i); |
| 1384 | TValue *rc = RKC(i); | 1385 | TValue *rc = RKC(i); |
| 1385 | TString *key = tsvalue(rc); /* key must be a string */ | 1386 | TString *key = tsvalue(rc); /* key must be a string */ |
| @@ -1786,7 +1787,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1786 | if (count > 0) { /* still more iterations? */ | 1787 | if (count > 0) { /* still more iterations? */ |
| 1787 | lua_Integer step = ivalue(s2v(ra + 1)); | 1788 | lua_Integer step = ivalue(s2v(ra + 1)); |
| 1788 | lua_Integer idx = ivalue(s2v(ra + 2)); /* control variable */ | 1789 | lua_Integer idx = ivalue(s2v(ra + 2)); /* control variable */ |
| 1789 | chgivalue(s2v(ra), count - 1); /* update counter */ | 1790 | chgivalue(s2v(ra), l_castU2S(count - 1)); /* update counter */ |
| 1790 | idx = intop(+, idx, step); /* add step to index */ | 1791 | idx = intop(+, idx, step); /* add step to index */ |
| 1791 | chgivalue(s2v(ra + 2), idx); /* update control variable */ | 1792 | chgivalue(s2v(ra + 2), idx); /* update control variable */ |
| 1792 | pc -= GETARG_Bx(i); /* jump back */ | 1793 | pc -= GETARG_Bx(i); /* jump back */ |
| @@ -1851,16 +1852,16 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1851 | }} | 1852 | }} |
| 1852 | vmcase(OP_SETLIST) { | 1853 | vmcase(OP_SETLIST) { |
| 1853 | StkId ra = RA(i); | 1854 | StkId ra = RA(i); |
| 1854 | int n = GETARG_vB(i); | 1855 | unsigned n = cast_uint(GETARG_vB(i)); |
| 1855 | unsigned int last = GETARG_vC(i); | 1856 | unsigned int last = cast_uint(GETARG_vC(i)); |
| 1856 | Table *h = hvalue(s2v(ra)); | 1857 | Table *h = hvalue(s2v(ra)); |
| 1857 | if (n == 0) | 1858 | if (n == 0) |
| 1858 | n = cast_int(L->top.p - ra) - 1; /* get up to the top */ | 1859 | n = cast_uint(L->top.p - ra) - 1; /* get up to the top */ |
| 1859 | else | 1860 | else |
| 1860 | L->top.p = ci->top.p; /* correct top in case of emergency GC */ | 1861 | L->top.p = ci->top.p; /* correct top in case of emergency GC */ |
| 1861 | last += n; | 1862 | last += n; |
| 1862 | if (TESTARG_k(i)) { | 1863 | if (TESTARG_k(i)) { |
| 1863 | last += GETARG_Ax(*pc) * (MAXARG_vC + 1); | 1864 | last += cast_uint(GETARG_Ax(*pc)) * (MAXARG_vC + 1); |
| 1864 | pc++; | 1865 | pc++; |
| 1865 | } | 1866 | } |
| 1866 | /* when 'n' is known, table should have proper size */ | 1867 | /* when 'n' is known, table should have proper size */ |
