tclcompile.h

来自「tcl是工具命令语言」· C头文件 代码 · 共 1,047 行 · 第 1/3 页

H
1,047
字号
				 * holding the loop's iteration count. Used				 * to determine next value list element to				 * assign each loop var. */    ForeachVarList *varLists[1];/* An array of pointers to ForeachVarList				 * structures describing each var list. The				 * actual size of this field will be large				 * enough to numVars indexes. THIS MUST BE				 * THE LAST FIELD IN THE STRUCTURE! */} ForeachInfo;extern AuxDataType		tclForeachInfoType;/* *---------------------------------------------------------------- * Procedures exported by tclBasic.c to be used within the engine. *---------------------------------------------------------------- */EXTERN int		TclEvalObjvInternal _ANSI_ARGS_((Tcl_Interp *interp, int objc,			    Tcl_Obj *CONST objv[], CONST char *command, int length,			    int flags));EXTERN int              TclInterpReady _ANSI_ARGS_((Tcl_Interp *interp));/* *---------------------------------------------------------------- * Procedures exported by the engine to be used by tclBasic.c *---------------------------------------------------------------- */EXTERN int		TclCompEvalObj _ANSI_ARGS_((Tcl_Interp *interp,			    Tcl_Obj *objPtr));/* *---------------------------------------------------------------- * Procedures shared among Tcl bytecode compilation and execution * modules but not used outside: *---------------------------------------------------------------- */EXTERN void		TclCleanupByteCode _ANSI_ARGS_((ByteCode *codePtr));EXTERN int		TclCompileCmdWord _ANSI_ARGS_((Tcl_Interp *interp,			    Tcl_Token *tokenPtr, int count,			    CompileEnv *envPtr));EXTERN int		TclCompileExpr _ANSI_ARGS_((Tcl_Interp *interp,			    CONST char *script, int numBytes,			    CompileEnv *envPtr));EXTERN int		TclCompileExprWords _ANSI_ARGS_((Tcl_Interp *interp,			    Tcl_Token *tokenPtr, int numWords,			    CompileEnv *envPtr));EXTERN int		TclCompileScript _ANSI_ARGS_((Tcl_Interp *interp,			    CONST char *script, int numBytes, int nested,			    CompileEnv *envPtr));EXTERN int		TclCompileTokens _ANSI_ARGS_((Tcl_Interp *interp,			    Tcl_Token *tokenPtr, int count,			    CompileEnv *envPtr));EXTERN int		TclCreateAuxData _ANSI_ARGS_((ClientData clientData,			    AuxDataType *typePtr, CompileEnv *envPtr));EXTERN int		TclCreateExceptRange _ANSI_ARGS_((			    ExceptionRangeType type, CompileEnv *envPtr));EXTERN ExecEnv *	TclCreateExecEnv _ANSI_ARGS_((Tcl_Interp *interp));EXTERN void		TclDeleteExecEnv _ANSI_ARGS_((ExecEnv *eePtr));EXTERN void		TclDeleteLiteralTable _ANSI_ARGS_((			    Tcl_Interp *interp, LiteralTable *tablePtr));EXTERN void		TclEmitForwardJump _ANSI_ARGS_((CompileEnv *envPtr,			    TclJumpType jumpType, JumpFixup *jumpFixupPtr));EXTERN ExceptionRange *	TclGetExceptionRangeForPc _ANSI_ARGS_((			    unsigned char *pc, int catchOnly,			    ByteCode* codePtr));EXTERN void		TclExpandJumpFixupArray _ANSI_ARGS_((                            JumpFixupArray *fixupArrayPtr));EXTERN void		TclFinalizeAuxDataTypeTable _ANSI_ARGS_((void));EXTERN int		TclFindCompiledLocal _ANSI_ARGS_((CONST char *name,         		    int nameChars, int create, int flags,			    Proc *procPtr));EXTERN LiteralEntry *	TclLookupLiteralEntry _ANSI_ARGS_((			    Tcl_Interp *interp, Tcl_Obj *objPtr));EXTERN int		TclFixupForwardJump _ANSI_ARGS_((			    CompileEnv *envPtr, JumpFixup *jumpFixupPtr,			    int jumpDist, int distThreshold));EXTERN void		TclFreeCompileEnv _ANSI_ARGS_((CompileEnv *envPtr));EXTERN void		TclFreeJumpFixupArray _ANSI_ARGS_((  			    JumpFixupArray *fixupArrayPtr));EXTERN void		TclInitAuxDataTypeTable _ANSI_ARGS_((void));EXTERN void		TclInitByteCodeObj _ANSI_ARGS_((Tcl_Obj *objPtr,			    CompileEnv *envPtr));EXTERN void		TclInitCompilation _ANSI_ARGS_((void));EXTERN void		TclInitCompileEnv _ANSI_ARGS_((Tcl_Interp *interp,			    CompileEnv *envPtr, char *string,			    int numBytes));EXTERN void		TclInitJumpFixupArray _ANSI_ARGS_((			    JumpFixupArray *fixupArrayPtr));EXTERN void		TclInitLiteralTable _ANSI_ARGS_((			    LiteralTable *tablePtr));#ifdef TCL_COMPILE_STATSEXTERN char *		TclLiteralStats _ANSI_ARGS_((			    LiteralTable *tablePtr));EXTERN int		TclLog2 _ANSI_ARGS_((int value));#endif#ifdef TCL_COMPILE_DEBUGEXTERN void		TclPrintByteCodeObj _ANSI_ARGS_((Tcl_Interp *interp,		            Tcl_Obj *objPtr));#endifEXTERN int		TclPrintInstruction _ANSI_ARGS_((ByteCode* codePtr,			    unsigned char *pc));EXTERN void		TclPrintObject _ANSI_ARGS_((FILE *outFile,			    Tcl_Obj *objPtr, int maxChars));EXTERN void		TclPrintSource _ANSI_ARGS_((FILE *outFile,			    CONST char *string, int maxChars));EXTERN void		TclRegisterAuxDataType _ANSI_ARGS_((AuxDataType *typePtr));EXTERN int		TclRegisterLiteral _ANSI_ARGS_((CompileEnv *envPtr,			    char *bytes, int length, int onHeap));EXTERN void		TclReleaseLiteral _ANSI_ARGS_((Tcl_Interp *interp,			    Tcl_Obj *objPtr));EXTERN void		TclSetCmdNameObj _ANSI_ARGS_((Tcl_Interp *interp,			    Tcl_Obj *objPtr, Command *cmdPtr));#ifdef TCL_COMPILE_DEBUGEXTERN void		TclVerifyGlobalLiteralTable _ANSI_ARGS_((			    Interp *iPtr));EXTERN void		TclVerifyLocalLiteralTable _ANSI_ARGS_((			    CompileEnv *envPtr));#endifEXTERN int		TclCompileVariableCmd _ANSI_ARGS_((			    Tcl_Interp *interp, Tcl_Parse *parsePtr, CompileEnv *envPtr));/* *---------------------------------------------------------------- * Macros used by Tcl bytecode compilation and execution modules * inside the Tcl core but not used outside. *---------------------------------------------------------------- *//* * Form of TclRegisterLiteral with onHeap == 0. * In that case, it is safe to cast away CONSTness, and it * is cleanest to do that here, all in one place. */#define TclRegisterNewLiteral(envPtr, bytes, length) \	TclRegisterLiteral(envPtr, (char *)(bytes), length, /*onHeap*/ 0)/* * Macro used to update the stack requirements. * It is called by the macros TclEmitOpCode, TclEmitInst1 and * TclEmitInst4. * Remark that the very last instruction of a bytecode always * reduces the stack level: INST_DONE or INST_POP, so that the  * maxStackdepth is always updated. */#define TclUpdateStackReqs(op, i, envPtr) \    {\	int delta = tclInstructionTable[(op)].stackEffect;\	if (delta) {\	    if (delta < 0) {\		if((envPtr)->maxStackDepth < (envPtr)->currStackDepth) {\		    (envPtr)->maxStackDepth = (envPtr)->currStackDepth;\		}\		if (delta == INT_MIN) {\		    delta = 1 - (i);\		}\	    }\	    (envPtr)->currStackDepth += delta;\	}\    }/* * Macro to emit an opcode byte into a CompileEnv's code array. * The ANSI C "prototype" for this macro is: * * EXTERN void	TclEmitOpcode _ANSI_ARGS_((unsigned char op, *		    CompileEnv *envPtr)); */#define TclEmitOpcode(op, envPtr) \    if ((envPtr)->codeNext == (envPtr)->codeEnd) \        TclExpandCodeArray(envPtr); \    *(envPtr)->codeNext++ = (unsigned char) (op);\    TclUpdateStackReqs(op, 0, envPtr)/* * Macro to emit an integer operand. * The ANSI C "prototype" for this macro is: * * EXTERN void	TclEmitInt1 _ANSI_ARGS_((int i, CompileEnv *envPtr)); */#define TclEmitInt1(i, envPtr) \    if ((envPtr)->codeNext == (envPtr)->codeEnd) \        TclExpandCodeArray(envPtr); \    *(envPtr)->codeNext++ = (unsigned char) ((unsigned int) (i))/* * Macros to emit an instruction with signed or unsigned integer operands. * Four byte integers are stored in "big-endian" order with the high order * byte stored at the lowest address. * The ANSI C "prototypes" for these macros are: * * EXTERN void	TclEmitInstInt1 _ANSI_ARGS_((unsigned char op, int i,  *		    CompileEnv *envPtr)); * EXTERN void	TclEmitInstInt4 _ANSI_ARGS_((unsigned char op, int i,  *		    CompileEnv *envPtr)); */#define TclEmitInstInt1(op, i, envPtr) \    if (((envPtr)->codeNext + 2) > (envPtr)->codeEnd) { \        TclExpandCodeArray(envPtr); \    } \    *(envPtr)->codeNext++ = (unsigned char) (op); \    *(envPtr)->codeNext++ = (unsigned char) ((unsigned int) (i));\    TclUpdateStackReqs(op, i, envPtr)#define TclEmitInstInt4(op, i, envPtr) \    if (((envPtr)->codeNext + 5) > (envPtr)->codeEnd) { \        TclExpandCodeArray(envPtr); \    } \    *(envPtr)->codeNext++ = (unsigned char) (op); \    *(envPtr)->codeNext++ = \        (unsigned char) ((unsigned int) (i) >> 24); \    *(envPtr)->codeNext++ = \        (unsigned char) ((unsigned int) (i) >> 16); \    *(envPtr)->codeNext++ = \        (unsigned char) ((unsigned int) (i) >>  8); \    *(envPtr)->codeNext++ = \        (unsigned char) ((unsigned int) (i)      );\    TclUpdateStackReqs(op, i, envPtr)    /* * Macro to push a Tcl object onto the Tcl evaluation stack. It emits the * object's one or four byte array index into the CompileEnv's code * array. These support, respectively, a maximum of 256 (2**8) and 2**32 * objects in a CompileEnv. The ANSI C "prototype" for this macro is: * * EXTERN void	TclEmitPush _ANSI_ARGS_((int objIndex, CompileEnv *envPtr)); */#define TclEmitPush(objIndex, envPtr) \    {\        register int objIndexCopy = (objIndex);\        if (objIndexCopy <= 255) { \	    TclEmitInstInt1(INST_PUSH1, objIndexCopy, (envPtr)); \        } else { \	    TclEmitInstInt4(INST_PUSH4, objIndexCopy, (envPtr)); \	}\    }/* * Macros to update a (signed or unsigned) integer starting at a pointer. * The two variants depend on the number of bytes. The ANSI C "prototypes" * for these macros are: * * EXTERN void	TclStoreInt1AtPtr _ANSI_ARGS_((int i, unsigned char *p)); * EXTERN void	TclStoreInt4AtPtr _ANSI_ARGS_((int i, unsigned char *p)); */    #define TclStoreInt1AtPtr(i, p) \    *(p)   = (unsigned char) ((unsigned int) (i))    #define TclStoreInt4AtPtr(i, p) \    *(p)   = (unsigned char) ((unsigned int) (i) >> 24); \    *(p+1) = (unsigned char) ((unsigned int) (i) >> 16); \    *(p+2) = (unsigned char) ((unsigned int) (i) >>  8); \    *(p+3) = (unsigned char) ((unsigned int) (i)      )/* * Macros to update instructions at a particular pc with a new op code * and a (signed or unsigned) int operand. The ANSI C "prototypes" for * these macros are: * * EXTERN void	TclUpdateInstInt1AtPc _ANSI_ARGS_((unsigned char op, int i, *		    unsigned char *pc)); * EXTERN void	TclUpdateInstInt4AtPc _ANSI_ARGS_((unsigned char op, int i, *		    unsigned char *pc)); */#define TclUpdateInstInt1AtPc(op, i, pc) \    *(pc) = (unsigned char) (op); \    TclStoreInt1AtPtr((i), ((pc)+1))#define TclUpdateInstInt4AtPc(op, i, pc) \    *(pc) = (unsigned char) (op); \    TclStoreInt4AtPtr((i), ((pc)+1))    /* * Macros to get a signed integer (GET_INT{1,2}) or an unsigned int * (GET_UINT{1,2}) from a pointer. There are two variants for each * return type that depend on the number of bytes fetched. * The ANSI C "prototypes" for these macros are: * * EXTERN int	        TclGetInt1AtPtr  _ANSI_ARGS_((unsigned char *p)); * EXTERN int	        TclGetInt4AtPtr  _ANSI_ARGS_((unsigned char *p)); * EXTERN unsigned int	TclGetUInt1AtPtr _ANSI_ARGS_((unsigned char *p)); * EXTERN unsigned int	TclGetUInt4AtPtr _ANSI_ARGS_((unsigned char *p)); *//* * The TclGetInt1AtPtr macro is tricky because we want to do sign * extension on the 1-byte value. Unfortunately the "char" type isn't * signed on all platforms so sign-extension doesn't always happen * automatically. Sometimes we can explicitly declare the pointer to be * signed, but other times we have to explicitly sign-extend the value * in software. */#ifndef __CHAR_UNSIGNED__#   define TclGetInt1AtPtr(p) ((int) *((char *) p))#else#   ifdef HAVE_SIGNED_CHAR#	define TclGetInt1AtPtr(p) ((int) *((signed char *) p))#    else#	define TclGetInt1AtPtr(p) (((int) *((char *) p)) \		| ((*(p) & 0200) ? (-256) : 0))#    endif#endif#define TclGetInt4AtPtr(p) (((int) TclGetInt1AtPtr(p) << 24) | \		                  	    (*((p)+1) << 16) | \				  	    (*((p)+2) <<  8) | \				  	    (*((p)+3)))#define TclGetUInt1AtPtr(p) ((unsigned int) *(p))#define TclGetUInt4AtPtr(p) ((unsigned int) (*(p)     << 24) | \		                            (*((p)+1) << 16) | \				            (*((p)+2) <<  8) | \				            (*((p)+3)))/* * Macros used to compute the minimum and maximum of two integers. * The ANSI C "prototypes" for these macros are: * * EXTERN int  TclMin _ANSI_ARGS_((int i, int j)); * EXTERN int  TclMax _ANSI_ARGS_((int i, int j)); */#define TclMin(i, j)   ((((int) i) < ((int) j))? (i) : (j))#define TclMax(i, j)   ((((int) i) > ((int) j))? (i) : (j))# undef TCL_STORAGE_CLASS# define TCL_STORAGE_CLASS DLLIMPORT#endif /* _TCLCOMPILATION */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?