MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / check_conflict

Function check_conflict

Source/Misc/lua/src/lua.c:8484–8504  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

8482** assignment.
8483*/
8484static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
8485FuncState *fs = ls->fs;
8486int extra = fs->freereg; /* eventual position to save local variable */
8487int conflict = 0;
8488for (; lh; lh = lh->prev) {
8489if (lh->v.k == VINDEXED) {
8490if (lh->v.u.s.info == v->u.s.info) { /* conflict? */
8491conflict = 1;
8492lh->v.u.s.info = extra; /* previous assignment will use safe copy */
8493}
8494if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */
8495conflict = 1;
8496lh->v.u.s.aux = extra; /* previous assignment will use safe copy */
8497}
8498}
8499}
8500if (conflict) {
8501luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */
8502luaK_reserveregs(fs, 1);
8503}
8504}
8505
8506
8507static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {

Callers 1

assignmentFunction · 0.85

Calls 2

luaK_codeABCFunction · 0.85
luaK_reserveregsFunction · 0.85

Tested by

no test coverage detected