MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / codeexpval

Function codeexpval

ThirdParty/lua/lua/lcode.c:793–821  ·  view source on GitHub ↗

** Code for binary and unary expressions that "produce values" ** (arithmetic operations, bitwise operations, concat, length). First ** try to do constant folding (only for numeric [arithmetic and ** bitwise] operations, which is what 'lua_arith' accepts). ** Expression to produce final result will be encoded in 'e1'. */

Source from the content-addressed store, hash-verified

791** Expression to produce final result will be encoded in 'e1'.
792*/
793static void codeexpval (FuncState *fs, OpCode op,
794 expdesc *e1, expdesc *e2, int line) {
795 lua_assert(op >= OP_ADD);
796 if (op <= OP_BNOT && constfolding(fs, op - OP_ADD + LUA_OPADD, e1, e2))
797 return; /* result has been folded */
798 else {
799 int o1, o2;
800 /* move operands to registers (if needed) */
801 if (op == OP_UNM || op == OP_BNOT || op == OP_LEN) { /* unary op? */
802 o2 = 0; /* no second expression */
803 o1 = luaK_exp2anyreg(fs, e1); /* cannot operate on constants */
804 }
805 else { /* regular case (binary operators) */
806 o2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */
807 o1 = luaK_exp2RK(fs, e1);
808 }
809 if (o1 > o2) { /* free registers in proper order */
810 freeexp(fs, e1);
811 freeexp(fs, e2);
812 }
813 else {
814 freeexp(fs, e2);
815 freeexp(fs, e1);
816 }
817 e1->u.info = luaK_codeABC(fs, op, 0, o1, o2); /* generate opcode */
818 e1->k = VRELOCABLE; /* all those operations are relocable */
819 luaK_fixline(fs, line);
820 }
821}
822
823
824static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,

Callers 2

luaK_prefixFunction · 0.85
luaK_posfixFunction · 0.85

Calls 6

constfoldingFunction · 0.85
luaK_exp2anyregFunction · 0.85
luaK_exp2RKFunction · 0.85
freeexpFunction · 0.85
luaK_codeABCFunction · 0.85
luaK_fixlineFunction · 0.85

Tested by

no test coverage detected