** Parse and compile a multiple assignment. The first "variable" ** (a 'suffixedexp') was already read by the caller. ** ** assignment -> suffixedexp restassign ** restassign -> ',' suffixedexp restassign | '=' explist */
| 1373 | ** restassign -> ',' suffixedexp restassign | '=' explist |
| 1374 | */ |
| 1375 | static void restassign (LexState *ls, struct LHS_assign *lh, int nvars) { |
| 1376 | expdesc e; |
| 1377 | check_condition(ls, vkisvar(lh->v.k), "syntax error"); |
| 1378 | check_readonly(ls, &lh->v); |
| 1379 | if (testnext(ls, ',')) { /* restassign -> ',' suffixedexp restassign */ |
| 1380 | struct LHS_assign nv; |
| 1381 | nv.prev = lh; |
| 1382 | suffixedexp(ls, &nv.v); |
| 1383 | if (!vkisindexed(nv.v.k)) |
| 1384 | check_conflict(ls, lh, &nv.v); |
| 1385 | enterlevel(ls); /* control recursion depth */ |
| 1386 | restassign(ls, &nv, nvars+1); |
| 1387 | leavelevel(ls); |
| 1388 | } |
| 1389 | else { /* restassign -> '=' explist */ |
| 1390 | int nexps; |
| 1391 | checknext(ls, '='); |
| 1392 | nexps = explist(ls, &e); |
| 1393 | if (nexps != nvars) |
| 1394 | adjust_assign(ls, nvars, nexps, &e); |
| 1395 | else { |
| 1396 | luaK_setoneret(ls->fs, &e); /* close last expression */ |
| 1397 | luaK_storevar(ls->fs, &lh->v, &e); |
| 1398 | return; /* avoid default */ |
| 1399 | } |
| 1400 | } |
| 1401 | init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ |
| 1402 | luaK_storevar(ls->fs, &lh->v, &e); |
| 1403 | } |
| 1404 | |
| 1405 | |
| 1406 | static int cond (LexState *ls) { |
no test coverage detected