MCPcopy Create free account
hub / github.com/DFHack/dfhack / assignment

Function assignment

depends/lua/src/lparser.c:1148–1175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1146
1147
1148static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
1149 expdesc e;
1150 check_condition(ls, vkisvar(lh->v.k), "syntax error");
1151 if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */
1152 struct LHS_assign nv;
1153 nv.prev = lh;
1154 suffixedexp(ls, &nv.v);
1155 if (nv.v.k != VINDEXED)
1156 check_conflict(ls, lh, &nv.v);
1157 checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS,
1158 "C levels");
1159 assignment(ls, &nv, nvars+1);
1160 }
1161 else { /* assignment -> '=' explist */
1162 int nexps;
1163 checknext(ls, '=');
1164 nexps = explist(ls, &e);
1165 if (nexps != nvars)
1166 adjust_assign(ls, nvars, nexps, &e);
1167 else {
1168 luaK_setoneret(ls->fs, &e); /* close last expression */
1169 luaK_storevar(ls->fs, &lh->v, &e);
1170 return; /* avoid default */
1171 }
1172 }
1173 init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */
1174 luaK_storevar(ls->fs, &lh->v, &e);
1175}
1176
1177
1178static int cond (LexState *ls) {

Callers 1

exprstatFunction · 0.85

Calls 10

testnextFunction · 0.85
suffixedexpFunction · 0.85
check_conflictFunction · 0.85
checklimitFunction · 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