diff options
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 12 |
1 files changed, 7 insertions, 5 deletions
| @@ -806,7 +806,7 @@ void luaK_setoneret (FuncState *fs, expdesc *e) { | |||
| 806 | ** Change a vararg parameter into a regular local variable | 806 | ** Change a vararg parameter into a regular local variable |
| 807 | */ | 807 | */ |
| 808 | void luaK_vapar2local (FuncState *fs, expdesc *var) { | 808 | void luaK_vapar2local (FuncState *fs, expdesc *var) { |
| 809 | fs->f->flag |= PF_VATAB; /* function will need a vararg table */ | 809 | needvatab(fs->f); /* function will need a vararg table */ |
| 810 | /* now a vararg parameter is equivalent to a regular local variable */ | 810 | /* now a vararg parameter is equivalent to a regular local variable */ |
| 811 | var->k = VLOCAL; | 811 | var->k = VLOCAL; |
| 812 | } | 812 | } |
| @@ -1127,7 +1127,7 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { | |||
| 1127 | break; | 1127 | break; |
| 1128 | } | 1128 | } |
| 1129 | case VVARGIND: { | 1129 | case VVARGIND: { |
| 1130 | fs->f->flag |= PF_VATAB; /* function will need a vararg table */ | 1130 | needvatab(fs->f); /* function will need a vararg table */ |
| 1131 | /* now, assignment is to a regular table */ | 1131 | /* now, assignment is to a regular table */ |
| 1132 | } /* FALLTHROUGH */ | 1132 | } /* FALLTHROUGH */ |
| 1133 | case VINDEXED: { | 1133 | case VINDEXED: { |
| @@ -1927,6 +1927,8 @@ static int finaltarget (Instruction *code, int i) { | |||
| 1927 | void luaK_finish (FuncState *fs) { | 1927 | void luaK_finish (FuncState *fs) { |
| 1928 | int i; | 1928 | int i; |
| 1929 | Proto *p = fs->f; | 1929 | Proto *p = fs->f; |
| 1930 | if (p->flag & PF_VATAB) /* will it use a vararg table? */ | ||
| 1931 | p->flag &= cast_byte(~PF_VAHID); /* then it will not use hidden args. */ | ||
| 1930 | for (i = 0; i < fs->pc; i++) { | 1932 | for (i = 0; i < fs->pc; i++) { |
| 1931 | Instruction *pc = &p->code[i]; | 1933 | Instruction *pc = &p->code[i]; |
| 1932 | /* avoid "not used" warnings when assert is off (for 'onelua.c') */ | 1934 | /* avoid "not used" warnings when assert is off (for 'onelua.c') */ |
| @@ -1934,7 +1936,7 @@ void luaK_finish (FuncState *fs) { | |||
| 1934 | lua_assert(i == 0 || luaP_isOT(*(pc - 1)) == luaP_isIT(*pc)); | 1936 | lua_assert(i == 0 || luaP_isOT(*(pc - 1)) == luaP_isIT(*pc)); |
| 1935 | switch (GET_OPCODE(*pc)) { | 1937 | switch (GET_OPCODE(*pc)) { |
| 1936 | case OP_RETURN0: case OP_RETURN1: { | 1938 | case OP_RETURN0: case OP_RETURN1: { |
| 1937 | if (!(fs->needclose || (p->flag & PF_ISVARARG))) | 1939 | if (!(fs->needclose || (p->flag & PF_VAHID))) |
| 1938 | break; /* no extra work */ | 1940 | break; /* no extra work */ |
| 1939 | /* else use OP_RETURN to do the extra work */ | 1941 | /* else use OP_RETURN to do the extra work */ |
| 1940 | SET_OPCODE(*pc, OP_RETURN); | 1942 | SET_OPCODE(*pc, OP_RETURN); |
| @@ -1942,8 +1944,8 @@ void luaK_finish (FuncState *fs) { | |||
| 1942 | case OP_RETURN: case OP_TAILCALL: { | 1944 | case OP_RETURN: case OP_TAILCALL: { |
| 1943 | if (fs->needclose) | 1945 | if (fs->needclose) |
| 1944 | SETARG_k(*pc, 1); /* signal that it needs to close */ | 1946 | SETARG_k(*pc, 1); /* signal that it needs to close */ |
| 1945 | if (p->flag & PF_ISVARARG) | 1947 | if (p->flag & PF_VAHID) /* does it use hidden arguments? */ |
| 1946 | SETARG_C(*pc, p->numparams + 1); /* signal that it is vararg */ | 1948 | SETARG_C(*pc, p->numparams + 1); /* signal that */ |
| 1947 | break; | 1949 | break; |
| 1948 | } | 1950 | } |
| 1949 | case OP_GETVARG: { | 1951 | case OP_GETVARG: { |
