diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-08 21:19:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-08 21:19:22 -0300 |
commit | 88b306f495fa7034c708c6b75a355a6deee51c58 (patch) | |
tree | 7d8faaacd1f5c753ed9e77f0e2c8e27b9a002635 /lcode.c | |
parent | 563de491be90601f23a735aede89ea9a3ef86ee9 (diff) | |
download | lua-88b306f495fa7034c708c6b75a355a6deee51c58.tar.gz lua-88b306f495fa7034c708c6b75a355a6deee51c58.tar.bz2 lua-88b306f495fa7034c708c6b75a355a6deee51c58.zip |
some optimizations
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -88,6 +88,16 @@ static void luaK_sub (LexState *ls) { | |||
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | static void luaK_conc (LexState *ls) { | ||
92 | Instruction *previous = previous_instruction(ls); | ||
93 | luaK_deltastack(ls, -1); | ||
94 | switch(GET_OPCODE(*previous)) { | ||
95 | case CONCOP: *previous = SETARG_U(*previous, GETARG_U(*previous)+1); break; | ||
96 | default: luaK_primitivecode(ls, CREATE_U(CONCOP, 2)); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | |||
91 | void luaK_retcode (LexState *ls, int nlocals, int nexps) { | 101 | void luaK_retcode (LexState *ls, int nlocals, int nexps) { |
92 | Instruction *previous = previous_instruction(ls); | 102 | Instruction *previous = previous_instruction(ls); |
93 | if (nexps > 0 && GET_OPCODE(*previous) == CALL) { | 103 | if (nexps > 0 && GET_OPCODE(*previous) == CALL) { |
@@ -286,7 +296,7 @@ void luaK_posfix (LexState *ls, int op, expdesc *v1, expdesc *v2) { | |||
286 | case '*': luaK_0(ls, MULTOP, -1); break; | 296 | case '*': luaK_0(ls, MULTOP, -1); break; |
287 | case '/': luaK_0(ls, DIVOP, -1); break; | 297 | case '/': luaK_0(ls, DIVOP, -1); break; |
288 | case '^': luaK_0(ls, POWOP, -1); break; | 298 | case '^': luaK_0(ls, POWOP, -1); break; |
289 | case CONC: luaK_0(ls, CONCOP, -1); break; | 299 | case CONC: luaK_conc(ls); break; |
290 | case EQ: luaK_0(ls, EQOP, -1); break; | 300 | case EQ: luaK_0(ls, EQOP, -1); break; |
291 | case NE: luaK_0(ls, NEQOP, -1); break; | 301 | case NE: luaK_0(ls, NEQOP, -1); break; |
292 | case '>': luaK_0(ls, GTOP, -1); break; | 302 | case '>': luaK_0(ls, GTOP, -1); break; |