| 1940 | |
| 1941 | |
| 1942 | LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, |
| 1943 | Dyndata *dyd, const char *name, int firstchar) { |
| 1944 | LexState lexstate; |
| 1945 | FuncState funcstate; |
| 1946 | LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */ |
| 1947 | setclLvalue2s(L, L->top.p, cl); /* anchor it (to avoid being collected) */ |
| 1948 | luaD_inctop(L); |
| 1949 | lexstate.h = luaH_new(L); /* create table for scanner */ |
| 1950 | sethvalue2s(L, L->top.p, lexstate.h); /* anchor it */ |
| 1951 | luaD_inctop(L); |
| 1952 | funcstate.f = cl->p = luaF_newproto(L); |
| 1953 | luaC_objbarrier(L, cl, cl->p); |
| 1954 | funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ |
| 1955 | luaC_objbarrier(L, funcstate.f, funcstate.f->source); |
| 1956 | lexstate.buff = buff; |
| 1957 | lexstate.dyd = dyd; |
| 1958 | dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; |
| 1959 | luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); |
| 1960 | mainfunc(&lexstate, &funcstate); |
| 1961 | lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); |
| 1962 | /* all scopes should be correctly finished */ |
| 1963 | lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); |
| 1964 | L->top.p--; /* remove scanner's table */ |
| 1965 | return cl; /* closure is on the stack, too */ |
| 1966 | } |
| 1967 |
no test coverage detected