aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/lvm.c b/lvm.c
index 78e39b71..a251f423 100644
--- a/lvm.c
+++ b/lvm.c
@@ -287,12 +287,13 @@ static int floatforloop (StkId ra) {
287/* 287/*
288** Finish the table access 'val = t[key]'. 288** Finish the table access 'val = t[key]'.
289*/ 289*/
290void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, 290void luaV_finishget_ (lua_State *L, const TValue *t, TValue *key, StkId val,
291 int hres) { 291 int tag) {
292 int loop; /* counter to avoid infinite loops */ 292 int loop; /* counter to avoid infinite loops */
293 const TValue *tm; /* metamethod */ 293 const TValue *tm; /* metamethod */
294 TValue aux;
294 for (loop = 0; loop < MAXTAGLOOP; loop++) { 295 for (loop = 0; loop < MAXTAGLOOP; loop++) {
295 if (hres == HNOTATABLE) { /* 't' is not a table? */ 296 if (tag == LUA_VNOTABLE) { /* 't' is not a table? */
296 lua_assert(!ttistable(t)); 297 lua_assert(!ttistable(t));
297 tm = luaT_gettmbyobj(L, t, TM_INDEX); 298 tm = luaT_gettmbyobj(L, t, TM_INDEX);
298 if (l_unlikely(notm(tm))) 299 if (l_unlikely(notm(tm)))
@@ -312,10 +313,11 @@ void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val,
312 return; 313 return;
313 } 314 }
314 t = tm; /* else try to access 'tm[key]' */ 315 t = tm; /* else try to access 'tm[key]' */
315 luaV_fastget(t, key, s2v(val), luaH_get, hres); 316 luaV_fastget(t, key, s2v(val), luaH_get, aux);
316 if (hres == HOK) 317 if (!isemptyV(aux))
317 return; /* done */ 318 return; /* done */
318 /* else repeat (tail call 'luaV_finishget') */ 319 /* else repeat (tail call 'luaV_finishget') */
320 tag = ttypetagV(aux);
319 } 321 }
320 luaG_runerror(L, "'__index' chain too long; possible loop"); 322 luaG_runerror(L, "'__index' chain too long; possible loop");
321} 323}
@@ -1245,36 +1247,36 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1245 TValue *upval = cl->upvals[GETARG_B(i)]->v.p; 1247 TValue *upval = cl->upvals[GETARG_B(i)]->v.p;
1246 TValue *rc = KC(i); 1248 TValue *rc = KC(i);
1247 TString *key = tsvalue(rc); /* key must be a short string */ 1249 TString *key = tsvalue(rc); /* key must be a short string */
1248 int hres; 1250 TValue aux;
1249 luaV_fastget(upval, key, s2v(ra), luaH_getshortstr, hres); 1251 luaV_fastget(upval, key, s2v(ra), luaH_getshortstr, aux);
1250 if (hres != HOK) 1252 if (isemptyV(aux))
1251 Protect(luaV_finishget(L, upval, rc, ra, hres)); 1253 Protect(luaV_finishget(L, upval, rc, ra, aux));
1252 vmbreak; 1254 vmbreak;
1253 } 1255 }
1254 vmcase(OP_GETTABLE) { 1256 vmcase(OP_GETTABLE) {
1255 StkId ra = RA(i); 1257 StkId ra = RA(i);
1256 TValue *rb = vRB(i); 1258 TValue *rb = vRB(i);
1257 TValue *rc = vRC(i); 1259 TValue *rc = vRC(i);
1258 int hres; 1260 TValue aux;
1259 if (ttisinteger(rc)) { /* fast track for integers? */ 1261 if (ttisinteger(rc)) { /* fast track for integers? */
1260 luaV_fastgeti(rb, ivalue(rc), s2v(ra), hres); 1262 luaV_fastgeti(rb, ivalue(rc), s2v(ra), aux);
1261 } 1263 }
1262 else 1264 else
1263 luaV_fastget(rb, rc, s2v(ra), luaH_get, hres); 1265 luaV_fastget(rb, rc, s2v(ra), luaH_get, aux);
1264 if (hres != HOK) /* fast track for integers? */ 1266 if (isemptyV(aux)) /* fast track for integers? */
1265 Protect(luaV_finishget(L, rb, rc, ra, hres)); 1267 Protect(luaV_finishget(L, rb, rc, ra, aux));
1266 vmbreak; 1268 vmbreak;
1267 } 1269 }
1268 vmcase(OP_GETI) { 1270 vmcase(OP_GETI) {
1269 StkId ra = RA(i); 1271 StkId ra = RA(i);
1270 TValue *rb = vRB(i); 1272 TValue *rb = vRB(i);
1271 int c = GETARG_C(i); 1273 int c = GETARG_C(i);
1272 int hres; 1274 TValue aux;
1273 luaV_fastgeti(rb, c, s2v(ra), hres); 1275 luaV_fastgeti(rb, c, s2v(ra), aux);
1274 if (hres != HOK) { 1276 if (isemptyV(aux)) {
1275 TValue key; 1277 TValue key;
1276 setivalue(&key, c); 1278 setivalue(&key, c);
1277 Protect(luaV_finishget(L, rb, &key, ra, hres)); 1279 Protect(luaV_finishget(L, rb, &key, ra, aux));
1278 } 1280 }
1279 vmbreak; 1281 vmbreak;
1280 } 1282 }
@@ -1283,10 +1285,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1283 TValue *rb = vRB(i); 1285 TValue *rb = vRB(i);
1284 TValue *rc = KC(i); 1286 TValue *rc = KC(i);
1285 TString *key = tsvalue(rc); /* key must be a short string */ 1287 TString *key = tsvalue(rc); /* key must be a short string */
1286 int hres; 1288 TValue aux;
1287 luaV_fastget(rb, key, s2v(ra), luaH_getshortstr, hres); 1289 luaV_fastget(rb, key, s2v(ra), luaH_getshortstr, aux);
1288 if (hres != HOK) 1290 if (isemptyV(aux))
1289 Protect(luaV_finishget(L, rb, rc, ra, hres)); 1291 Protect(luaV_finishget(L, rb, rc, ra, aux));
1290 vmbreak; 1292 vmbreak;
1291 } 1293 }
1292 vmcase(OP_SETTABUP) { 1294 vmcase(OP_SETTABUP) {
@@ -1368,14 +1370,14 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1368 } 1370 }
1369 vmcase(OP_SELF) { 1371 vmcase(OP_SELF) {
1370 StkId ra = RA(i); 1372 StkId ra = RA(i);
1371 int hres; 1373 TValue aux;
1372 TValue *rb = vRB(i); 1374 TValue *rb = vRB(i);
1373 TValue *rc = RKC(i); 1375 TValue *rc = RKC(i);
1374 TString *key = tsvalue(rc); /* key must be a string */ 1376 TString *key = tsvalue(rc); /* key must be a string */
1375 setobj2s(L, ra + 1, rb); 1377 setobj2s(L, ra + 1, rb);
1376 luaV_fastget(rb, key, s2v(ra), luaH_getstr, hres); 1378 luaV_fastget(rb, key, s2v(ra), luaH_getstr, aux);
1377 if (hres != HOK) 1379 if (isemptyV(aux))
1378 Protect(luaV_finishget(L, rb, rc, ra, hres)); 1380 Protect(luaV_finishget(L, rb, rc, ra, aux));
1379 vmbreak; 1381 vmbreak;
1380 } 1382 }
1381 vmcase(OP_ADDI) { 1383 vmcase(OP_ADDI) {