MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / assignment

Function assignment

lua/lparser.c:977–1022  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

975
976
977static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
978 expdesc e;
979 check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
980 "syntax error");
981 if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */
982 struct LHS_assign nv;
983 nv.prev = lh;
984 primaryexp(ls, &nv.v);
985 if (nv.v.k == VLOCAL)
986 check_conflict(ls, lh, &nv.v);
987 luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
988 "variables in assignment");
989 assignment(ls, &nv, nvars+1);
990 /* COMDB2 MODIFICATION */
991 } else if (testnext(ls, TK_CAST)) { /* assignment -> `:=' primaryexp assignment */
992 int nexps;
993 nexps = explist1(ls, &e);
994 if (nexps != nvars) {
995 adjust_assign(ls, nvars, nexps, &e);
996 if (nexps > nvars)
997 ls->fs->freereg -= nexps - nvars; /* remove extra values */
998 }
999 else {
1000 expdesc e1 = lh->v;
1001 codearith(ls->fs, OP_CAST, &e1, &e);
1002 luaK_storevar(ls->fs, &lh->v, &e1);
1003 return;
1004 }
1005 } else { /* assignment -> `=' explist1 */
1006 int nexps;
1007 checknext(ls, '=');
1008 nexps = explist1(ls, &e);
1009 if (nexps != nvars) {
1010 adjust_assign(ls, nvars, nexps, &e);
1011 if (nexps > nvars)
1012 ls->fs->freereg -= nexps - nvars; /* remove extra values */
1013 }
1014 else {
1015 luaK_setoneret(ls->fs, &e); /* close last expression */
1016 luaK_storevar(ls->fs, &lh->v, &e);
1017 return; /* avoid default */
1018 }
1019 }
1020 init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */
1021 luaK_storevar(ls->fs, &lh->v, &e);
1022}
1023
1024
1025static int cond (LexState *ls) {

Callers 1

exprstatFunction · 0.85

Calls 10

testnextFunction · 0.85
primaryexpFunction · 0.85
check_conflictFunction · 0.85
explist1Function · 0.85
adjust_assignFunction · 0.85
codearithFunction · 0.85
luaK_storevarFunction · 0.85
checknextFunction · 0.85
luaK_setoneretFunction · 0.85
init_expFunction · 0.85

Tested by

no test coverage detected