| 904 | |
| 905 | |
| 906 | static void constructor (LexState *ls, expdesc *t) { |
| 907 | /* constructor -> '{' [ field { sep field } [sep] ] '}' |
| 908 | sep -> ',' | ';' */ |
| 909 | FuncState *fs = ls->fs; |
| 910 | int line = ls->linenumber; |
| 911 | int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); |
| 912 | ConsControl cc; |
| 913 | luaK_code(fs, 0); /* space for extra arg. */ |
| 914 | cc.na = cc.nh = cc.tostore = 0; |
| 915 | cc.t = t; |
| 916 | init_exp(t, VNONRELOC, fs->freereg); /* table will be at stack top */ |
| 917 | luaK_reserveregs(fs, 1); |
| 918 | init_exp(&cc.v, VVOID, 0); /* no value (yet) */ |
| 919 | checknext(ls, '{'); |
| 920 | do { |
| 921 | lua_assert(cc.v.k == VVOID || cc.tostore > 0); |
| 922 | if (ls->t.token == '}') break; |
| 923 | closelistfield(fs, &cc); |
| 924 | field(ls, &cc); |
| 925 | } while (testnext(ls, ',') || testnext(ls, ';')); |
| 926 | check_match(ls, '}', '{', line); |
| 927 | lastlistfield(fs, &cc); |
| 928 | luaK_settablesize(fs, pc, t->u.info, cc.na, cc.nh); |
| 929 | } |
| 930 | |
| 931 | /* }====================================================================== */ |
| 932 |
no test coverage detected