** Finalize code for binary operation, after reading 2nd operand. ** For '(a .. b .. c)' (which is '(a .. (b .. c))', because ** concatenation is right associative), merge second CONCAT into first ** one. */
| 1129 | ** one. |
| 1130 | */ |
| 1131 | void luaK_posfix (FuncState *fs, BinOpr op, |
| 1132 | expdesc *e1, expdesc *e2, int line) { |
| 1133 | switch (op) { |
| 1134 | case OPR_AND: { |
| 1135 | lua_assert(e1->t == NO_JUMP); /* list closed by 'luK_infix' */ |
| 1136 | luaK_dischargevars(fs, e2); |
| 1137 | luaK_concat(fs, &e2->f, e1->f); |
| 1138 | *e1 = *e2; |
| 1139 | break; |
| 1140 | } |
| 1141 | case OPR_OR: { |
| 1142 | lua_assert(e1->f == NO_JUMP); /* list closed by 'luK_infix' */ |
| 1143 | luaK_dischargevars(fs, e2); |
| 1144 | luaK_concat(fs, &e2->t, e1->t); |
| 1145 | *e1 = *e2; |
| 1146 | break; |
| 1147 | } |
| 1148 | case OPR_CONCAT: { |
| 1149 | luaK_exp2val(fs, e2); |
| 1150 | if (e2->k == VRELOCABLE && |
| 1151 | GET_OPCODE(getinstruction(fs, e2)) == OP_CONCAT) { |
| 1152 | lua_assert(e1->u.info == GETARG_B(getinstruction(fs, e2))-1); |
| 1153 | freeexp(fs, e1); |
| 1154 | SETARG_B(getinstruction(fs, e2), e1->u.info); |
| 1155 | e1->k = VRELOCABLE; e1->u.info = e2->u.info; |
| 1156 | } |
| 1157 | else { |
| 1158 | luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ |
| 1159 | codebinexpval(fs, OP_CONCAT, e1, e2, line); |
| 1160 | } |
| 1161 | break; |
| 1162 | } |
| 1163 | case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: |
| 1164 | case OPR_IDIV: case OPR_MOD: case OPR_POW: |
| 1165 | case OPR_BAND: case OPR_BOR: case OPR_BXOR: |
| 1166 | case OPR_SHL: case OPR_SHR: { |
| 1167 | if (!constfolding(fs, op + LUA_OPADD, e1, e2)) |
| 1168 | codebinexpval(fs, cast(OpCode, op + OP_ADD), e1, e2, line); |
| 1169 | break; |
| 1170 | } |
| 1171 | case OPR_EQ: case OPR_LT: case OPR_LE: |
| 1172 | case OPR_NE: case OPR_GT: case OPR_GE: { |
| 1173 | codecomp(fs, op, e1, e2); |
| 1174 | break; |
| 1175 | } |
| 1176 | default: lua_assert(0); |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | |
| 1181 | /* |
no test coverage detected