lua-users home
lua-l archive

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


Wolfgang Pupp <wolfgang.pupp <at> gmail.com> writes:
 
> 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).

This must be close.  I tried running the following code:

    local t1 = {}
    table.insert(t1, 1)

and got this err:

    bad argument #1 to 'insert' (table expected, got number)


I wonder if this has to do with what is at the the top of the stack? 

- Greg