MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / codeeq

Function codeeq

lib/lua/src/lcode.c:1584–1609  ·  view source on GitHub ↗

** Emit code for equality comparisons ('==', '~='). ** 'e1' was already put as RK by 'luaK_infix'. */

Source from the content-addressed store, hash-verified

1582** 'e1' was already put as RK by 'luaK_infix'.
1583*/
1584static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
1585 int r1, r2;
1586 int im;
1587 int isfloat = 0; /* not needed here, but kept for symmetry */
1588 OpCode op;
1589 if (e1->k != VNONRELOC) {
1590 lua_assert(e1->k == VK || e1->k == VKINT || e1->k == VKFLT);
1591 swapexps(e1, e2);
1592 }
1593 r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */
1594 if (isSCnumber(e2, &im, &isfloat)) {
1595 op = OP_EQI;
1596 r2 = im; /* immediate operand */
1597 }
1598 else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */
1599 op = OP_EQK;
1600 r2 = e2->u.info; /* constant index */
1601 }
1602 else {
1603 op = OP_EQ; /* will compare two registers */
1604 r2 = luaK_exp2anyreg(fs, e2);
1605 }
1606 freeexps(fs, e1, e2);
1607 e1->u.info = condjump(fs, op, r1, r2, isfloat, (opr == OPR_EQ));
1608 e1->k = VJMP;
1609}
1610
1611
1612/*

Callers 1

luaK_posfixFunction · 0.85

Calls 6

swapexpsFunction · 0.85
luaK_exp2anyregFunction · 0.85
isSCnumberFunction · 0.85
exp2RKFunction · 0.85
freeexpsFunction · 0.85
condjumpFunction · 0.85

Tested by

no test coverage detected