|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
-** $Id: lcode.c,v 2.159 2018/03/07 15:55:38 roberto Exp roberto $
|
|
|
+** $Id: lcode.c,v 2.160 2018/03/16 14:22:09 roberto Exp roberto $
|
|
|
** Code generator for Lua
|
|
|
** See Copyright Notice in lua.h
|
|
|
*/
|
|
@@ -678,10 +678,6 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
|
|
|
e->k = VNONRELOC; /* becomes a non-relocatable value */
|
|
|
break;
|
|
|
}
|
|
|
- case VUNDEF: { /* not a real expression */
|
|
|
- luaK_semerror(fs->ls, "'undef' is not a value!!");
|
|
|
- break;
|
|
|
- }
|
|
|
case VUPVAL: { /* move value to some (pending) register */
|
|
|
e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0);
|
|
|
e->k = VRELOC;
|
|
@@ -1410,48 +1406,6 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-static void normalizeindexed (FuncState *fs, expdesc *v) {
|
|
|
- if (v->k != VINDEXED) { /* not in proper form? */
|
|
|
- int key = fs->freereg; /* register with key value */
|
|
|
- luaK_reserveregs(fs, 1);
|
|
|
- switch (v->k) {
|
|
|
- case VINDEXI:
|
|
|
- luaK_int(fs, key, v->u.ind.idx);
|
|
|
- break;
|
|
|
- case VINDEXSTR:
|
|
|
- luaK_codek(fs, key, v->u.ind.idx);
|
|
|
- break;
|
|
|
- case VINDEXUP:
|
|
|
- luaK_codek(fs, key, v->u.ind.idx);
|
|
|
- luaK_codeABC(fs, OP_GETUPVAL, fs->freereg, v->u.ind.t, 0);
|
|
|
- v->u.ind.t = fs->freereg;
|
|
|
- luaK_reserveregs(fs, 1); /* one more register for the upvalue */
|
|
|
- break;
|
|
|
- default:
|
|
|
- luaK_semerror(fs->ls, "'undef' is not a value!!");
|
|
|
- break;
|
|
|
- }
|
|
|
- v->u.ind.idx = key;
|
|
|
- v->k = VINDEXED;
|
|
|
- }
|
|
|
- freeregs(fs, v->u.ind.t, v->u.ind.idx);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void codeisdef (FuncState *fs, int eq, expdesc *v) {
|
|
|
- normalizeindexed(fs, v);
|
|
|
- v->u.info = luaK_codeABCk(fs, OP_ISDEF, 0, v->u.ind.t, v->u.ind.idx, eq);
|
|
|
- v->k = VRELOC;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-void luaK_codeundef (FuncState *fs, expdesc *v) {
|
|
|
- normalizeindexed(fs, v);
|
|
|
- v->u.info = luaK_codeABC(fs, OP_UNDEF, v->u.ind.t, v->u.ind.idx, 0);
|
|
|
- v->k = VRELOC;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/*
|
|
|
** Apply prefix operation 'op' to expression 'e'.
|
|
|
*/
|
|
@@ -1500,7 +1454,7 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
|
|
|
break;
|
|
|
}
|
|
|
case OPR_EQ: case OPR_NE: {
|
|
|
- if (!tonumeral(v, NULL) && fs->ls->t.token != TK_UNDEF)
|
|
|
+ if (!tonumeral(v, NULL))
|
|
|
luaK_exp2RK(fs, v);
|
|
|
/* else keep numeral, which may be an immediate operand */
|
|
|
break;
|
|
@@ -1597,10 +1551,7 @@ void luaK_posfix (FuncState *fs, BinOpr opr,
|
|
|
break;
|
|
|
}
|
|
|
case OPR_EQ: case OPR_NE: {
|
|
|
- if (e2->k == VUNDEF)
|
|
|
- codeisdef(fs, opr == OPR_NE, e1);
|
|
|
- else
|
|
|
- codeeq(fs, opr, e1, e2);
|
|
|
+ codeeq(fs, opr, e1, e2);
|
|
|
break;
|
|
|
}
|
|
|
case OPR_LT: case OPR_LE: {
|