MCPcopy Create free account
hub / github.com/F-Stack/f-stack / constructor

Function constructor

app/redis-6.2.6/deps/lua/src/lparser.c:502–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500
501
502static void constructor (LexState *ls, expdesc *t) {
503 /* constructor -> ?? */
504 FuncState *fs = ls->fs;
505 int line = ls->linenumber;
506 int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
507 struct ConsControl cc;
508 cc.na = cc.nh = cc.tostore = 0;
509 cc.t = t;
510 init_exp(t, VRELOCABLE, pc);
511 init_exp(&cc.v, VVOID, 0); /* no value (yet) */
512 luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */
513 checknext(ls, '{');
514 do {
515 lua_assert(cc.v.k == VVOID || cc.tostore > 0);
516 if (ls->t.token == '}') break;
517 closelistfield(fs, &cc);
518 switch(ls->t.token) {
519 case TK_NAME: { /* may be listfields or recfields */
520 luaX_lookahead(ls);
521 if (ls->lookahead.token != '=') /* expression? */
522 listfield(ls, &cc);
523 else
524 recfield(ls, &cc);
525 break;
526 }
527 case '[': { /* constructor_item -> recfield */
528 recfield(ls, &cc);
529 break;
530 }
531 default: { /* constructor_part -> listfield */
532 listfield(ls, &cc);
533 break;
534 }
535 }
536 } while (testnext(ls, ',') || testnext(ls, ';'));
537 check_match(ls, '}', '{', line);
538 lastlistfield(fs, &cc);
539 SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */
540 SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */
541}
542
543/* }====================================================================== */
544

Callers 2

funcargsFunction · 0.70
simpleexpFunction · 0.70

Calls 12

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

Tested by

no test coverage detected