diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-22 12:16:46 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-22 12:16:46 -0200 |
| commit | 4676f6599e04d4eaa78c050616e94994e6a36396 (patch) | |
| tree | 94ef87b23d9008bee2fd34df7703c77181b4d655 /lcode.c | |
| parent | 1d5b885437286a307a77b5d12756d73d374efd54 (diff) | |
| download | lua-4676f6599e04d4eaa78c050616e94994e6a36396.tar.gz lua-4676f6599e04d4eaa78c050616e94994e6a36396.tar.bz2 lua-4676f6599e04d4eaa78c050616e94994e6a36396.zip | |
new macros 'isOT'/'isIT'
(plus exchanged parameters of OP_VARARG to make it similar to other
'isOT' instructions)
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 14 |
1 files changed, 7 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 2.145 2017/12/15 18:53:48 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.146 2017/12/18 15:44:44 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 | */ |
| @@ -618,12 +618,11 @@ static void luaK_float (FuncState *fs, int reg, lua_Number f) { | |||
| 618 | ** or 'nresults' is LUA_MULTRET (as any expression can satisfy that). | 618 | ** or 'nresults' is LUA_MULTRET (as any expression can satisfy that). |
| 619 | */ | 619 | */ |
| 620 | void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { | 620 | void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { |
| 621 | if (e->k == VCALL) { /* expression is an open function call? */ | 621 | Instruction *pc = &getinstruction(fs, e); |
| 622 | SETARG_C(getinstruction(fs, e), nresults + 1); | 622 | if (e->k == VCALL) /* expression is an open function call? */ |
| 623 | } | 623 | SETARG_C(*pc, nresults + 1); |
| 624 | else if (e->k == VVARARG) { | 624 | else if (e->k == VVARARG) { |
| 625 | Instruction *pc = &getinstruction(fs, e); | 625 | SETARG_C(*pc, nresults + 1); |
| 626 | SETARG_B(*pc, nresults + 1); | ||
| 627 | SETARG_A(*pc, fs->freereg); | 626 | SETARG_A(*pc, fs->freereg); |
| 628 | luaK_reserveregs(fs, 1); | 627 | luaK_reserveregs(fs, 1); |
| 629 | } | 628 | } |
| @@ -649,7 +648,7 @@ void luaK_setoneret (FuncState *fs, expdesc *e) { | |||
| 649 | e->u.info = GETARG_A(getinstruction(fs, e)); | 648 | e->u.info = GETARG_A(getinstruction(fs, e)); |
| 650 | } | 649 | } |
| 651 | else if (e->k == VVARARG) { | 650 | else if (e->k == VVARARG) { |
| 652 | SETARG_B(getinstruction(fs, e), 2); | 651 | SETARG_C(getinstruction(fs, e), 2); |
| 653 | e->k = VRELOC; /* can relocate its simple result */ | 652 | e->k = VRELOC; /* can relocate its simple result */ |
| 654 | } | 653 | } |
| 655 | } | 654 | } |
| @@ -1623,6 +1622,7 @@ void luaK_finish (FuncState *fs) { | |||
| 1623 | Proto *p = fs->f; | 1622 | Proto *p = fs->f; |
| 1624 | for (i = 0; i < fs->pc; i++) { | 1623 | for (i = 0; i < fs->pc; i++) { |
| 1625 | Instruction *pc = &p->code[i]; | 1624 | Instruction *pc = &p->code[i]; |
| 1625 | lua_assert(isOT(*pc) == isIT(*(pc + 1))); | ||
| 1626 | switch (GET_OPCODE(*pc)) { | 1626 | switch (GET_OPCODE(*pc)) { |
| 1627 | case OP_RETURN: case OP_RETURN0: case OP_RETURN1: | 1627 | case OP_RETURN: case OP_RETURN0: case OP_RETURN1: |
| 1628 | case OP_TAILCALL: { | 1628 | case OP_TAILCALL: { |
