summaryrefslogtreecommitdiff
path: root/src/lua51/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua51/lapi.c')
-rw-r--r--src/lua51/lapi.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lua51/lapi.c b/src/lua51/lapi.c
index 5d5145d..0678908 100644
--- a/src/lua51/lapi.c
+++ b/src/lua51/lapi.c
@@ -801,7 +801,7 @@ static void f_call (lua_State *L, void *ud) {
}
-
+//c
LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
struct CallS c;
int status;
@@ -816,7 +816,7 @@ 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 */
+ c.func = L->top - (nargs+1); /* function to be called */ //调用的函数的指针,是f_parser函数的输出,放在栈顶的那个指针
c.nresults = nresults;
status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
adjustresults(L, nresults);
@@ -859,6 +859,8 @@ LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
}
+//c 加载代码,并编译生成函数原型 调用了f_parser
+//c load完之后会生成一个closure(包含proto)在栈顶
LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
const char *chunkname) {
ZIO z;
@@ -866,7 +868,8 @@ 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);
- status = luaD_protectedparser(L, &z, chunkname);
+ //c 保护模式下编译源代码
+ status = luaD_protectedparser(L, &z, chunkname); // 编译
lua_unlock(L);
return status;
}