source codeは、従うのは比較的簡単で非常にコメントです。
libが実行する機能は、どのパーツが機能やスレッドを構成するかを決定し、すべてのパーツを別々に格納することです。あなたは、コードをスキップしてちょうどコメントを読めば
は、ここでは2つの関連の機能がどのように見えるかです:
static void persistfunction(PersistInfo *pi)
{
...
if(cl->c.isC) {
/* It's a C function. For now, we aren't going to allow
* persistence of C closures, even if the "C proto" is
* already in the permanents table. */
lua_pushstring(pi->L, "Attempt to persist a C function");
lua_error(pi->L);
} else { /* It's a Lua closure. */
/* Persist prototype */
...
/* Persist upvalue values (not the upvalue objects themselves) */
...
/* Persist function environment */
...
}
}
static void persistthread(PersistInfo *pi)
{
...
/* Persist the stack */
...
/* Now, persist the CallInfo stack. */
...
/* Serialize the state's other parameters, with the exception of upval stuff */
...
/* Finally, record upvalues which need to be reopened */
...
}
だから、あなたが見ることができるように、関数はプロトタイプの組成物として考えることができ、 upvaluesのグループと環境(テーブル)。スレッドは、2つの「スタック」(呼び出しスタックとメモリスタック)、状態情報(上位値を除く)、つまりスレッドが定義されたときに基本的にどの変数に値があったか、および上位値です。
アップルの詳細については、PiL 27.3.3