MCPcopy Create free account
hub / github.com/DFHack/dfhack / constructor

Function constructor

depends/lua/src/lparser.c:725–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723
724
725static 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

Callers 2

funcargsFunction · 0.85
simpleexpFunction · 0.85

Calls 10

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

Tested by

no test coverage detected