| 1616 | |
| 1617 | |
| 1618 | Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, |
| 1619 | Dyndata *dyd, const char *name, int firstchar) { |
| 1620 | LexState lexstate; |
| 1621 | FuncState funcstate; |
| 1622 | Closure *cl = luaF_newLclosure(L, 1); /* create main closure */ |
| 1623 | /* anchor closure (to avoid being collected) */ |
| 1624 | setclLvalue(L, L->top, cl); |
| 1625 | incr_top(L); |
| 1626 | funcstate.f = cl->l.p = luaF_newproto(L); |
| 1627 | funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ |
| 1628 | lexstate.buff = buff; |
| 1629 | lexstate.dyd = dyd; |
| 1630 | dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; |
| 1631 | luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); |
| 1632 | mainfunc(&lexstate, &funcstate); |
| 1633 | lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); |
| 1634 | /* all scopes should be correctly finished */ |
| 1635 | lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); |
| 1636 | return cl; /* it's on the stack too */ |
| 1637 | } |
| 1638 |
no test coverage detected