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

Function constructor

freebsd/contrib/openzfs/module/lua/lparser.c:734–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

funcargsFunction · 0.70
simpleexpFunction · 0.70

Calls 10

luaK_codeABCFunction · 0.70
init_expFunction · 0.70
luaK_exp2nextregFunction · 0.70
checknextFunction · 0.70
closelistfieldFunction · 0.70
fieldFunction · 0.70
testnextFunction · 0.70
check_matchFunction · 0.70
lastlistfieldFunction · 0.70
luaO_int2fbFunction · 0.70

Tested by

no test coverage detected