summaryrefslogtreecommitdiff
path: root/src/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lcode.c')
-rw-r--r--src/lcode.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/lcode.c b/src/lcode.c
index b40bc5a1..1e8d80fb 100644
--- a/src/lcode.c
+++ b/src/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 2.9 2005/01/10 18:17:39 roberto Exp $
+** $Id: lcode.c,v 2.12 2005/03/16 16:59:21 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -603,19 +603,32 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
- if (op == OPR_MINUS) {
- luaK_exp2val(fs, e);
- if (e->k == VK && ttisnumber(&fs->f->k[e->info]))
- e->info = luaK_numberK(fs, num_unm(nvalue(&fs->f->k[e->info])));
- else {
+ switch (op) {
+ case OPR_MINUS: {
+ luaK_exp2val(fs, e);
+ if (e->k == VK && ttisnumber(&fs->f->k[e->info]))
+ e->info = luaK_numberK(fs, luai_numunm(nvalue(&fs->f->k[e->info])));
+ else {
+ luaK_exp2anyreg(fs, e);
+ freeexp(fs, e);
+ e->info = luaK_codeABC(fs, OP_UNM, 0, e->info, 0);
+ e->k = VRELOCABLE;
+ }
+ break;
+ }
+ case OPR_NOT: {
+ codenot(fs, e);
+ break;
+ }
+ case OPR_SIZE: {
luaK_exp2anyreg(fs, e);
freeexp(fs, e);
- e->info = luaK_codeABC(fs, OP_UNM, 0, e->info, 0);
+ e->info = luaK_codeABC(fs, OP_SIZ, 0, e->info, 0);
e->k = VRELOCABLE;
+ break;
}
+ default: lua_assert(0);
}
- else /* op == NOT */
- codenot(fs, e);
}