| 750 | |
| 751 | |
| 752 | static void constructor(LexState *ls, expdesc *t) { |
| 753 | /* constructor -> '{' [ field { sep field } [sep] ] '}' |
| 754 | sep -> ',' | ';' */ |
| 755 | FuncState *fs = ls->fs; |
| 756 | int line = ls->linenumber; |
| 757 | int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); |
| 758 | struct ConsControl cc; |
| 759 | cc.na = cc.nh = cc.tostore = 0; |
| 760 | cc.t = t; |
| 761 | init_exp(t, VRELOCABLE, pc); |
| 762 | init_exp(&cc.v, VVOID, 0); /* no value (yet) */ |
| 763 | luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ |
| 764 | checknext(ls, '{'); |
| 765 | do { |
| 766 | lua_assert(cc.v.k == VVOID || cc.tostore > 0); |
| 767 | if (ls->t.token == '}') break; |
| 768 | closelistfield(fs, &cc); |
| 769 | field(ls, &cc); |
| 770 | } while (testnext(ls, ',') || testnext(ls, ';')); |
| 771 | check_match(ls, '}', '{', line); |
| 772 | lastlistfield(fs, &cc); |
| 773 | SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ |
| 774 | SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ |
| 775 | } |
| 776 | |
| 777 | /* }====================================================================== */ |
| 778 |
no test coverage detected