| 1626 | |
| 1627 | |
| 1628 | LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, |
| 1629 | Dyndata *dyd, const char *name, int firstchar) { |
| 1630 | LexState lexstate; |
| 1631 | FuncState funcstate; |
| 1632 | LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */ |
| 1633 | setclLvalue(L, L->top, cl); /* anchor it (to avoid being collected) */ |
| 1634 | luaD_inctop(L); |
| 1635 | lexstate.h = luaH_new(L); /* create table for scanner */ |
| 1636 | sethvalue(L, L->top, lexstate.h); /* anchor it */ |
| 1637 | luaD_inctop(L); |
| 1638 | funcstate.f = cl->p = luaF_newproto(L); |
| 1639 | luaC_objbarrier(L, cl, cl->p); |
| 1640 | funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ |
| 1641 | lua_assert(iswhite(funcstate.f)); /* do not need barrier here */ |
| 1642 | lexstate.buff = buff; |
| 1643 | lexstate.dyd = dyd; |
| 1644 | dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; |
| 1645 | luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); |
| 1646 | mainfunc(&lexstate, &funcstate); |
| 1647 | lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); |
| 1648 | /* all scopes should be correctly finished */ |
| 1649 | lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); |
| 1650 | L->top--; /* remove scanner's table */ |
| 1651 | return cl; /* closure is on the stack, too */ |
| 1652 | } |
| 1653 |
no test coverage detected