diff options
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.72 2001/06/08 12:29:27 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.73 2001/06/08 19:00:57 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 | */ |
@@ -69,8 +69,8 @@ int luaK_jump (FuncState *fs) { | |||
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | static int luaK_condjump (FuncState *fs, OpCode op, int B, int C) { | 72 | static int luaK_condjump (FuncState *fs, OpCode op, int A, int B, int C) { |
73 | luaK_codeABC(fs, op, NO_REG, B, C); | 73 | luaK_codeABC(fs, op, A, B, C); |
74 | return luaK_codeAsBc(fs, OP_CJMP, 0, NO_JUMP); | 74 | return luaK_codeAsBc(fs, OP_CJMP, 0, NO_JUMP); |
75 | } | 75 | } |
76 | 76 | ||
@@ -261,12 +261,11 @@ static int number_constant (FuncState *fs, lua_Number r) { | |||
261 | 261 | ||
262 | void luaK_setcallreturns (FuncState *fs, expdesc *e, int nresults) { | 262 | void luaK_setcallreturns (FuncState *fs, expdesc *e, int nresults) { |
263 | if (e->k == VCALL) { /* expression is an open function call? */ | 263 | if (e->k == VCALL) { /* expression is an open function call? */ |
264 | int a = GETARG_A(getcode(fs, e)); | 264 | if (nresults == LUA_MULTRET) nresults = NO_REG; |
265 | int c = (nresults == LUA_MULTRET) ? NO_REG : a + nresults; | 265 | SETARG_C(getcode(fs, e), nresults); |
266 | SETARG_C(getcode(fs, e), c); | ||
267 | if (nresults == 1) { /* `regular' expression? */ | 266 | if (nresults == 1) { /* `regular' expression? */ |
268 | e->k = VNONRELOC; | 267 | e->k = VNONRELOC; |
269 | e->u.i.info = a; | 268 | e->u.i.info = GETARG_A(getcode(fs, e)); |
270 | } | 269 | } |
271 | } | 270 | } |
272 | } | 271 | } |
@@ -499,13 +498,13 @@ static int jumponcond (FuncState *fs, expdesc *e, OpCode op) { | |||
499 | if (GET_OPCODE(ie) == OP_NOT) { | 498 | if (GET_OPCODE(ie) == OP_NOT) { |
500 | op = invertoperator(op); | 499 | op = invertoperator(op); |
501 | fs->pc--; /* remove previous OP_NOT */ | 500 | fs->pc--; /* remove previous OP_NOT */ |
502 | return luaK_condjump(fs, op, GETARG_B(ie), 0); | 501 | return luaK_condjump(fs, op, NO_REG, GETARG_B(ie), 0); |
503 | } | 502 | } |
504 | /* else go through */ | 503 | /* else go through */ |
505 | } | 504 | } |
506 | discharge2anyreg(fs, e); | 505 | discharge2anyreg(fs, e); |
507 | freeexp(fs, e); | 506 | freeexp(fs, e); |
508 | return luaK_condjump(fs, op, e->u.i.info, 0); | 507 | return luaK_condjump(fs, op, NO_REG, e->u.i.info, 0); |
509 | } | 508 | } |
510 | 509 | ||
511 | 510 | ||
@@ -748,7 +747,7 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { | |||
748 | e1->k = VRELOCABLE; | 747 | e1->k = VRELOCABLE; |
749 | } | 748 | } |
750 | else { /* jump */ | 749 | else { /* jump */ |
751 | e1->u.i.info = luaK_condjump(fs, opc, o1, o2); | 750 | e1->u.i.info = luaK_condjump(fs, opc, o1, 0, o2); |
752 | e1->k = VJMP; | 751 | e1->k = VJMP; |
753 | } | 752 | } |
754 | } | 753 | } |