diff options
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.10 2005/03/08 20:10:05 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.11 2005/03/09 16:28:07 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -603,19 +603,32 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | |||
603 | 603 | ||
604 | 604 | ||
605 | void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { | 605 | void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { |
606 | if (op == OPR_MINUS) { | 606 | switch (op) { |
607 | luaK_exp2val(fs, e); | 607 | case OPR_MINUS: { |
608 | if (e->k == VK && ttisnumber(&fs->f->k[e->info])) | 608 | luaK_exp2val(fs, e); |
609 | e->info = luaK_numberK(fs, luai_numunm(nvalue(&fs->f->k[e->info]))); | 609 | if (e->k == VK && ttisnumber(&fs->f->k[e->info])) |
610 | else { | 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: { | ||
611 | luaK_exp2anyreg(fs, e); | 624 | luaK_exp2anyreg(fs, e); |
612 | freeexp(fs, e); | 625 | 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); |
614 | e->k = VRELOCABLE; | 627 | e->k = VRELOCABLE; |
628 | break; | ||
615 | } | 629 | } |
630 | default: lua_assert(0); | ||
616 | } | 631 | } |
617 | else /* op == NOT */ | ||
618 | codenot(fs, e); | ||
619 | } | 632 | } |
620 | 633 | ||
621 | 634 | ||