diff options
Diffstat (limited to 'src/lj_parse.c')
-rw-r--r-- | src/lj_parse.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lj_parse.c b/src/lj_parse.c index e1ca2ff7..522f8ef8 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c | |||
@@ -116,7 +116,7 @@ typedef struct FuncState { | |||
116 | BCPos bclim; /* Limit of bytecode stack. */ | 116 | BCPos bclim; /* Limit of bytecode stack. */ |
117 | MSize vbase; /* Base of variable stack for this function. */ | 117 | MSize vbase; /* Base of variable stack for this function. */ |
118 | uint8_t flags; /* Prototype flags. */ | 118 | uint8_t flags; /* Prototype flags. */ |
119 | uint8_t numparams; /* Number of active local variables. */ | 119 | uint8_t numparams; /* Number of parameters. */ |
120 | uint8_t framesize; /* Fixed frame size. */ | 120 | uint8_t framesize; /* Fixed frame size. */ |
121 | uint8_t nuv; /* Number of upvalues */ | 121 | uint8_t nuv; /* Number of upvalues */ |
122 | VarIndex varmap[LJ_MAX_LOCVAR]; /* Map from register to variable idx. */ | 122 | VarIndex varmap[LJ_MAX_LOCVAR]; /* Map from register to variable idx. */ |
@@ -1397,10 +1397,8 @@ static BCReg parse_params(LexState *ls, int needself) | |||
1397 | FuncState *fs = ls->fs; | 1397 | FuncState *fs = ls->fs; |
1398 | BCReg nparams = 0; | 1398 | BCReg nparams = 0; |
1399 | lex_check(ls, '('); | 1399 | lex_check(ls, '('); |
1400 | if (needself) { | 1400 | if (needself) |
1401 | var_new_lit(ls, 0, "self"); | 1401 | var_new_lit(ls, nparams++, "self"); |
1402 | var_add(ls, 1); | ||
1403 | } | ||
1404 | if (ls->token != ')') { | 1402 | if (ls->token != ')') { |
1405 | do { | 1403 | do { |
1406 | if (ls->token == TK_name) { | 1404 | if (ls->token == TK_name) { |
@@ -1415,9 +1413,10 @@ static BCReg parse_params(LexState *ls, int needself) | |||
1415 | } while (lex_opt(ls, ',')); | 1413 | } while (lex_opt(ls, ',')); |
1416 | } | 1414 | } |
1417 | var_add(ls, nparams); | 1415 | var_add(ls, nparams); |
1418 | bcreg_reserve(fs, fs->nactvar); | 1416 | lua_assert(fs->nactvar == nparams); |
1417 | bcreg_reserve(fs, nparams); | ||
1419 | lex_check(ls, ')'); | 1418 | lex_check(ls, ')'); |
1420 | return fs->nactvar; | 1419 | return nparams; |
1421 | } | 1420 | } |
1422 | 1421 | ||
1423 | /* Forward declaration. */ | 1422 | /* Forward declaration. */ |
@@ -1577,7 +1576,7 @@ static void expr_simple(LexState *ls, ExpDesc *v) | |||
1577 | checkcond(ls, fs->flags & PROTO_IS_VARARG, LJ_ERR_XDOTS); | 1576 | checkcond(ls, fs->flags & PROTO_IS_VARARG, LJ_ERR_XDOTS); |
1578 | bcreg_reserve(fs, 1); | 1577 | bcreg_reserve(fs, 1); |
1579 | base = fs->freereg-1; | 1578 | base = fs->freereg-1; |
1580 | expr_init(v, VCALL, bcemit_ABC(fs, BC_VARG, base, 2, 1)); | 1579 | expr_init(v, VCALL, bcemit_ABC(fs, BC_VARG, base, 2, fs->numparams)); |
1581 | v->u.s.aux = base; | 1580 | v->u.s.aux = base; |
1582 | break; | 1581 | break; |
1583 | } | 1582 | } |