History

Lua 5.1-work6

Lua Team committed 21 years ago

Commit b5301731 parent e684a4d66 files · +1742 −1346Browse files

Showing the changes to src/lcode.c (1 of 66 files). Show all

Unified · Split

src/lcode.c+22−9
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lcode.c,v 2.9 2005/01/10 18:17:39 roberto Exp $
2+** $Id: lcode.c,v 2.12 2005/03/16 16:59:21 roberto Exp $
33 ** Code generator for Lua
44 ** See Copyright Notice in lua.h
55 */
@@ -603,19 +603,32 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { · 597 unmodified lines
603603
604604
605605 void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
606− if (op == OPR_MINUS) {
607− luaK_exp2val(fs, e);
608− if (e->k == VK && ttisnumber(&fs->f->k[e->info]))
609− e->info = luaK_numberK(fs, num_unm(nvalue(&fs->f->k[e->info])));
610− else {
606+ switch (op) {
607+ case OPR_MINUS: {
608+ luaK_exp2val(fs, e);
609+ if (e->k == VK && ttisnumber(&fs->f->k[e->info]))
610+ e->info = luaK_numberK(fs, luai_numunm(nvalue(&fs->f->k[e->info])));
611+ else {
612+ luaK_exp2anyreg(fs, e);
613+ freeexp(fs, e);
614+ e->info = luaK_codeABC(fs, OP_UNM, 0, e->info, 0);
615+ e->k = VRELOCABLE;
616+ }
617+ break;
618+ }
619+ case OPR_NOT: {
620+ codenot(fs, e);
621+ break;
622+ }
623+ case OPR_SIZE: {
611624 luaK_exp2anyreg(fs, e);
612625 freeexp(fs, e);
613− e->info = luaK_codeABC(fs, OP_UNM, 0, e->info, 0);
626+ e->info = luaK_codeABC(fs, OP_SIZ, 0, e->info, 0);
614627 e->k = VRELOCABLE;
628+ break;
615629 }
630+ default: lua_assert(0);
616631 }
617− else /* op == NOT */
618− codenot(fs, e);
619632 }
620633
621634