| 923 | |
| 924 | |
| 925 | static void constructor (LexState *ls, expdesc *t) { |
| 926 | /* constructor -> '{' [ field { sep field } [sep] ] '}' |
| 927 | sep -> ',' | ';' */ |
| 928 | FuncState *fs = ls->fs; |
| 929 | int line = ls->linenumber; |
| 930 | int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); |
| 931 | ConsControl cc; |
| 932 | luaK_code(fs, 0); /* space for extra arg. */ |
| 933 | cc.na = cc.nh = cc.tostore = 0; |
| 934 | cc.t = t; |
| 935 | init_exp(t, VNONRELOC, fs->freereg); /* table will be at stack top */ |
| 936 | luaK_reserveregs(fs, 1); |
| 937 | init_exp(&cc.v, VVOID, 0); /* no value (yet) */ |
| 938 | checknext(ls, '{'); |
| 939 | do { |
| 940 | lua_assert(cc.v.k == VVOID || cc.tostore > 0); |
| 941 | if (ls->t.token == '}') break; |
| 942 | closelistfield(fs, &cc); |
| 943 | field(ls, &cc); |
| 944 | } while (testnext(ls, ',') || testnext(ls, ';')); |
| 945 | check_match(ls, '}', '{', line); |
| 946 | lastlistfield(fs, &cc); |
| 947 | luaK_settablesize(fs, pc, t->u.info, cc.na, cc.nh); |
| 948 | } |
| 949 | |
| 950 | /* }====================================================================== */ |
| 951 |
no test coverage detected