⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tclcompile.h

📁 linux系统下的音频通信
💻 H
📖 第 1 页 / 共 3 页
字号:
/* * tclCompile.h -- * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * SCCS: @(#) tclCompile.h 1.7 98/08/04 11:53:24 */#ifndef _TCLCOMPILATION#define _TCLCOMPILATION 1#ifndef _TCLINT#include "tclInt.h"#endif /* _TCLINT */#ifdef BUILD_tcl# undef TCL_STORAGE_CLASS# define TCL_STORAGE_CLASS DLLEXPORT#endif/* *------------------------------------------------------------------------ * Variables related to compilation. These are used in tclCompile.c, * tclExecute.c, tclBasic.c, and their clients. *------------------------------------------------------------------------ *//* * Variable that denotes the command name Tcl object type. Objects of this * type cache the Command pointer that results from looking up command names * in the command hashtable. */extern Tcl_ObjType	tclCmdNameType;/* * Variable that controls whether compilation tracing is enabled and, if so, * what level of tracing is desired: *    0: no compilation tracing *    1: summarize compilation of top level cmds and proc bodies *    2: display all instructions of each ByteCode compiled * This variable is linked to the Tcl variable "tcl_traceCompile". */extern int 		tclTraceCompile;/* * Variable that controls whether execution tracing is enabled and, if so, * what level of tracing is desired: *    0: no execution tracing *    1: trace invocations of Tcl procs only *    2: trace invocations of all (not compiled away) commands *    3: display each instruction executed * This variable is linked to the Tcl variable "tcl_traceExec". */extern int 		tclTraceExec;/* * The number of bytecode compilations and various other compilation-related * statistics. The tclByteCodeCount and tclSourceCount arrays are used to * hold the count of ByteCodes and sources whose sizes fall into various * binary decades; e.g., tclByteCodeCount[5] is a count of the ByteCodes * with size larger than 2**4 and less than or equal to 2**5. */#ifdef TCL_COMPILE_STATSextern long		tclNumCompilations;extern double		tclTotalSourceBytes;extern double		tclTotalCodeBytes;extern double		tclTotalInstBytes;extern double		tclTotalObjBytes;extern double		tclTotalExceptBytes;extern double		tclTotalAuxBytes;extern double		tclTotalCmdMapBytes;extern double		tclCurrentSourceBytes;extern double		tclCurrentCodeBytes;extern int		tclSourceCount[32];extern int		tclByteCodeCount[32];#endif /* TCL_COMPILE_STATS *//* *------------------------------------------------------------------------ * Data structures related to compilation. *------------------------------------------------------------------------ *//* * The structure used to implement Tcl "exceptions" (exceptional returns): * for example, those generated in loops by the break and continue commands, * and those generated by scripts and caught by the catch command. This * ExceptionRange structure describes a range of code (e.g., a loop body), * the kind of exceptions (e.g., a break or continue) that might occur, and * the PC offsets to jump to if a matching exception does occur. Exception * ranges can nest so this structure includes a nesting level that is used * at runtime to find the closest exception range surrounding a PC. For * example, when a break command is executed, the ExceptionRange structure * for the most deeply nested loop, if any, is found and used. These * structures are also generated for the "next" subcommands of for loops * since a break there terminates the for command. This means a for command * actually generates two LoopInfo structures. */typedef enum {    LOOP_EXCEPTION_RANGE,	/* Code range is part of a loop command.				 * break and continue "exceptions" cause				 * jumps to appropriate PC offsets. */    CATCH_EXCEPTION_RANGE	/* Code range is controlled by a catch				 * command. Errors in the range cause a				 * jump to a particular PC offset. */} ExceptionRangeType;typedef struct ExceptionRange {    ExceptionRangeType type;	/* The kind of ExceptionRange. */    int nestingLevel;		/* Static depth of the exception range.				 * Used to find the most deeply-nested				 * range surrounding a PC at runtime. */    int codeOffset;		/* Offset of the first instruction byte of				 * the code range. */    int numCodeBytes;		/* Number of bytes in the code range. */    int breakOffset;		/* If a LOOP_EXCEPTION_RANGE, the target				 * PC offset for a break command in the				 * range. */    int continueOffset;		/* If a LOOP_EXCEPTION_RANGE and not -1,				 * the target PC offset for a continue				 * command in the code range. Otherwise,				 * ignore this range when processing a				 * continue command. */    int catchOffset;		/* If a CATCH_EXCEPTION_RANGE, the target PC				 * offset for an "exception" in range. */} ExceptionRange;/* * Structure used to map between instruction pc and source locations. It * defines for each compiled Tcl command its code's starting offset and  * its source's starting offset and length. Note that the code offset * increases monotonically: that is, the table is sorted in code offset * order. The source offset is not monotonic. */typedef struct CmdLocation {    int codeOffset;		/* Offset of first byte of command code. */    int numCodeBytes;		/* Number of bytes for command's code. */    int srcOffset;		/* Offset of first char of the command. */    int numSrcChars;		/* Number of command source chars. */} CmdLocation;/* * CompileProcs need the ability to record information during compilation * that can be used by bytecode instructions during execution. The AuxData * structure provides this "auxiliary data" mechanism. An arbitrary number * of these structures can be stored in the ByteCode record (during * compilation they are stored in a CompileEnv structure). Each AuxData * record holds one word of client-specified data (often a pointer) and is * given an index that instructions can later use to look up the structure * and its data. * * The following definitions declare the types of procedures that are called * to duplicate or free this auxiliary data when the containing ByteCode * objects are duplicated and freed. Pointers to these procedures are kept * in the AuxData structure. */typedef ClientData (AuxDataDupProc)  _ANSI_ARGS_((ClientData clientData));typedef void       (AuxDataFreeProc) _ANSI_ARGS_((ClientData clientData));/* * We define a separate AuxDataType struct to hold type-related information * for the AuxData structure. This separation makes it possible for clients * outside of the TCL core to manipulate (in a limited fashion!) AuxData; * for example, it makes it possible to pickle and unpickle AuxData structs. */typedef struct AuxDataType {    char *name;					/* the name of the type. Types can be                                 * registered and found by name */    AuxDataDupProc *dupProc;	/* Callback procedure to invoke when the                                 * aux data is duplicated (e.g., when the                                 * ByteCode structure containing the aux                                 * data is duplicated). NULL means just                                 * copy the source clientData bits; no                                 * proc need be called. */    AuxDataFreeProc *freeProc;	/* Callback procedure to invoke when the                                 * aux data is freed. NULL means no                                 * proc need be called. */} AuxDataType;/* * The definition of the AuxData structure that holds information created * during compilation by CompileProcs and used by instructions during * execution. */typedef struct AuxData {    AuxDataType *type;		/* pointer to the AuxData type associated with                             * this ClientData. */    ClientData clientData;	/* The compilation data itself. */} AuxData;/* * Structure defining the compilation environment. After compilation, fields * describing bytecode instructions are copied out into the more compact * ByteCode structure defined below. */#define COMPILEENV_INIT_CODE_BYTES    250#define COMPILEENV_INIT_NUM_OBJECTS    40#define COMPILEENV_INIT_EXCEPT_RANGES   5#define COMPILEENV_INIT_CMD_MAP_SIZE   40#define COMPILEENV_INIT_AUX_DATA_SIZE   5typedef struct CompileEnv {    Interp *iPtr;		/* Interpreter containing the code being				 * compiled. Commands and their compile				 * procs are specific to an interpreter so				 * the code emitted will depend on the				 * interpreter. */    char *source;		/* The source string being compiled by				 * SetByteCodeFromAny. This pointer is not				 * owned by the CompileEnv and must not be				 * freed or changed by it. */    Proc *procPtr;		/* If a procedure is being compiled, a				 * pointer to its Proc structure; otherwise				 * NULL. Used to compile local variables.				 * Set from information provided by				 * ObjInterpProc in tclProc.c. */    int numCommands;		/* Number of commands compiled. */    int excRangeDepth;		/* Current exception range nesting level;				 * -1 if not in any range currently. */    int maxExcRangeDepth;	/* Max nesting level of exception ranges;				 * -1 if no ranges have been compiled. */    int maxStackDepth;		/* Maximum number of stack elements needed				 * to execute the code. Set by compilation				 * procedures before returning. */    Tcl_HashTable objTable;	/* Contains all Tcl objects referenced by				 * the compiled code. Indexed by the string				 * representations of the objects. Used to				 * avoid creating duplicate objects. */    int pushSimpleWords;	/* Set 1 by callers of compilation routines				 * if they should emit instructions to push				 * "simple" command words (those that are				 * just a sequence of characters). If 0, the				 * callers are responsible for compiling				 * simple words. */    int wordIsSimple;		/* Set 1 by compilation procedures before				 * returning if the previous command word				 * was just a sequence of characters,				 * otherwise 0. Used to help determine the				 * command being compiled. */    int numSimpleWordChars;	/* If wordIsSimple is 1 then the number of				 * characters in the simple word, else 0. */    int exprIsJustVarRef;	/* Set 1 if the expression last compiled by				 * TclCompileExpr consisted of just a				 * variable reference as in the expression				 * of "if $b then...". Otherwise 0. Used				 * to implement expr's 2 level substitution				 * semantics properly. */    int exprIsComparison;	/* Set 1 if the top-level operator in the				 * expression last compiled is a comparison.				 * Otherwise 0. If 1, since the operands				 * might be strings, the expr is compiled				 * out-of-line to implement expr's 2 level				 * substitution semantics properly. */    int termOffset;		/* Offset of character just after the last				 * one compiled. Set by compilation				 * procedures before returning. */    unsigned char *codeStart;	/* Points to the first byte of the code. */    unsigned char *codeNext;	/* Points to next code array byte to use. */    unsigned char *codeEnd;	/* Points just after the last allocated				 * code array byte. */    int mallocedCodeArray;      /* Set 1 if code array was expanded 				 * and codeStart points into the heap.*/    Tcl_Obj **objArrayPtr;	/* Points to start of object array. */    int objArrayNext;		/* Index of next free object array entry. */    int objArrayEnd;		/* Index just after last obj array entry. */    int mallocedObjArray;       /* 1 if object array was expanded and                                 * objArray points into the heap, else 0. */    ExceptionRange *excRangeArrayPtr;    				/* Points to start of the ExceptionRange				 * array. */    int excRangeArrayNext;	/* Next free ExceptionRange array index.				 * excRangeArrayNext is the number of ranges				 * and (excRangeArrayNext-1) is the index of				 * the current range's array entry. */    int excRangeArrayEnd;	/* Index after the last ExceptionRange				 * array entry. */    int mallocedExcRangeArray;	/* 1 if ExceptionRange array was expanded				 * and excRangeArrayPtr points in heap,				 * else 0. */    CmdLocation *cmdMapPtr;	/* Points to start of CmdLocation array.				 * numCommands is the index of the next				 * entry to use; (numCommands-1) is the				 * entry index for the last command. */    int cmdMapEnd;		/* Index after last CmdLocation entry. */    int mallocedCmdMap;		/* 1 if command map array was expanded and				 * cmdMapPtr points in the heap, else 0. */    AuxData *auxDataArrayPtr;   /* Points to auxiliary data array start. */    int auxDataArrayNext;	/* Next free compile aux data array index.				 * auxDataArrayNext is the number of aux				 * data items and (auxDataArrayNext-1) is				 * index of current aux data array entry. */    int auxDataArrayEnd;	/* Index after last aux data array entry. */    int mallocedAuxDataArray;	/* 1 if aux data array was expanded and				 * auxDataArrayPtr points in heap else 0. */    unsigned char staticCodeSpace[COMPILEENV_INIT_CODE_BYTES];                                /* Initial storage for code. */    Tcl_Obj *staticObjArraySpace[COMPILEENV_INIT_NUM_OBJECTS];                                /* Initial storage for object array. */    ExceptionRange staticExcRangeArraySpace[COMPILEENV_INIT_EXCEPT_RANGES];                                /* Initial ExceptionRange array storage. */    CmdLocation staticCmdMapSpace[COMPILEENV_INIT_CMD_MAP_SIZE];                                /* Initial storage for cmd location map. */    AuxData staticAuxDataArraySpace[COMPILEENV_INIT_AUX_DATA_SIZE];                                /* Initial storage for aux data array. */} CompileEnv;/* * The structure defining the bytecode instructions resulting from compiling * a Tcl script. Note that this structure is variable length: a single heap * object is allocated to hold the ByteCode structure immediately followed * by the code bytes, the object array, the ExceptionRange array, the * CmdLocation map, and the compilation AuxData array. *//* * A PRECOMPILED bytecode struct is one that was generated from a compiled * image rather than implicitly compiled from source */#define TCL_BYTECODE_PRECOMPILED		0x0001typedef struct ByteCode {    Interp *iPtr;		/* Interpreter containing the code being				 * compiled. Commands and their compile				 * procs are specific to an interpreter so				 * the code emitted will depend on the				 * interpreter. */    int compileEpoch;		/* Value of iPtr->compileEpoch when this				 * ByteCode was compiled. Used to invalidate				 * code when, e.g., commands with compile				 * procs are redefined. */    Namespace *nsPtr;		/* Namespace context in which this code				 * was compiled. If the code is executed				 * if a different namespace, it must be				 * recompiled. */    int nsEpoch;		/* Value of nsPtr->resolverEpoch when this				 * ByteCode was compiled. Used to invalidate

⌨️ 快捷键说明

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