diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-08-23 14:32:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-08-23 14:32:34 -0300 |
commit | 8d9ea59d28e0a4626ce8372f6f643c30d79063aa (patch) | |
tree | 91d3bc066c1f0c0b8f4ddd31d24606b8b82519cd | |
parent | 5e7dbd0b8b397ba8fbeb0698ca051829a683a9d8 (diff) | |
download | lua-8d9ea59d28e0a4626ce8372f6f643c30d79063aa.tar.gz lua-8d9ea59d28e0a4626ce8372f6f643c30d79063aa.tar.bz2 lua-8d9ea59d28e0a4626ce8372f6f643c30d79063aa.zip |
'pushclosure' -> 'codeclosure' (as there is another 'pushclosure' in
'lvm.c) + small detail
-rw-r--r-- | lparser.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.89 2010/07/02 20:42:40 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.90 2010/07/07 16:27:29 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -352,15 +352,20 @@ static void leaveblock (FuncState *fs) { | |||
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | static void pushclosure (LexState *ls, Proto *clp, expdesc *v) { | 355 | /* |
356 | ** adds prototype being created into its parent list of prototypes | ||
357 | ** and codes instruction to create new closure | ||
358 | */ | ||
359 | static void codeclosure (LexState *ls, Proto *clp, expdesc *v) { | ||
356 | FuncState *fs = ls->fs->prev; | 360 | FuncState *fs = ls->fs->prev; |
357 | Proto *f = fs->f; /* prototype of function creating new closure */ | 361 | Proto *f = fs->f; /* prototype of function creating new closure */ |
358 | int oldsize = f->sizep; | 362 | if (fs->np >= f->sizep) { |
359 | luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, | 363 | int oldsize = f->sizep; |
360 | MAXARG_Bx, "functions"); | 364 | luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, |
361 | while (oldsize < f->sizep) f->p[oldsize++] = NULL; | 365 | MAXARG_Bx, "functions"); |
366 | while (oldsize < f->sizep) f->p[oldsize++] = NULL; | ||
367 | } | ||
362 | f->p[fs->np++] = clp; | 368 | f->p[fs->np++] = clp; |
363 | /* initial environment for new function is current lexical environment */ | ||
364 | luaC_objbarrier(ls->L, f, clp); | 369 | luaC_objbarrier(ls->L, f, clp); |
365 | init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); | 370 | init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); |
366 | } | 371 | } |
@@ -653,7 +658,7 @@ static void body (LexState *ls, expdesc *e, int needself, int line) { | |||
653 | chunk(ls); | 658 | chunk(ls); |
654 | new_fs.f->lastlinedefined = ls->linenumber; | 659 | new_fs.f->lastlinedefined = ls->linenumber; |
655 | check_match(ls, TK_END, TK_FUNCTION, line); | 660 | check_match(ls, TK_END, TK_FUNCTION, line); |
656 | pushclosure(ls, new_fs.f, e); | 661 | codeclosure(ls, new_fs.f, e); |
657 | close_func(ls); | 662 | close_func(ls); |
658 | } | 663 | } |
659 | 664 | ||