More concise
This commit is contained in:
parent
377a9c10f0
commit
5a8e653cd5
|
@ -689,7 +689,7 @@ static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
|
||||||
static void codeunaryarith (FuncState *fs, OpCode op, expdesc *e) {
|
static void codeunaryarith (FuncState *fs, OpCode op, expdesc *e) {
|
||||||
expdesc e2;
|
expdesc e2;
|
||||||
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
||||||
if (!isnumeral(e))
|
if (op == OP_LEN || !isnumeral(e))
|
||||||
luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
|
luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
|
||||||
codearith(fs, op, e, &e2);
|
codearith(fs, op, e, &e2);
|
||||||
}
|
}
|
||||||
|
@ -712,17 +712,11 @@ static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
|
||||||
|
|
||||||
|
|
||||||
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
|
||||||
expdesc e2;
|
|
||||||
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OPR_MINUS: codeunaryarith(fs, OP_UNM, e); break;
|
case OPR_MINUS: codeunaryarith(fs, OP_UNM, e); break;
|
||||||
case OPR_BNOT: codeunaryarith(fs, OP_BNOT, e); break;
|
case OPR_BNOT: codeunaryarith(fs, OP_BNOT, e); break;
|
||||||
case OPR_NOT: codenot(fs, e); break;
|
case OPR_NOT: codenot(fs, e); break;
|
||||||
case OPR_LEN: {
|
case OPR_LEN: codeunaryarith(fs, OP_LEN, e); break;
|
||||||
luaK_exp2anyreg(fs, e); /* cannot operate on constants */
|
|
||||||
codearith(fs, OP_LEN, e, &e2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: lua_assert(0);
|
default: lua_assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue