MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / constructor

Function constructor

third-party/lua-5.3.5/src/lparser.c:724–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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