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

Function mainfunc

depends/lua/src/lparser.c:1613–1625  ·  view source on GitHub ↗

** compiles the main function, which is a regular vararg function with an ** upvalue named LUA_ENV */

Source from the content-addressed store, hash-verified

1611** upvalue named LUA_ENV
1612*/
1613static void mainfunc (LexState *ls, FuncState *fs) {
1614 BlockCnt bl;
1615 expdesc v;
1616 open_func(ls, fs, &bl);
1617 fs->f->is_vararg = 1; /* main function is always declared vararg */
1618 init_exp(&v, VLOCAL, 0); /* create and... */
1619 newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
1620 luaC_objbarrier(ls->L, fs->f, ls->envn);
1621 luaX_next(ls); /* read first token */
1622 statlist(ls); /* parse main body */
1623 check(ls, TK_EOS);
1624 close_func(ls);
1625}
1626
1627
1628LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,

Callers 1

luaY_parserFunction · 0.85

Calls 7

open_funcFunction · 0.85
init_expFunction · 0.85
newupvalueFunction · 0.85
luaX_nextFunction · 0.85
statlistFunction · 0.85
checkFunction · 0.85
close_funcFunction · 0.85

Tested by

no test coverage detected