MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / assignment

Function assignment

third-party/lua-5.1.5/src/lparser.c:931–962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

929
930
931static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
932 expdesc e;
933 check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
934 "syntax error");
935 if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */
936 struct LHS_assign nv;
937 nv.prev = lh;
938 primaryexp(ls, &nv.v);
939 if (nv.v.k == VLOCAL)
940 check_conflict(ls, lh, &nv.v);
941 luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
942 "variables in assignment");
943 assignment(ls, &nv, nvars+1);
944 }
945 else { /* assignment -> `=' explist1 */
946 int nexps;
947 checknext(ls, '=');
948 nexps = explist1(ls, &e);
949 if (nexps != nvars) {
950 adjust_assign(ls, nvars, nexps, &e);
951 if (nexps > nvars)
952 ls->fs->freereg -= nexps - nvars; /* remove extra values */
953 }
954 else {
955 luaK_setoneret(ls->fs, &e); /* close last expression */
956 luaK_storevar(ls->fs, &lh->v, &e);
957 return; /* avoid default */
958 }
959 }
960 init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */
961 luaK_storevar(ls->fs, &lh->v, &e);
962}
963
964
965static int cond (LexState *ls) {

Callers 1

exprstatFunction · 0.70

Calls 10

luaY_checklimitFunction · 0.85
explist1Function · 0.85
testnextFunction · 0.70
primaryexpFunction · 0.70
check_conflictFunction · 0.70
checknextFunction · 0.70
adjust_assignFunction · 0.70
luaK_setoneretFunction · 0.70
luaK_storevarFunction · 0.70
init_expFunction · 0.70

Tested by

no test coverage detected