MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / constructor

Function constructor

lua/lparser.c:529–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527
528
529static void constructor (LexState *ls, expdesc *t) {
530 /* constructor -> ?? */
531 FuncState *fs = ls->fs;
532 int line = ls->linenumber;
533 int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
534 struct ConsControl cc;
535 cc.na = cc.nh = cc.tostore = 0;
536 cc.t = t;
537 init_exp(t, VRELOCABLE, pc);
538 init_exp(&cc.v, VVOID, 0); /* no value (yet) */
539 luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */
540 checknext(ls, '{');
541 do {
542 lua_assert(cc.v.k == VVOID || cc.tostore > 0);
543 if (ls->t.token == '}') break;
544 closelistfield(fs, &cc);
545 switch(ls->t.token) {
546 case TK_NAME: { /* may be listfields or recfields */
547 luaX_lookahead(ls);
548 if (ls->lookahead.token != '=') /* expression? */
549 listfield(ls, &cc);
550 else
551 recfield(ls, &cc);
552 break;
553 }
554 case '[': { /* constructor_item -> recfield */
555 recfield(ls, &cc);
556 break;
557 }
558 default: { /* constructor_part -> listfield */
559 listfield(ls, &cc);
560 break;
561 }
562 }
563 } while (testnext(ls, ',') || testnext(ls, ';'));
564 check_match(ls, '}', '{', line);
565 lastlistfield(fs, &cc);
566 SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */
567 SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */
568}
569
570/* }====================================================================== */
571

Callers 2

funcargsFunction · 0.85
simpleexpFunction · 0.85

Calls 12

luaK_codeABCFunction · 0.85
init_expFunction · 0.85
luaK_exp2nextregFunction · 0.85
checknextFunction · 0.85
closelistfieldFunction · 0.85
luaX_lookaheadFunction · 0.85
listfieldFunction · 0.85
recfieldFunction · 0.85
testnextFunction · 0.85
check_matchFunction · 0.85
lastlistfieldFunction · 0.85
luaO_int2fbFunction · 0.85

Tested by

no test coverage detected