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

Function constructor

third-party/lua-5.5.0/src/lparser.c:1028–1054  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026
1027
1028static void constructor (LexState *ls, expdesc *t) {
1029 /* constructor -> '{' [ field { sep field } [sep] ] '}'
1030 sep -> ',' | ';' */
1031 FuncState *fs = ls->fs;
1032 int line = ls->linenumber;
1033 int pc = luaK_codevABCk(fs, OP_NEWTABLE, 0, 0, 0, 0);
1034 ConsControl cc;
1035 luaK_code(fs, 0); /* space for extra arg. */
1036 cc.na = cc.nh = cc.tostore = 0;
1037 cc.t = t;
1038 init_exp(t, VNONRELOC, fs->freereg); /* table will be at stack top */
1039 luaK_reserveregs(fs, 1);
1040 init_exp(&cc.v, VVOID, 0); /* no value (yet) */
1041 checknext(ls, '{' /*}*/);
1042 cc.maxtostore = maxtostore(fs);
1043 do {
1044 if (ls->t.token == /*{*/ '}') break;
1045 if (cc.v.k != VVOID) /* is there a previous list item? */
1046 closelistfield(fs, &cc); /* close it */
1047 field(ls, &cc);
1048 luaY_checklimit(fs, cc.tostore + cc.na + cc.nh, MAX_CNST,
1049 "items in a constructor");
1050 } while (testnext(ls, ',') || testnext(ls, ';'));
1051 check_match(ls, /*{*/ '}', '{' /*}*/, line);
1052 lastlistfield(fs, &cc);
1053 luaK_settablesize(fs, pc, t->u.info, cc.na, cc.nh);
1054}
1055
1056/* }====================================================================== */
1057

Callers 2

funcargsFunction · 0.70
simpleexpFunction · 0.70

Calls 13

luaK_codevABCkFunction · 0.85
maxtostoreFunction · 0.85
luaY_checklimitFunction · 0.85
luaK_codeFunction · 0.70
init_expFunction · 0.70
luaK_reserveregsFunction · 0.70
checknextFunction · 0.70
closelistfieldFunction · 0.70
fieldFunction · 0.70
testnextFunction · 0.70
check_matchFunction · 0.70
lastlistfieldFunction · 0.70

Tested by

no test coverage detected