lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

in nested function parsing,
static void body (LexState *ls, expdesc *e, int needself, int line) {
  /* body ->  `(' parlist `)' chunk END */
  FuncState new_fs;
  open_func(ls, &new_fs);            =========> start of new child function
  new_fs.f->linedefined = line;
  checknext(ls, '(');
  if (needself) {
    new_localvarliteral(ls, "self", 0);
    adjustlocalvars(ls, 1);
  checknext(ls, ')');
  chunk(ls);                         =========> this will cause GC, so the opend proto would collected because it is not added to parent's p(added in pushclosure)

  new_fs.f->lastlinedefined = ls->linenumber;
  check_match(ls, TK_END, TK_FUNCTION, line);
  close_func(ls);                    =========> end of this function
  pushclosure(ls, &new_fs, e);       =========> add to parent function's p

chunk GC call trace
#0  singlestep (L=0x804e4b0) at lgc.c:560
#1  0x1594c8f0 in luaC_step (L=0x804e4b0) at lgc.c:620
#2  0x159599e3 in luaX_newstring (ls=0x3fffa520, str=0x8057508 "userDatatFileIndexder\"lua\"", l=8) at llex.c:123
#3  0x1595af1d in llex (ls=0x3fffa520, seminfo=0x3fffa530) at llex.c:428
#4  0x1595affd in luaX_next (ls=0x3fffa520) at llex.c:455
#5  0x1594d511 in testnext (ls=0x3fffa520, c=44) at lparser.c:83
#6  0x1594ea16 in parlist (ls=0x3fffa520) at lparser.c:569
#7  0x1594eb52 in body (ls=0x3fffa520, e=0x3fffa220, needself=0, line=49) at lparser.c:595
#8  0x15950348 in funcstat (ls=0x3fffa520, line=49) at lparser.c:1231
#9  0x1595061f in statement (ls=0x3fffa520) at lparser.c:1310
#10 0x15950711 in chunk (ls=0x3fffa520) at lparser.c:1343
#11 0x1594e403 in luaY_parser (L=0x804e4b0, z=0x3fffa740, buff=0x3fffa6f4,
    name=0x8057350 "@/usr/lib/lua_scripts/enables/webbbs_mydrivers.lua") at lparser.c:392
#12 0x1594a43b in f_parser (L=0x804e4b0, ud=0x3fffa6f0) at ldo.c:497
#13 0x159493ea in luaD_rawrunprotected (L=0x804e4b0, f=0x1594a3ca <f_parser>, ud=0x3fffa6f0) at ldo.c:118
#14 0x1594a331 in luaD_pcall (L=0x804e4b0, func=0x1594a3ca <f_parser>, u=0x3fffa6f0, old_top=24, ef=0) at ldo.c:463
#15 0x1594a534 in luaD_protectedparser (L=0x804e4b0, z=0x3fffa740,
    name=0x8057350 "@/usr/lib/lua_scripts/enables/webbbs_mydrivers.lua") at ldo.c:513
#16 0x159473ce in lua_load (L=0x804e4b0, reader=0x15957301 <getF>, data="">