diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-21 15:31:28 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-21 15:31:28 -0200 |
commit | cfdebfbc5361ee9779f39e076afef7c7474fb3de (patch) | |
tree | 300cd787208c016dbf5998fd89a4384d6fb2bba7 /lparser.c | |
parent | d61d5bef9d13bb9ed184edd08f2dabd7c4399b7a (diff) | |
download | lua-cfdebfbc5361ee9779f39e076afef7c7474fb3de.tar.gz lua-cfdebfbc5361ee9779f39e076afef7c7474fb3de.tar.bz2 lua-cfdebfbc5361ee9779f39e076afef7c7474fb3de.zip |
debug information for parameters use line 0 for them (as they are
always visible).
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 27 |
1 files changed, 12 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.46 1999/12/07 11:36:16 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.47 1999/12/14 18:42:57 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -333,23 +333,21 @@ static void store_localvar (LexState *ls, TaggedString *name, int n) { | |||
333 | FuncState *fs = ls->fs; | 333 | FuncState *fs = ls->fs; |
334 | checklimit(ls, fs->nlocalvar+n+1, MAXLOCALS, "local variables"); | 334 | checklimit(ls, fs->nlocalvar+n+1, MAXLOCALS, "local variables"); |
335 | fs->localvar[fs->nlocalvar+n] = name; | 335 | fs->localvar[fs->nlocalvar+n] = name; |
336 | luaI_registerlocalvar(ls, name, ls->linenumber); | ||
337 | } | 336 | } |
338 | 337 | ||
339 | 338 | ||
340 | static void add_localvar (LexState *ls, TaggedString *name) { | 339 | static void adjustlocalvars (LexState *ls, int nvars, int line) { |
341 | store_localvar(ls, name, 0); | 340 | FuncState *fs = ls->fs; |
342 | ls->fs->nlocalvar++; | 341 | int i; |
342 | fs->nlocalvar += nvars; | ||
343 | for (i=fs->nlocalvar-nvars; i<fs->nlocalvar; i++) | ||
344 | luaI_registerlocalvar(ls, fs->localvar[i], line); | ||
343 | } | 345 | } |
344 | 346 | ||
345 | 347 | ||
346 | static void correctvarlines (LexState *ls, int nvars) { | 348 | static void add_localvar (LexState *ls, TaggedString *name) { |
347 | FuncState *fs = ls->fs; | 349 | store_localvar(ls, name, 0); |
348 | if (fs->nvars != -1) { /* debug information? */ | 350 | adjustlocalvars(ls, 1, 0); |
349 | for (; nvars; nvars--) { /* correct line information */ | ||
350 | fs->f->locvars[fs->nvars-nvars].line = fs->lastsetline; | ||
351 | } | ||
352 | } | ||
353 | } | 351 | } |
354 | 352 | ||
355 | 353 | ||
@@ -454,7 +452,7 @@ static void adjust_mult_assign (LexState *ls, int nvars, listdesc *d) { | |||
454 | 452 | ||
455 | static void code_args (LexState *ls, int nparams, int dots) { | 453 | static void code_args (LexState *ls, int nparams, int dots) { |
456 | FuncState *fs = ls->fs; | 454 | FuncState *fs = ls->fs; |
457 | fs->nlocalvar += nparams; /* `self' may already be there */ | 455 | adjustlocalvars(ls, nparams, 0); |
458 | checklimit(ls, fs->nlocalvar, MAXPARAMS, "parameters"); | 456 | checklimit(ls, fs->nlocalvar, MAXPARAMS, "parameters"); |
459 | nparams = fs->nlocalvar; | 457 | nparams = fs->nlocalvar; |
460 | if (!dots) { | 458 | if (!dots) { |
@@ -760,8 +758,7 @@ static void localstat (LexState *ls) { | |||
760 | next(ls); | 758 | next(ls); |
761 | nvars = localnamelist(ls); | 759 | nvars = localnamelist(ls); |
762 | decinit(ls, &d); | 760 | decinit(ls, &d); |
763 | fs->nlocalvar += nvars; | 761 | adjustlocalvars(ls, nvars, fs->lastsetline); |
764 | correctvarlines(ls, nvars); /* vars will be alive only after decinit */ | ||
765 | adjust_mult_assign(ls, nvars, &d); | 762 | adjust_mult_assign(ls, nvars, &d); |
766 | } | 763 | } |
767 | 764 | ||