MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / codecomp

Function codecomp

libraries/AP_Scripting/lua/src/lcode.c:1044–1067  ·  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

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

Callers 1

luaK_posfixFunction · 0.85

Calls 3

luaK_exp2RKFunction · 0.85
freeexpsFunction · 0.85
condjumpFunction · 0.85

Tested by

no test coverage detected