MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / restassign

Function restassign

extlibs/lua/src/lparser.c:1356–1384  ·  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

1354** restassign -> ',' suffixedexp restassign | '=' explist
1355*/
1356static 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
1387static 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