From 2dfa15a926f06137f2ba6afcce2e3c1d23300100 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 13 Sep 2020 20:56:14 +0800 Subject: *misc --- src/lua51/lapi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/lua51/lapi.c') diff --git a/src/lua51/lapi.c b/src/lua51/lapi.c index eeaa5ad..a476634 100644 --- a/src/lua51/lapi.c +++ b/src/lua51/lapi.c @@ -795,13 +795,14 @@ struct CallS { /* data to `f_call' */ }; +//c 执行字节码,调用luaD_call进入虚拟机主循环 static void f_call (lua_State *L, void *ud) { struct CallS *c = cast(struct CallS *, ud); luaD_call(L, c->func, c->nresults); } -//c +//c 执行字节码 LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { struct CallS c; int status; @@ -816,8 +817,10 @@ LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { api_checkvalidindex(L, o); func = savestack(L, o); } - c.func = L->top - (nargs+1); /* function to be called */ //调用的函数的指针,是f_parser函数的输出,放在栈顶的那个指针 + //c 调用的函数的指针,是f_parser函数的输出,放在栈顶的那个指针 + c.func = L->top - (nargs+1); /* function to be called */ c.nresults = nresults; + //c 进入虚拟机主循环 f_call status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); adjustresults(L, nresults); lua_unlock(L); @@ -868,7 +871,7 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, lua_lock(L); if (!chunkname) chunkname = "?"; luaZ_init(L, &z, reader, data); - //c 保护模式下编译源代码 + //c 保护模式下编译源代码,生成一个闭包留在栈顶 status = luaD_protectedparser(L, &z, chunkname); // 编译 lua_unlock(L); return status; -- cgit v1.1-26-g67d0