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

Function check_conflict

third-party/lua-5.3.5/src/lparser.c:1119–1144  ·  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

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