概要
コマンドフレームを定義する構造体
/*
* Data needed for Eval vs TEBC
*
* EXECUTION CONTEXTS and usage of CmdFrame
*
* Field TEBC EvalEx EvalObjEx
* ======= ==== ====== =========
* level yes yes yes
* type BC/PREBC SRC/EVAL EVAL_LIST
* line0 yes yes yes
* framePtr yes yes yes
* ======= ==== ====== =========
*
* ======= ==== ====== ========= union data
* line1 - yes -
* line3 - yes -
* path - yes -
* ------- ---- ------ ---------
* codePtr yes - -
* pc yes - -
* ======= ==== ====== =========
*
* ======= ==== ====== ========= | union cmd
* listPtr - - yes |
* ------- ---- ------ --------- |
* cmd yes yes - |
* cmdlen yes yes - |
* ------- ---- ------ --------- |
*/
メンバー
- int type; /* Values see below. */
- int level; スタック内のフレーム数
- int *line; コマンドが始まるワードのライン /* Lines the words of the command start on. */
- int nline;
- CallFrame *framePtr; activation record の手続き。may be NULL
- struct CmdFrame *nextPtr;
- union {
struct {
[[Tcl_Obj]] *path; コマンドが入っているファイルへのパス
} eval;
struct {
const void *codePtr; 実行中のバイトコード
const char *pc; 命令カウンター
} tebc;
} data;
union {
struct {
const char *cmd; 実行されたコマンドと長さ
int len;
} str;
[[Tcl_Obj]] *listPtr; /* Tcl_EvalObjEx, cmd list. */
} cmd;
ソース
/*
* TIP #280
* The structure below defines a command frame. A command frame provides
* location information for all commands executing a tcl script (source, eval,
* uplevel, procedure bodies, ...). The runtime structure essentially contains
* the stack trace as it would be if the currently executing command were to
* throw an error.
*
* For commands where it makes sense it refers to the associated CallFrame as
* well.
*
* The structures are chained in a single list, with the top of the stack
* anchored in the Interp structure.
*
* Instances can be allocated on the C stack, or the heap, the former making
* cleanup a bit simpler.
*/
typedef struct CmdFrame {
/*
* General data. Always available.
*/
int type; /* Values see below. */
int level; /* Number of frames in stack, prevent O(n)
* scan of list. */
int *line; /* Lines the words of the command start on. */
int nline;
[[CallFrame]] *framePtr; /* Procedure activation record, may be
* NULL. */
struct CmdFrame *nextPtr; /* Link to calling frame. */
/*
* Data needed for Eval vs TEBC
*
* EXECUTION CONTEXTS and usage of CmdFrame
*
* Field TEBC EvalEx EvalObjEx
* ======= ==== ====== =========
* level yes yes yes
* type BC/PREBC SRC/EVAL EVAL_LIST
* line0 yes yes yes
* framePtr yes yes yes
* ======= ==== ====== =========
*
* ======= ==== ====== ========= union data
* line1 - yes -
* line3 - yes -
* path - yes -
* ------- ---- ------ ---------
* codePtr yes - -
* pc yes - -
* ======= ==== ====== =========
*
* ======= ==== ====== ========= | union cmd
* listPtr - - yes |
* ------- ---- ------ --------- |
* cmd yes yes - |
* cmdlen yes yes - |
* ------- ---- ------ --------- |
*/
union {
struct {
Tcl_Obj *path; /* Path of the sourced file the command is
* in. */
} eval;
struct {
const void *codePtr;/* Byte code currently executed... */
const char *pc; /* ... and instruction pointer. */
} tebc;
} data;
union {
struct {
const char *cmd; /* The executed command, if possible... */
int len; /* ... and its length. */
} str;
Tcl_Obj *listPtr; /* Tcl_EvalObjEx, cmd list. */
} cmd;
} CmdFrame;
最終更新:2011年11月09日 18:00