MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / check_conflict

Function check_conflict

lua/lparser.c:954–974  ·  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

952** assignment.
953*/
954static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
955 FuncState *fs = ls->fs;
956 int extra = fs->freereg; /* eventual position to save local variable */
957 int conflict = 0;
958 for (; lh; lh = lh->prev) {
959 if (lh->v.k == VINDEXED) {
960 if (lh->v.u.s.info == v->u.s.info) { /* conflict? */
961 conflict = 1;
962 lh->v.u.s.info = extra; /* previous assignment will use safe copy */
963 }
964 if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */
965 conflict = 1;
966 lh->v.u.s.aux = extra; /* previous assignment will use safe copy */
967 }
968 }
969 }
970 if (conflict) {
971 luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */
972 luaK_reserveregs(fs, 1);
973 }
974}
975
976
977static 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