diff options
author | Lua Team <team@lua.org> | 2005-05-20 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2005-05-20 12:00:00 +0000 |
commit | bf6b5550cdfbc0c4a3a4577776ad76628d80718e (patch) | |
tree | d714ef8ac5581536c0f8bb2c8e90e2b8207799b1 /src/lcode.c | |
parent | e6ddfd3b09c0a3727afc773029c323a3defe50fa (diff) | |
download | lua-github-5.1-work6.tar.gz |
Lua 5.1-work65.1-work6
Diffstat (limited to 'src/lcode.c')
-rw-r--r-- | src/lcode.c | 31 |
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); } |