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