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

Function constructor

third-party/lua-5.4.6/src/lparser.c:924–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

922
923
924static void constructor (LexState *ls, expdesc *t) {
925 /* constructor -> '{' [ field { sep field } [sep] ] '}'
926 sep -> ',' | ';' */
927 FuncState *fs = ls->fs;
928 int line = ls->linenumber;
929 int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
930 ConsControl cc;
931 luaK_code(fs, 0); /* space for extra arg. */
932 cc.na = cc.nh = cc.tostore = 0;
933 cc.t = t;
934 init_exp(t, VNONRELOC, fs->freereg); /* table will be at stack top */
935 luaK_reserveregs(fs, 1);
936 init_exp(&cc.v, VVOID, 0); /* no value (yet) */
937 checknext(ls, '{');
938 do {
939 lua_assert(cc.v.k == VVOID || cc.tostore > 0);
940 if (ls->t.token == '}') break;
941 closelistfield(fs, &cc);
942 field(ls, &cc);
943 } while (testnext(ls, ',') || testnext(ls, ';'));
944 check_match(ls, '}', '{', line);
945 lastlistfield(fs, &cc);
946 luaK_settablesize(fs, pc, t->u.info, cc.na, cc.nh);
947}
948
949/* }====================================================================== */
950

Callers 2

funcargsFunction · 0.70
simpleexpFunction · 0.70

Calls 11

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
luaK_settablesizeFunction · 0.70
luaK_codeABCFunction · 0.50

Tested by

no test coverage detected