| 975 | |
| 976 | |
| 977 | static 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 | |
| 1025 | static int cond (LexState *ls) { |
no test coverage detected