MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / restassign

Function restassign

lib/lua/src/lparser.c:1375–1403  ·  view source on GitHub ↗

** Parse and compile a multiple assignment. The first "variable" ** (a 'suffixedexp') was already read by the caller. ** ** assignment -> suffixedexp restassign ** restassign -> ',' suffixedexp restassign | '=' explist */

Source from the content-addressed store, hash-verified

1373** restassign -> ',' suffixedexp restassign | '=' explist
1374*/
1375static 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
1406static int cond (LexState *ls) {

Callers 1

exprstatFunction · 0.85

Calls 10

check_readonlyFunction · 0.85
testnextFunction · 0.85
suffixedexpFunction · 0.85
check_conflictFunction · 0.85
checknextFunction · 0.85
explistFunction · 0.85
adjust_assignFunction · 0.85
luaK_setoneretFunction · 0.85
luaK_storevarFunction · 0.85
init_expFunction · 0.85

Tested by

no test coverage detected