MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / constructor

Function constructor

3rd/lua-5.4.3/src/lparser.c:913–936  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

funcargsFunction · 0.85
simpleexpFunction · 0.85

Calls 10

luaK_codeFunction · 0.85
init_expFunction · 0.85
luaK_reserveregsFunction · 0.85
checknextFunction · 0.85
closelistfieldFunction · 0.85
fieldFunction · 0.85
testnextFunction · 0.85
check_matchFunction · 0.85
lastlistfieldFunction · 0.85
luaK_settablesizeFunction · 0.85

Tested by

no test coverage detected