| 882 | |
| 883 | |
| 884 | void luaK_posfix (FuncState *fs, BinOpr op, |
| 885 | expdesc *e1, expdesc *e2, int line) { |
| 886 | switch (op) { |
| 887 | case OPR_AND: { |
| 888 | lua_assert(e1->t == NO_JUMP); /* list must be closed */ |
| 889 | luaK_dischargevars(fs, e2); |
| 890 | luaK_concat(fs, &e2->f, e1->f); |
| 891 | *e1 = *e2; |
| 892 | break; |
| 893 | } |
| 894 | case OPR_OR: { |
| 895 | lua_assert(e1->f == NO_JUMP); /* list must be closed */ |
| 896 | luaK_dischargevars(fs, e2); |
| 897 | luaK_concat(fs, &e2->t, e1->t); |
| 898 | *e1 = *e2; |
| 899 | break; |
| 900 | } |
| 901 | case OPR_CONCAT: { |
| 902 | luaK_exp2val(fs, e2); |
| 903 | if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { |
| 904 | lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1); |
| 905 | freeexp(fs, e1); |
| 906 | SETARG_B(getcode(fs, e2), e1->u.info); |
| 907 | e1->k = VRELOCABLE; e1->u.info = e2->u.info; |
| 908 | } |
| 909 | else { |
| 910 | luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ |
| 911 | codeexpval(fs, OP_CONCAT, e1, e2, line); |
| 912 | } |
| 913 | break; |
| 914 | } |
| 915 | case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: |
| 916 | case OPR_IDIV: case OPR_MOD: case OPR_POW: |
| 917 | case OPR_BAND: case OPR_BOR: case OPR_BXOR: |
| 918 | case OPR_SHL: case OPR_SHR: { |
| 919 | codeexpval(fs, cast(OpCode, (op - OPR_ADD) + OP_ADD), e1, e2, line); |
| 920 | break; |
| 921 | } |
| 922 | case OPR_EQ: case OPR_LT: case OPR_LE: { |
| 923 | codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2); |
| 924 | break; |
| 925 | } |
| 926 | case OPR_NE: case OPR_GT: case OPR_GE: { |
| 927 | codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2); |
| 928 | break; |
| 929 | } |
| 930 | default: lua_assert(0); |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | |
| 935 | void luaK_fixline (FuncState *fs, int line) { |
no test coverage detected