アットウィキロゴ

Interp

概要



メンバー

  • char *result; 最後のコマンドが返した文字列。直接アクセスしてはいけない。
  • Tcl_FreeProc *freeProc; 0の時文字列は静的にアロケートされている。 TCL_DYNAMIC のとき、ckallocでアロケートされているので、ckfreeで解放しないと行けない。他の値の時は、文字列を得るための手続きのアドレスをしめす。Tcl_Evalは、次のコマンドを実行する前にfreeしないといけない。
  • int errorLine; TCL_ERROR が返ってきたとき、エラーの発生した行数。
  • struct TclStubs *stubTable; サポートされない関数群
  • TclHandle handle; void型のポインタ
  • Namespace *globalNsPtr; global ネームスペースへのポインタ
  • Tcl_HashTable *hiddenCmdTablePtr; hidden commaandをトラックするためのハッシュテーブル
  • ClientData interpInfo; intep basis上のmaster/slaveをトラックスのに使う。
  • Tcl_HashTable unused2; 未使用
  • int numLevels; 実行中にTcl_Evalがどれだけネストして呼ばれているかを保存する。
  • int maxNestingDepth; ネストしている呼び出し回数の最大値
  • CallFrame *framePtr; 全てのネストした手続きの中で一番上のスタックを指す
  • CallFrame *varFramePtr; 現在使用しているスタック。uplevelを使わない限り、framePtrと同じ
  • ActiveVarTrace *activeVarTracePtr; intepのアクティブトレースの先頭
  • int returnCode;
  • CallFrame *rootFramePtr; グローバルフレームポインタ
  • Namespace *lookupNsPtr; Tcl_EvalObjvに対して 次の TCL_EVAL_INVOKE にのみ使用するネームスペース
  • char *appendResult; Tcl_AppendResult によって生成された結果用の保存スペース。Ckallokを使っている。
  • int appendAvl; partialResult に多指定の有効な空間の合計
  • int appendUsed; partialResult に対して保存しているnon-nullバイトの数
  • Tcl_HashTable packageTable; このインタープリターで有効、もしくはロードされている全てのパッケージの記述。キーはパッケージネーム、値はパッケージへのポインタ。
  • char *packageUnknown; パッケージテーブルに記載されていないコマンド。Ckallocされる。おそらくNULL
  • int cmdCount; インタープリターに呼ばれたコマンドの回数。
  • int evalFlags; 次に Tcl_Evalを呼ぶときのフラグ
  • int unused1; 未使用
  • LiteralTable literalTable; リテラルテーブル
  • int compileEpoch; 現在の "compilation epoch" を保存する。存在するバイトコードを無効にするためにインクリメントする。
  • Proc *compiledProcPtr; 手続きがコンパイルされているとき、そのProc構造体へのポインタ。
  • ResolverScheme *resolverPtr;
  • Tcl_Obj *scriptFile; ソースがネストしていないときはNULL、そうでなけばソースファイルへのポインタ。
  • int flags; フラグ
  • long randSeed; 乱数のSEED
  • Trace *tracePtr; このインタープリターへのトレースのリスト
  • Tcl_HashTable *assocData; インタープリターに関連つけられたハッシュテーブル
  • struct ExecEnv *execEnvPtr; Tcl バイトコードの実行用の環境
  • Tcl_Obj *emptyObjPtr; 空文字列を保存しているオブジェクトへのポインタ
  • char resultSpace[TCL_RESULT_SIZE+1]; 小さい結果用の静的な空間
  • Tcl_Obj *objResultPtr; 最後のコマンドが返した結果
  • Tcl_ThreadId threadId; スレッドID
  • ActiveCommandTrace *activeCmdTracePtr; interpへのアクティブなコマンドトレースの先頭
  • ActiveInterpTrace *activeInterpTracePtr; interpへのアクティブなトレースの先頭
  • int tracesForbiddingInline; トレースの数
  • Tcl_Obj *returnOpts; last [return] commandへのオプションを保持している辞書
  • Tcl_Obj *errorInfo;
  • Tcl_Obj *eiVar;
  • Tcl_Obj *errorCode;
  • Tcl_Obj *ecVar;
  • int returnLevel; [return -level] parameter.
  • struct limit; リソースの限界 TIP#143
  • struct ensembleRewrite ensenblesから作られるデフォルトのエラー生成情報 TIP#112
  • Tcl_Obj *chanMsg; I/OシステムへのGlobal info TIP#219
  • CmdFrame *cmdFramePtr; 現時のコマンドのロケーション情報を含んでいるコマンドフレーム TIP#280
  • const CmdFrame *invokeCmdFramePtr; バイトコードのコンパイラによって起動されるコマンドフレーム
  • int invokeWord; コンパイルされたコマンドの中のワードインデックス
  • Tcl_HashTable *linePBodyPtr; bodyへのロケーション情報の手続きを記録しているテーブル?
  • Tcl_HashTable *lineBCPtr;
  • Tcl_HashTable *lineLABCPtr;
  • Tcl_HashTable *lineLAPtr; 実行スタック上の各引数を記録しているテーブル。
  • ContLineLoc *scriptCLLocPtr; このテーブルは、スクリプトの見えない continuation linesを記録する。
  • int packagePrefer; 現在のacvitve selection mode TIP#268
  • Tcl_HashTable varTraces; 変数のアクティブトレースリストのハッシュテーブル
  • Tcl_HashTable varSearches; 変数のアクティブサーチリストのハッシュテーブル
  • void *allocCache;
  • void *pendingObjDataPtr; キャッシュとペンディングオブジェクトへのポインタ
  • int *asyncReadyPtr; asyncReady indicator へのポインタ
  • int *stackBound; stackアドレスの限界へのポインタ
  • ByteCodeStats stats; コンパイルと実行の統計情報


struct limit メンバー

時間とコマンドの両方でチェックをしている。
TIP#143
  • int active;
  • int granularityTicker; どのくらい頻繁にlimitをチェックしたかのカウンター
  • int exceeded; どっちのlimitが超えたかを表すフラグ
  • int cmdCount; コマンドの回数
  • LimitHandler *cmdHandlers; limitを超えたときに実行されるハンドラ
  • int cmdGranularity;
  • Tcl_Time time; 時間のlimit
  • LimitHandler *timeHandlers; limitを超えたときに実行されるハンドラ
  • int timeGranularity;
  • Tcl_TimerToken timeEvent; time-limitが超えたときのコールバック関数
  • Tcl_HashTable callbacks; pairからデータへのマッピング。limitを超えたときのハンドラを、ここにインストールする?

struct ensembleRewrite のメンバー

  • Tcl_Obj *const *sourceObjs; *root* enssemble コマンドに実際に入力された引数
  • int numRemovedObjs; ensemble processingの為に、取り除かれた引数の数
  • int numInsertedObjs; ensambleによって挿入されたcurrent引数の数

ソース


 /*
  *----------------------------------------------------------------
  * This structure defines an interpreter, which is a collection of commands
  * plus other state information related to interpreting commands, such as
  * variable storage. Primary responsibility for this data structure is in
  * tclBasic.c, but almost every Tcl source file uses something in here.
  *----------------------------------------------------------------
  */
 
 typedef struct Interp {
     /*
      * Note: the first three fields must match exactly the fields in a
      * Tcl_Interp struct (see tcl.h). If you change one, be sure to change the
      * other.
      *
      * The interpreter's result is held in both the string and the
      * objResultPtr fields. These fields hold, respectively, the result's
      * string or object value. The interpreter's result is always in the
      * result field if that is non-empty, otherwise it is in objResultPtr.
      * The two fields are kept consistent unless some C code sets
      * interp->result directly. Programs should not access result and
      * objResultPtr directly; instead, they should always get and set the
      * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult, and
      * Tcl_GetStringResult. See the SetResult man page for details.
      */
 
     char *result;		/* If the last command returned a string
 				 * result, this points to it. Should not be
 				 * accessed directly; see comment above. */
     [[Tcl_FreeProc]] *freeProc;	/* Zero means a string result is statically
 				 * allocated. TCL_DYNAMIC means string result
 				 * was allocated with ckalloc and should be
 				 * freed with ckfree. Other values give
 				 * address of procedure to invoke to free the
 				 * string result. Tcl_Eval must free it before
 				 * executing next command. */
     int errorLine;		/* When TCL_ERROR is returned, this gives the
 				 * line number in the command where the error
 				 * occurred (1 means first line). */
     struct [[TclStubs]] *stubTable;
 				/* Pointer to the exported Tcl stub table. On
 				 * previous versions of Tcl this is a pointer
 				 * to the objResultPtr or a pointer to a
 				 * buckets array in a hash table. We therefore
 				 * have to do some careful checking before we
 				 * can use this. */
 
     [[TclHandle]] handle;		/* Handle used to keep track of when this
 				 * interp is deleted. */
 
     [[Namespace]] *globalNsPtr;	/* The interpreter's global namespace. */
     [[Tcl_HashTable]] *hiddenCmdTablePtr;
 				/* Hash table used by tclBasic.c to keep track
 				 * of hidden commands on a per-interp
 				 * basis. */
     [[ClientData]] interpInfo;	/* Information used by tclInterp.c to keep
 				 * track of master/slave interps on a
 				 * per-interp basis. */
     Tcl_HashTable unused2;	/* No longer used (was mathFuncTable) */
 
     /*
      * Information related to procedures and variables. See tclProc.c and
      * tclVar.c for usage.
      */
 
     int numLevels;		/* Keeps track of how many nested calls to
 				 * Tcl_Eval are in progress for this
 				 * interpreter. It's used to delay deletion of
 				 * the table until all Tcl_Eval invocations
 				 * are completed. */
     int maxNestingDepth;	/* If numLevels exceeds this value then Tcl
 				 * assumes that infinite recursion has
 				 * occurred and it generates an error. */
     [[CallFrame]] *framePtr;	/* Points to top-most in stack of all nested
 				 * procedure invocations. */
     CallFrame *varFramePtr;	/* Points to the call frame whose variables
 				 * are currently in use (same as framePtr
 				 * unless an "uplevel" command is
 				 * executing). */
     [[ActiveVarTrace]] *activeVarTracePtr;
 				/* First in list of active traces for interp,
 				 * or NULL if no active traces. */
     int returnCode;		/* [return -code] parameter. */
     CallFrame *rootFramePtr;	/* Global frame pointer for this
 				 * interpreter. */
     Namespace *lookupNsPtr;	/* Namespace to use ONLY on the next
 				 * TCL_EVAL_INVOKE call to Tcl_EvalObjv. */
 
     /*
      * Information used by Tcl_AppendResult to keep track of partial results.
      * See Tcl_AppendResult code for details.
      */
 
     char *appendResult;		/* Storage space for results generated by
 				 * Tcl_AppendResult. Ckalloc-ed. NULL means
 				 * not yet allocated. */
     int appendAvl;		/* Total amount of space available at
 				 * partialResult. */
     int appendUsed;		/* Number of non-null bytes currently stored
 				 * at partialResult. */
 
     /*
      * Information about packages. Used only in tclPkg.c.
      */
 
     Tcl_HashTable packageTable;	/* Describes all of the packages loaded in or
 				 * available to this interpreter. Keys are
 				 * package names, values are (Package *)
 				 * pointers. */
     char *packageUnknown;	/* [[Command]] to invoke during "package require"
 				 * commands for packages that aren't described
 				 * in packageTable. Ckalloc'ed, may be
 				 * NULL. */
     /*
      * Miscellaneous information:
      */
 
     int cmdCount;		/* Total number of times a command procedure
 				 * has been called for this interpreter. */
     int evalFlags;		/* Flags to control next call to [[Tcl_Eval]].
 				 * Normally zero, but may be set before
 				 * calling Tcl_Eval. See below for valid
 				 * values. */
     int unused1;		/* No longer used (was termOffset) */
     [[LiteralTable]] literalTable;	/* Contains [[LiteralEntry]]'s describing all Tcl
 				 * objects holding literals of scripts
 				 * compiled by the interpreter. Indexed by the
 				 * string representations of literals. Used to
 				 * avoid creating duplicate objects. */
     int compileEpoch;		/* Holds the current "compilation epoch" for
 				 * this interpreter. This is incremented to
 				 * invalidate existing ByteCodes when, e.g., a
 				 * command with a compile procedure is
 				 * redefined. */
     [[Proc]] *compiledProcPtr;	/* If a procedure is being compiled, a pointer
 				 * to its Proc structure; otherwise, this is
 				 * NULL. Set by ObjInterpProc in tclProc.c and
 				 * used by tclCompile.c to process local
 				 * variables appropriately. */
     [[ResolverScheme]] *resolverPtr;
 				/* Linked list of name resolution schemes
 				 * added to this interpreter. Schemes are
 				 * added and removed by calling
 				 * Tcl_AddInterpResolvers and
 				 * Tcl_RemoveInterpResolver respectively. */
     [[Tcl_Obj]] *scriptFile;	/* NULL means there is no nested source
 				 * command active; otherwise this points to
 				 * pathPtr of the file being sourced. */
     int flags;			/* Various flag bits. See below. */
     long randSeed;		/* Seed used for rand() function. */
     [[Trace]] *tracePtr;		/* List of traces for this interpreter. */
     Tcl_HashTable *assocData;	/* Hash table for associating data with this
 				 * interpreter. Cleaned up when this
 				 * interpreter is deleted. */
     struct [[ExecEnv]] *execEnvPtr;	/* Execution environment for Tcl bytecode
 				 * execution. Contains a pointer to the Tcl
 				 * evaluation stack. */
     Tcl_Obj *emptyObjPtr;	/* Points to an object holding an empty
 				 * string. Returned by Tcl_ObjSetVar2 when
 				 * variable traces change a variable in a
 				 * gross way. */
     char resultSpace[TCL_RESULT_SIZE+1];
 				/* Static space holding small results. */
     Tcl_Obj *objResultPtr;	/* If the last command returned an object
 				 * result, this points to it. Should not be
 				 * accessed directly; see comment above. */
     Tcl_ThreadId threadId;	/* ID of thread that owns the interpreter. */
 
     [[ActiveCommandTrace]] *activeCmdTracePtr;
 				/* First in list of active command traces for
 				 * interp, or NULL if no active traces. */
     [[ActiveInterpTrace]] *activeInterpTracePtr;
 				/* First in list of active traces for interp,
 				 * or NULL if no active traces. */
 
     int tracesForbiddingInline;	/* Count of traces (in the list headed by
 				 * tracePtr) that forbid inline bytecode
 				 * compilation. */
 
     /*
      * Fields used to manage extensible return options (TIP 90).
      */
 
     Tcl_Obj *returnOpts;	/* A dictionary holding the options to the
 				 * last [return] command. */
 
     Tcl_Obj *errorInfo;		/* errorInfo value (now as a Tcl_Obj). */
     Tcl_Obj *eiVar;		/* cached ref to ::errorInfo variable. */
     Tcl_Obj *errorCode;		/* errorCode value (now as a Tcl_Obj). */
     Tcl_Obj *ecVar;		/* cached ref to ::errorInfo variable. */
     int returnLevel;		/* [return -level] parameter. */
 
     /*
      * Resource limiting framework support (TIP#143).
      */
 
     struct {
 	int active;		/* Flag values defining which limits have been
 				 * set. */
 	int granularityTicker;	/* Counter used to determine how often to
 				 * check the limits. */
 	int exceeded;		/* Which limits have been exceeded, described
 				 * as flag values the same as the 'active'
 				 * field. */
 
 	int cmdCount;		/* Limit for how many commands to execute in
 				 * the interpreter. */
 	LimitHandler *cmdHandlers;
 				/* Handlers to execute when the limit is
 				 * reached. */
 	int cmdGranularity;	/* Mod factor used to determine how often to
 				 * evaluate the limit check. */
 
 	[[Tcl_Time]] time;		/* Time limit for execution within the
 				 * interpreter. */
 	LimitHandler *timeHandlers;
 				/* Handlers to execute when the limit is
 				 * reached. */
 	int timeGranularity;	/* Mod factor used to determine how often to
 				 * evaluate the limit check. */
 	Tcl_TimerToken timeEvent;
 				/* Handle for a timer callback that will occur
 				 * when the time-limit is exceeded. */
 
 	Tcl_HashTable callbacks;/* Mapping from (interp,type) pair to data
 				 * used to install a limit handler callback to
 				 * run in _this_ interp when the limit is
 				 * exceeded. */
     } limit;
 
     /*
      * Information for improved default error generation from ensembles
      * (TIP#112).
      */
 
     struct {
 	Tcl_Obj *const *sourceObjs;
 				/* What arguments were actually input into the
 				 * *root* ensemble command? (Nested ensembles
 				 * don't rewrite this.) NULL if we're not
 				 * processing an ensemble. */
 	int numRemovedObjs;	/* How many arguments have been stripped off
 				 * because of ensemble processing. */
 	int numInsertedObjs;	/* How many of the current arguments were
 				 * inserted by an ensemble. */
     } ensembleRewrite;
 
     /*
      * TIP #219: Global info for the I/O system.
      */
 
     Tcl_Obj *chanMsg;		/* Error message set by channel drivers, for
 				 * the propagation of arbitrary Tcl errors.
 				 * This information, if present (chanMsg not
 				 * NULL), takes precedence over a POSIX error
 				 * code returned by a channel operation. */
 
     /*
      * Source code origin information (TIP #280).
      */
 
     [[CmdFrame]] *cmdFramePtr;	/* Points to the command frame containing the
 				 * location information for the current
 				 * command. */
     const CmdFrame *invokeCmdFramePtr;
 				/* Points to the command frame which is the
 				 * invoking context of the bytecode compiler.
 				 * NULL when the byte code compiler is not
 				 * active. */
     int invokeWord;		/* Index of the word in the command which
 				 * is getting compiled. */
     Tcl_HashTable *linePBodyPtr;/* This table remembers for each statically
 				 * defined procedure the location information
 				 * for its body. It is keyed by the address of
 				 * the Proc structure for a procedure. The
 				 * values are "struct CmdFrame*". */
     Tcl_HashTable *lineBCPtr;	/* This table remembers for each ByteCode
 				 * object the location information for its
 				 * body. It is keyed by the address of the
 				 * Proc structure for a procedure. The values
 				 * are "struct ExtCmdLoc*". (See
 				 * tclCompile.h) */
     Tcl_HashTable *lineLABCPtr;
     Tcl_HashTable *lineLAPtr;	/* This table remembers for each argument of a
 				 * command on the execution stack the index of
 				 * the argument in the command, and the
 				 * location data of the command. It is keyed
 				 * by the address of the Tcl_Obj containing
 				 * the argument. The values are "struct
 				 * CFWord*" (See tclBasic.c). This allows
 				 * commands like uplevel, eval, etc. to find
 				 * location information for their arguments,
 				 * if they are a proper literal argument to an
 				 * invoking command. Alt view: An index to the
 				 * CmdFrame stack keyed by command argument
 				 * holders. */
     [[ContLineLoc]] *scriptCLLocPtr;/* This table points to the location data for
 				 * invisible continuation lines in the script,
 				 * if any. This pointer is set by the function
 				 * TclEvalObjEx() in file "tclBasic.c", and
 				 * used by function ...() in the same file.
 				 * It does for the eval/direct path of script
 				 * execution what CompileEnv.clLoc does for
 				 * the bytecode compiler.
 				 */
     /*
      * TIP #268. The currently active selection mode, i.e. the package require
      * preferences.
      */
 
     int packagePrefer;		/* Current package selection mode. */
 
     /*
      * Hashtables for variable traces and searches.
      */
 
     Tcl_HashTable varTraces;	/* Hashtable holding the start of a variable's
 				 * active trace list; varPtr is the key. */
     Tcl_HashTable varSearches;	/* Hashtable holding the start of a variable's
 				 * active searches list; varPtr is the key. */
     /*
      * The thread-specific data ekeko: cache pointers or values that
      *  (a) do not change during the thread's lifetime
      *  (b) require access to TSD to determine at runtime
      *  (c) are accessed very often (e.g., at each command call)
      *
      * Note that these are the same for all interps in the same thread. They
      * just have to be initialised for the thread's master interp, slaves
      * inherit the value.
      *
      * They are used by the macros defined below.
      */
 
     void *allocCache;
     void *pendingObjDataPtr;	/* Pointer to the Cache and PendingObjData
 				 * structs for this interp's thread; see
 				 * tclObj.c and tclThreadAlloc.c */
     int *asyncReadyPtr;		/* Pointer to the asyncReady indicator for
 				 * this interp's thread; see tclAsync.c */
     int *stackBound;		/* Pointer to the limit stack address
 				 * allowable for invoking a new command
 				 * without "risking" a C-stack overflow; see
 				 * TclpCheckStackSpace in the platform's
 				 * directory. */
 
 
 #ifdef TCL_COMPILE_STATS
     /*
      * Statistical information about the bytecode compiler and interpreter's
      * operation.
      */
 
     [[ByteCodeStats]] stats;	/* Holds compilation and execution statistics
 				 * for this interpreter. */
 #endif /* TCL_COMPILE_STATS */
 } Interp;
最終更新:2011年11月09日 18:41