** Parse and compile a multiple assignment. The first "variable" ** (a 'suffixedexp') was already read by the caller. ** ** assignment -> suffixedexp restassign ** restassign -> ',' suffixedexp restassign | '=' explist */
| 1354 | ** restassign -> ',' suffixedexp restassign | '=' explist |
| 1355 | */ |
| 1356 | static void restassign (LexState *ls, struct LHS_assign *lh, int nvars) { |
| 1357 | expdesc e; |
| 1358 | check_condition(ls, vkisvar(lh->v.k), "syntax error"); |
| 1359 | check_readonly(ls, &lh->v); |
| 1360 | if (testnext(ls, ',')) { /* restassign -> ',' suffixedexp restassign */ |
| 1361 | struct LHS_assign nv; |
| 1362 | nv.prev = lh; |
| 1363 | suffixedexp(ls, &nv.v); |
| 1364 | if (!vkisindexed(nv.v.k)) |
| 1365 | check_conflict(ls, lh, &nv.v); |
| 1366 | enterlevel(ls); /* control recursion depth */ |
| 1367 | restassign(ls, &nv, nvars+1); |
| 1368 | leavelevel(ls); |
| 1369 | } |
| 1370 | else { /* restassign -> '=' explist */ |
| 1371 | int nexps; |
| 1372 | checknext(ls, '='); |
| 1373 | nexps = explist(ls, &e); |
| 1374 | if (nexps != nvars) |
| 1375 | adjust_assign(ls, nvars, nexps, &e); |
| 1376 | else { |
| 1377 | luaK_setoneret(ls->fs, &e); /* close last expression */ |
| 1378 | luaK_storevar(ls->fs, &lh->v, &e); |
| 1379 | return; /* avoid default */ |
| 1380 | } |
| 1381 | } |
| 1382 | init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ |
| 1383 | luaK_storevar(ls->fs, &lh->v, &e); |
| 1384 | } |
| 1385 | |
| 1386 | |
| 1387 | static int cond (LexState *ls) { |
no test coverage detected