MCPcopy Create free account
hub / github.com/Tencent/sluaunreal / codecomp

Function codecomp

Plugins/slua_unreal/External/lua/lcode.cpp:1035–1058  ·  view source on GitHub ↗

** Emit code for comparisons. ** 'e1' was already put in R/K form by 'luaK_infix'. */

Source from the content-addressed store, hash-verified

1033** 'e1' was already put in R/K form by 'luaK_infix'.
1034*/
1035static void codecomp (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
1036 int rk1 = (e1->k == VK) ? RKASK(e1->u.info)
1037 : check_exp(e1->k == VNONRELOC, e1->u.info);
1038 int rk2 = luaK_exp2RK(fs, e2);
1039 freeexps(fs, e1, e2);
1040 switch (opr) {
1041 case OPR_NE: { /* '(a ~= b)' ==> 'not (a == b)' */
1042 e1->u.info = condjump(fs, OP_EQ, 0, rk1, rk2);
1043 break;
1044 }
1045 case OPR_GT: case OPR_GE: {
1046 /* '(a > b)' ==> '(b < a)'; '(a >= b)' ==> '(b <= a)' */
1047 OpCode op = cast(OpCode, (opr - OPR_NE) + OP_EQ);
1048 e1->u.info = condjump(fs, op, 1, rk2, rk1); /* invert operands */
1049 break;
1050 }
1051 default: { /* '==', '<', '<=' use their own opcodes */
1052 OpCode op = cast(OpCode, (opr - OPR_EQ) + OP_EQ);
1053 e1->u.info = condjump(fs, op, 1, rk1, rk2);
1054 break;
1055 }
1056 }
1057 e1->k = VJMP;
1058}
1059
1060
1061/*

Callers 1

luaK_posfixFunction · 0.85

Calls 3

luaK_exp2RKFunction · 0.85
freeexpsFunction · 0.85
condjumpFunction · 0.85

Tested by

no test coverage detected