MCPcopy Create free account
hub / github.com/Cubitect/cubiomes-viewer / codeeq

Function codeeq

lua/src/lcode.c:1540–1565  ·  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

1538** 'e1' was already put as RK by 'luaK_infix'.
1539*/
1540static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
1541 int r1, r2;
1542 int im;
1543 int isfloat = 0; /* not needed here, but kept for symmetry */
1544 OpCode op;
1545 if (e1->k != VNONRELOC) {
1546 lua_assert(e1->k == VK || e1->k == VKINT || e1->k == VKFLT);
1547 swapexps(e1, e2);
1548 }
1549 r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */
1550 if (isSCnumber(e2, &im, &isfloat)) {
1551 op = OP_EQI;
1552 r2 = im; /* immediate operand */
1553 }
1554 else if (luaK_exp2RK(fs, e2)) { /* 1st expression is constant? */
1555 op = OP_EQK;
1556 r2 = e2->u.info; /* constant index */
1557 }
1558 else {
1559 op = OP_EQ; /* will compare two registers */
1560 r2 = luaK_exp2anyreg(fs, e2);
1561 }
1562 freeexps(fs, e1, e2);
1563 e1->u.info = condjump(fs, op, r1, r2, isfloat, (opr == OPR_EQ));
1564 e1->k = VJMP;
1565}
1566
1567
1568/*

Callers 1

luaK_posfixFunction · 0.85

Calls 6

swapexpsFunction · 0.85
luaK_exp2anyregFunction · 0.85
isSCnumberFunction · 0.85
luaK_exp2RKFunction · 0.85
freeexpsFunction · 0.85
condjumpFunction · 0.85

Tested by

no test coverage detected