| 723 | |
| 724 | |
| 725 | static void constructor (LexState *ls, expdesc *t) { |
| 726 | /* constructor -> '{' [ field { sep field } [sep] ] '}' |
| 727 | sep -> ',' | ';' */ |
| 728 | FuncState *fs = ls->fs; |
| 729 | int line = ls->linenumber; |
| 730 | int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); |
| 731 | struct ConsControl cc; |
| 732 | cc.na = cc.nh = cc.tostore = 0; |
| 733 | cc.t = t; |
| 734 | init_exp(t, VRELOCABLE, pc); |
| 735 | init_exp(&cc.v, VVOID, 0); /* no value (yet) */ |
| 736 | luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ |
| 737 | checknext(ls, '{'); |
| 738 | do { |
| 739 | lua_assert(cc.v.k == VVOID || cc.tostore > 0); |
| 740 | if (ls->t.token == '}') break; |
| 741 | closelistfield(fs, &cc); |
| 742 | field(ls, &cc); |
| 743 | } while (testnext(ls, ',') || testnext(ls, ';')); |
| 744 | check_match(ls, '}', '{', line); |
| 745 | lastlistfield(fs, &cc); |
| 746 | SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ |
| 747 | SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ |
| 748 | } |
| 749 | |
| 750 | /* }====================================================================== */ |
| 751 |
no test coverage detected