lua-users home
lua-l archive

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


Greg tghill@hotmail.com:
> I wonder how hard it would be to patch LuaJIT?

I think you just need to change the function expr_table in lj_parse.c.
Just look for the following else-if (in in lj_parse.c, around line
1545), and replace it with this:

else if (ls->token == TK_name && lj_lex_lookahead(ls) == '=') {
      do {
        expr_str(ls, &key);
        lex_check(ls, '=');
        nhash++;
        /* just pasted & adapted this (from below) */
        expr(ls, &val);
        TValue k;
        if (!t) { /* Create template table on demand. */
          BCReg kidx;
          t = lj_tab_new(fs->L, 0, 0);
          kidx = const_gc(fs, obj2gco(t), LJ_TTAB);
          fs->bcbase[pc].ins = BCINS_AD(BC_TDUP, freg-1, kidx);
        }
        vcall = 0;
        expr_kvalue(&k, &key);
        expr_kvalue(lj_tab_set(fs->L, t, &k), &val);
        lj_gc_anybarriert(fs->L, t);
        fs->freereg = freg;
        /* pasted & adapted part ends here */
      } while (ls->token == TK_name && lj_lex_lookahead(ls) == '=');
      lex_opt(ls, ',');
      lex_opt(ls, ';');
      continue;
    }

That should do the trick; I didn't test it extensively though.
A patchfile is attached (I'm sorry if it's the wrong format or
anything; never used patch/diff before).

Attachment: lj_lesscommas.patch
Description: Binary data