MCPcopy Create free account
hub / github.com/F-Stack/f-stack / check_conflict

Function check_conflict

freebsd/contrib/openzfs/module/lua/lparser.c:1112–1137  ·  view source on GitHub ↗

** check whether, in an assignment to an upvalue/local variable, the ** upvalue/local variable is begin used in a previous assignment to a ** table. If so, save original upvalue/local value in a safe place and ** use this safe copy in the previous assignment. */

Source from the content-addressed store, hash-verified

1110** use this safe copy in the previous assignment.
1111*/
1112static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
1113 FuncState *fs = ls->fs;
1114 int extra = fs->freereg; /* eventual position to save local variable */
1115 int conflict = 0;
1116 for (; lh; lh = lh->prev) { /* check all previous assignments */
1117 if (lh->v.k == VINDEXED) { /* assigning to a table? */
1118 /* table is the upvalue/local being assigned now? */
1119 if (lh->v.u.ind.vt == v->k && lh->v.u.ind.t == v->u.info) {
1120 conflict = 1;
1121 lh->v.u.ind.vt = VLOCAL;
1122 lh->v.u.ind.t = extra; /* previous assignment will use safe copy */
1123 }
1124 /* index is the local being assigned? (index cannot be upvalue) */
1125 if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) {
1126 conflict = 1;
1127 lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */
1128 }
1129 }
1130 }
1131 if (conflict) {
1132 /* copy upvalue/local value to a temporary (in position 'extra') */
1133 OpCode op = (v->k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;
1134 luaK_codeABC(fs, op, extra, v->u.info, 0);
1135 luaK_reserveregs(fs, 1);
1136 }
1137}
1138
1139
1140static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {

Callers 1

assignmentFunction · 0.70

Calls 2

luaK_codeABCFunction · 0.70
luaK_reserveregsFunction · 0.70

Tested by

no test coverage detected