| 1958 | |
| 1959 | |
| 1960 | LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, |
| 1961 | Dyndata *dyd, const char *name, int firstchar) { |
| 1962 | LexState lexstate; |
| 1963 | FuncState funcstate; |
| 1964 | LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */ |
| 1965 | setclLvalue2s(L, L->top, cl); /* anchor it (to avoid being collected) */ |
| 1966 | luaD_inctop(L); |
| 1967 | lexstate.h = luaH_new(L); /* create table for scanner */ |
| 1968 | sethvalue2s(L, L->top, lexstate.h); /* anchor it */ |
| 1969 | luaD_inctop(L); |
| 1970 | funcstate.f = cl->p = luaF_newproto(L); |
| 1971 | funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ |
| 1972 | luaC_objbarrier(L, funcstate.f, funcstate.f->source); |
| 1973 | lexstate.buff = buff; |
| 1974 | lexstate.dyd = dyd; |
| 1975 | dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; |
| 1976 | luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); |
| 1977 | mainfunc(&lexstate, &funcstate); |
| 1978 | lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); |
| 1979 | /* all scopes should be correctly finished */ |
| 1980 | lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); |
| 1981 | L->top--; /* remove scanner's table */ |
| 1982 | return cl; /* closure is on the stack, too */ |
| 1983 | } |
| 1984 |
no test coverage detected