diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-10-04 16:01:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-10-04 16:01:53 -0300 |
commit | 5ee87acd6b920a6a122277cd817aea4cfd618671 (patch) | |
tree | 5e931c1db32c2be6378fde498ffcc5ee9dec0d6a /lparser.c | |
parent | 5d834bdf571ef3ee343b21fde2d49de1e4ea08b4 (diff) | |
download | lua-5ee87acd6b920a6a122277cd817aea4cfd618671.tar.gz lua-5ee87acd6b920a6a122277cd817aea4cfd618671.tar.bz2 lua-5ee87acd6b920a6a122277cd817aea4cfd618671.zip |
small optimization for boolean constants + new format for SETLIST opcode
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.4 2004/04/30 20:13:38 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.5 2004/05/31 18:51:50 roberto Exp $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -475,9 +475,8 @@ static void closelistfield (FuncState *fs, struct ConsControl *cc) { | |||
475 | luaK_exp2nextreg(fs, &cc->v); | 475 | luaK_exp2nextreg(fs, &cc->v); |
476 | cc->v.k = VVOID; | 476 | cc->v.k = VVOID; |
477 | if (cc->tostore == LFIELDS_PER_FLUSH) { | 477 | if (cc->tostore == LFIELDS_PER_FLUSH) { |
478 | luaK_codeABx(fs, OP_SETLIST, cc->t->info, cc->na-1); /* flush */ | 478 | luaK_setlist(fs, cc->t->info, cc->na, cc->tostore); /* flush */ |
479 | cc->tostore = 0; /* no more items pending */ | 479 | cc->tostore = 0; /* no more items pending */ |
480 | fs->freereg = cc->t->info + 1; /* free registers */ | ||
481 | } | 480 | } |
482 | } | 481 | } |
483 | 482 | ||
@@ -486,15 +485,14 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) { | |||
486 | if (cc->tostore == 0) return; | 485 | if (cc->tostore == 0) return; |
487 | if (hasmultret(cc->v.k)) { | 486 | if (hasmultret(cc->v.k)) { |
488 | luaK_setmultret(fs, &cc->v); | 487 | luaK_setmultret(fs, &cc->v); |
489 | luaK_codeABx(fs, OP_SETLISTO, cc->t->info, cc->na-1); | 488 | luaK_setlist(fs, cc->t->info, cc->na, LUA_MULTRET); |
490 | cc->na--; /* do not count last expression (unknown number of elements) */ | 489 | cc->na--; /* do not count last expression (unknown number of elements) */ |
491 | } | 490 | } |
492 | else { | 491 | else { |
493 | if (cc->v.k != VVOID) | 492 | if (cc->v.k != VVOID) |
494 | luaK_exp2nextreg(fs, &cc->v); | 493 | luaK_exp2nextreg(fs, &cc->v); |
495 | luaK_codeABx(fs, OP_SETLIST, cc->t->info, cc->na-1); | 494 | luaK_setlist(fs, cc->t->info, cc->na, cc->tostore); |
496 | } | 495 | } |
497 | fs->freereg = cc->t->info + 1; /* free registers */ | ||
498 | } | 496 | } |
499 | 497 | ||
500 | 498 | ||