lua-users home
lua-l archive

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


> If the theory is indeed confirmed, is there a reason why the line hook
> is not triggered *before* the entire translation?

Line hooks are triggered whenever the code starts executing a new line.
There is no relation to what the line does. We cannot control when
they are triggered.

It seems that the best solution is to actually do the "= nil" part. The
new version of `localfunc' would be something like this:

  static void localfunc (LexState *ls) {
    expdesc v, b;
    FuncState *fs = ls->fs;
    new_localvar(ls, str_checkname(ls), 0);
    b.k = VVOID;
    adjust_assign(ls, 1, 0, &b);
    adjustlocalvars(ls, 1);
    init_exp(&v, VLOCAL, fs->freereg - 1);
    body(ls, &b, 0, ls->linenumber);
    luaK_storevar(fs, &v, &b);
  }

-- Roberto