MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / constructor

Function constructor

lib/lua/src/lparser.c:925–948  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

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