tclInt.hGo to the documentation of this file.00001 /* 00002 * tclInt.h -- 00003 * 00004 * Declarations of things used internally by the Tcl interpreter. 00005 * 00006 * Copyright (c) 1987-1993 The Regents of the University of California. 00007 * Copyright (c) 1993-1997 Lucent Technologies. 00008 * Copyright (c) 1994-1998 Sun Microsystems, Inc. 00009 * Copyright (c) 1998-1999 by Scriptics Corporation. 00010 * Copyright (c) 2001, 2002 by Kevin B. Kenny. All rights reserved. 00011 * Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net> 00012 * 00013 * See the file "license.terms" for information on usage and redistribution of 00014 * this file, and for a DISCLAIMER OF ALL WARRANTIES. 00015 * 00016 * RCS: @(#) $Id: tclInt.h,v 1.362 2008/01/23 21:32:36 dgp Exp $ 00017 */ 00018 00019 #ifndef _TCLINT 00020 #define _TCLINT 00021 00022 /* 00023 * Some numerics configuration options 00024 */ 00025 00026 #undef NO_WIDE_TYPE 00027 #undef ACCEPT_NAN 00028 00029 /* 00030 * Common include files needed by most of the Tcl source files are included 00031 * here, so that system-dependent personalizations for the include files only 00032 * have to be made in once place. This results in a few extra includes, but 00033 * greater modularity. The order of the three groups of #includes is 00034 * important. For example, stdio.h is needed by tcl.h, and the _ANSI_ARGS_ 00035 * declaration in tcl.h is needed by stdlib.h in some configurations. 00036 */ 00037 00038 #ifdef HAVE_TCL_CONFIG_H 00039 #include "tclConfig.h" 00040 #endif 00041 #ifndef _TCL 00042 #include "tcl.h" 00043 #endif 00044 00045 #include <stdio.h> 00046 00047 #include <ctype.h> 00048 #ifdef NO_LIMITS_H 00049 # include "../compat/limits.h" 00050 #else 00051 # include <limits.h> 00052 #endif 00053 #ifdef NO_STDLIB_H 00054 # include "../compat/stdlib.h" 00055 #else 00056 # include <stdlib.h> 00057 #endif 00058 #ifdef NO_STRING_H 00059 #include "../compat/string.h" 00060 #else 00061 #include <string.h> 00062 #endif 00063 #ifdef STDC_HEADERS 00064 #include <stddef.h> 00065 #else 00066 typedef int ptrdiff_t; 00067 #endif 00068 00069 /* 00070 * Ensure WORDS_BIGENDIAN is defined correcly: 00071 * Needs to happen here in addition to configure to work with fat compiles on 00072 * Darwin (where configure runs only once for multiple architectures). 00073 */ 00074 00075 #ifdef HAVE_SYS_TYPES_H 00076 # include <sys/types.h> 00077 #endif 00078 #ifdef HAVE_SYS_PARAM_H 00079 # include <sys/param.h> 00080 #endif 00081 #ifdef BYTE_ORDER 00082 # ifdef BIG_ENDIAN 00083 # if BYTE_ORDER == BIG_ENDIAN 00084 # undef WORDS_BIGENDIAN 00085 # define WORDS_BIGENDIAN 1 00086 # endif 00087 # endif 00088 # ifdef LITTLE_ENDIAN 00089 # if BYTE_ORDER == LITTLE_ENDIAN 00090 # undef WORDS_BIGENDIAN 00091 # endif 00092 # endif 00093 #endif 00094 00095 /* 00096 * Used to tag functions that are only to be visible within the module being 00097 * built and not outside it (where this is supported by the linker). 00098 */ 00099 00100 #ifndef MODULE_SCOPE 00101 # ifdef __cplusplus 00102 # define MODULE_SCOPE extern "C" 00103 # else 00104 # define MODULE_SCOPE extern 00105 # endif 00106 #endif 00107 00108 /* 00109 * When Tcl_WideInt and long are the same type, there's no value in 00110 * having a tclWideIntType separate from the tclIntType. 00111 */ 00112 #ifdef TCL_WIDE_INT_IS_LONG 00113 #define NO_WIDE_TYPE 00114 #endif 00115 00116 /* 00117 * Macros used to cast between pointers and integers (e.g. when storing an int 00118 * in ClientData), on 64-bit architectures they avoid gcc warning about "cast 00119 * to/from pointer from/to integer of different size". 00120 */ 00121 00122 #if !defined(INT2PTR) && !defined(PTR2INT) 00123 # if defined(HAVE_INTPTR_T) || defined(intptr_t) 00124 # define INT2PTR(p) ((void*)(intptr_t)(p)) 00125 # define PTR2INT(p) ((int)(intptr_t)(p)) 00126 # else 00127 # define INT2PTR(p) ((void*)(p)) 00128 # define PTR2INT(p) ((int)(p)) 00129 # endif 00130 #endif 00131 #if !defined(UINT2PTR) && !defined(PTR2UINT) 00132 # if defined(HAVE_UINTPTR_T) || defined(uintptr_t) 00133 # define UINT2PTR(p) ((void*)(uintptr_t)(p)) 00134 # define PTR2UINT(p) ((unsigned int)(uintptr_t)(p)) 00135 # else 00136 # define UINT2PTR(p) ((void*)(p)) 00137 # define PTR2UINT(p) ((unsigned int)(p)) 00138 # endif 00139 #endif 00140 00141 /* 00142 * The following procedures allow namespaces to be customized to support 00143 * special name resolution rules for commands/variables. 00144 */ 00145 00146 struct Tcl_ResolvedVarInfo; 00147 00148 typedef Tcl_Var (Tcl_ResolveRuntimeVarProc)(Tcl_Interp *interp, 00149 struct Tcl_ResolvedVarInfo *vinfoPtr); 00150 00151 typedef void (Tcl_ResolveVarDeleteProc)(struct Tcl_ResolvedVarInfo *vinfoPtr); 00152 00153 /* 00154 * The following structure encapsulates the routines needed to resolve a 00155 * variable reference at runtime. Any variable specific state will typically 00156 * be appended to this structure. 00157 */ 00158 00159 typedef struct Tcl_ResolvedVarInfo { 00160 Tcl_ResolveRuntimeVarProc *fetchProc; 00161 Tcl_ResolveVarDeleteProc *deleteProc; 00162 } Tcl_ResolvedVarInfo; 00163 00164 typedef int (Tcl_ResolveCompiledVarProc) (Tcl_Interp *interp, 00165 CONST84 char *name, int length, Tcl_Namespace *context, 00166 Tcl_ResolvedVarInfo **rPtr); 00167 00168 typedef int (Tcl_ResolveVarProc) (Tcl_Interp *interp, CONST84 char *name, 00169 Tcl_Namespace *context, int flags, Tcl_Var *rPtr); 00170 00171 typedef int (Tcl_ResolveCmdProc) (Tcl_Interp *interp, CONST84 char *name, 00172 Tcl_Namespace *context, int flags, Tcl_Command *rPtr); 00173 00174 typedef struct Tcl_ResolverInfo { 00175 Tcl_ResolveCmdProc *cmdResProc; 00176 /* Procedure handling command name 00177 * resolution. */ 00178 Tcl_ResolveVarProc *varResProc; 00179 /* Procedure handling variable name resolution 00180 * for variables that can only be handled at 00181 * runtime. */ 00182 Tcl_ResolveCompiledVarProc *compiledVarResProc; 00183 /* Procedure handling variable name resolution 00184 * at compile time. */ 00185 } Tcl_ResolverInfo; 00186 00187 /* 00188 *---------------------------------------------------------------- 00189 * Data structures related to namespaces. 00190 *---------------------------------------------------------------- 00191 */ 00192 00193 typedef struct Tcl_Ensemble Tcl_Ensemble; 00194 typedef struct NamespacePathEntry NamespacePathEntry; 00195 00196 /* 00197 * Special hashtable for variables: this is just a Tcl_HashTable with an nsPtr 00198 * field added at the end: in this way variables can find their namespace 00199 * without having to copy a pointer in their struct: they can access it via 00200 * their hPtr->tablePtr. 00201 */ 00202 00203 typedef struct TclVarHashTable { 00204 Tcl_HashTable table; 00205 struct Namespace *nsPtr; 00206 } TclVarHashTable; 00207 00208 /* 00209 * This is for itcl - it likes to search our varTables directly :( 00210 */ 00211 00212 #define TclVarHashFindVar(tablePtr, key) \ 00213 TclVarHashCreateVar((tablePtr), (key), NULL) 00214 00215 00216 /* 00217 * The structure below defines a namespace. 00218 * Note: the first five fields must match exactly the fields in a 00219 * Tcl_Namespace structure (see tcl.h). If you change one, be sure to change 00220 * the other. 00221 */ 00222 00223 typedef struct Namespace { 00224 char *name; /* The namespace's simple (unqualified) name. 00225 * This contains no ::'s. The name of the 00226 * global namespace is "" although "::" is an 00227 * synonym. */ 00228 char *fullName; /* The namespace's fully qualified name. This 00229 * starts with ::. */ 00230 ClientData clientData; /* An arbitrary value associated with this 00231 * namespace. */ 00232 Tcl_NamespaceDeleteProc *deleteProc; 00233 /* Procedure invoked when deleting the 00234 * namespace to, e.g., free clientData. */ 00235 struct Namespace *parentPtr;/* Points to the namespace that contains this 00236 * one. NULL if this is the global 00237 * namespace. */ 00238 Tcl_HashTable childTable; /* Contains any child namespaces. Indexed by 00239 * strings; values have type (Namespace *). */ 00240 long nsId; /* Unique id for the namespace. */ 00241 Tcl_Interp *interp; /* The interpreter containing this 00242 * namespace. */ 00243 int flags; /* OR-ed combination of the namespace status 00244 * flags NS_DYING and NS_DEAD listed below. */ 00245 int activationCount; /* Number of "activations" or active call 00246 * frames for this namespace that are on the 00247 * Tcl call stack. The namespace won't be 00248 * freed until activationCount becomes zero. */ 00249 int refCount; /* Count of references by namespaceName 00250 * objects. The namespace can't be freed until 00251 * refCount becomes zero. */ 00252 Tcl_HashTable cmdTable; /* Contains all the commands currently 00253 * registered in the namespace. Indexed by 00254 * strings; values have type (Command *). 00255 * Commands imported by Tcl_Import have 00256 * Command structures that point (via an 00257 * ImportedCmdRef structure) to the Command 00258 * structure in the source namespace's command 00259 * table. */ 00260 TclVarHashTable varTable; /* Contains all the (global) variables 00261 * currently in this namespace. Indexed by 00262 * strings; values have type (Var *). */ 00263 char **exportArrayPtr; /* Points to an array of string patterns 00264 * specifying which commands are exported. A 00265 * pattern may include "string match" style 00266 * wildcard characters to specify multiple 00267 * commands; however, no namespace qualifiers 00268 * are allowed. NULL if no export patterns are 00269 * registered. */ 00270 int numExportPatterns; /* Number of export patterns currently 00271 * registered using "namespace export". */ 00272 int maxExportPatterns; /* Mumber of export patterns for which space 00273 * is currently allocated. */ 00274 int cmdRefEpoch; /* Incremented if a newly added command 00275 * shadows a command for which this namespace 00276 * has already cached a Command * pointer; 00277 * this causes all its cached Command* 00278 * pointers to be invalidated. */ 00279 int resolverEpoch; /* Incremented whenever (a) the name 00280 * resolution rules change for this namespace 00281 * or (b) a newly added command shadows a 00282 * command that is compiled to bytecodes. This 00283 * invalidates all byte codes compiled in the 00284 * namespace, causing the code to be 00285 * recompiled under the new rules.*/ 00286 Tcl_ResolveCmdProc *cmdResProc; 00287 /* If non-null, this procedure overrides the 00288 * usual command resolution mechanism in Tcl. 00289 * This procedure is invoked within 00290 * Tcl_FindCommand to resolve all command 00291 * references within the namespace. */ 00292 Tcl_ResolveVarProc *varResProc; 00293 /* If non-null, this procedure overrides the 00294 * usual variable resolution mechanism in Tcl. 00295 * This procedure is invoked within 00296 * Tcl_FindNamespaceVar to resolve all 00297 * variable references within the namespace at 00298 * runtime. */ 00299 Tcl_ResolveCompiledVarProc *compiledVarResProc; 00300 /* If non-null, this procedure overrides the 00301 * usual variable resolution mechanism in Tcl. 00302 * This procedure is invoked within 00303 * LookupCompiledLocal to resolve variable 00304 * references within the namespace at compile 00305 * time. */ 00306 int exportLookupEpoch; /* Incremented whenever a command is added to 00307 * a namespace, removed from a namespace or 00308 * the exports of a namespace are changed. 00309 * Allows TIP#112-driven command lists to be 00310 * validated efficiently. */ 00311 Tcl_Ensemble *ensembles; /* List of structures that contain the details 00312 * of the ensembles that are implemented on 00313 * top of this namespace. */ 00314 Tcl_Obj *unknownHandlerPtr; /* A script fragment to be used when command 00315 * resolution in this namespace fails. TIP 00316 * 181. */ 00317 int commandPathLength; /* The length of the explicit path. */ 00318 NamespacePathEntry *commandPathArray; 00319 /* The explicit path of the namespace as an 00320 * array. */ 00321 NamespacePathEntry *commandPathSourceList; 00322 /* Linked list of path entries that point to 00323 * this namespace. */ 00324 } Namespace; 00325 00326 /* 00327 * An entry on a namespace's command resolution path. 00328 */ 00329 00330 struct NamespacePathEntry { 00331 Namespace *nsPtr; /* What does this path entry point to? If it 00332 * is NULL, this path entry points is 00333 * redundant and should be skipped. */ 00334 Namespace *creatorNsPtr; /* Where does this path entry point from? This 00335 * allows for efficient invalidation of 00336 * references when the path entry's target 00337 * updates its current list of defined 00338 * commands. */ 00339 NamespacePathEntry *prevPtr, *nextPtr; 00340 /* Linked list pointers or NULL at either end 00341 * of the list that hangs off Namespace's 00342 * commandPathSourceList field. */ 00343 }; 00344 00345 /* 00346 * Flags used to represent the status of a namespace: 00347 * 00348 * NS_DYING - 1 means Tcl_DeleteNamespace has been called to delete the 00349 * namespace but there are still active call frames on the Tcl 00350 * stack that refer to the namespace. When the last call frame 00351 * referring to it has been popped, it's variables and command 00352 * will be destroyed and it will be marked "dead" (NS_DEAD). The 00353 * namespace can no longer be looked up by name. 00354 * NS_DEAD - 1 means Tcl_DeleteNamespace has been called to delete the 00355 * namespace and no call frames still refer to it. Its variables 00356 * and command have already been destroyed. This bit allows the 00357 * namespace resolution code to recognize that the namespace is 00358 * "deleted". When the last namespaceName object in any byte code 00359 * unit that refers to the namespace has been freed (i.e., when 00360 * the namespace's refCount is 0), the namespace's storage will 00361 * be freed. 00362 * NS_KILLED 1 means that TclTeardownNamespace has already been called on 00363 * this namespace and it should not be called again [Bug 1355942] 00364 */ 00365 00366 #define NS_DYING 0x01 00367 #define NS_DEAD 0x02 00368 #define NS_KILLED 0x04 00369 00370 /* 00371 * Flags passed to TclGetNamespaceForQualName: 00372 * 00373 * TCL_GLOBAL_ONLY - (see tcl.h) Look only in the global ns. 00374 * TCL_NAMESPACE_ONLY - (see tcl.h) Look only in the context ns. 00375 * TCL_CREATE_NS_IF_UNKNOWN - Create unknown namespaces. 00376 * TCL_FIND_ONLY_NS - The name sought is a namespace name. 00377 */ 00378 00379 #define TCL_CREATE_NS_IF_UNKNOWN 0x800 00380 #define TCL_FIND_ONLY_NS 0x1000 00381 00382 /* 00383 * The data cached in an ensemble subcommand's Tcl_Obj rep (reference in 00384 * otherValuePtr field). This structure is not shared between Tcl_Objs 00385 * referring to the same subcommand, even where one is a duplicate of another. 00386 */ 00387 00388 typedef struct { 00389 Namespace *nsPtr; /* The namespace backing the ensemble which 00390 * this is a subcommand of. */ 00391 int epoch; /* Used to confirm when the data in this 00392 * really structure matches up with the 00393 * ensemble. */ 00394 Tcl_Command token; /* Reference to the comamnd for which this 00395 * structure is a cache of the resolution. */ 00396 char *fullSubcmdName; /* The full (local) name of the subcommand, 00397 * allocated with ckalloc(). */ 00398 Tcl_Obj *realPrefixObj; /* Object containing the prefix words of the 00399 * command that implements this ensemble 00400 * subcommand. */ 00401 } EnsembleCmdRep; 00402 00403 /* 00404 * Flag to enable bytecode compilation of an ensemble. 00405 */ 00406 00407 #define ENSEMBLE_COMPILE 0x4 00408 00409 /* 00410 *---------------------------------------------------------------- 00411 * Data structures related to variables. These are used primarily in tclVar.c 00412 *---------------------------------------------------------------- 00413 */ 00414 00415 /* 00416 * The following structure defines a variable trace, which is used to invoke a 00417 * specific C procedure whenever certain operations are performed on a 00418 * variable. 00419 */ 00420 00421 typedef struct VarTrace { 00422 Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given by 00423 * flags are performed on variable. */ 00424 ClientData clientData; /* Argument to pass to proc. */ 00425 int flags; /* What events the trace procedure is 00426 * interested in: OR-ed combination of 00427 * TCL_TRACE_READS, TCL_TRACE_WRITES, 00428 * TCL_TRACE_UNSETS and TCL_TRACE_ARRAY. */ 00429 struct VarTrace *nextPtr; /* Next in list of traces associated with a 00430 * particular variable. */ 00431 } VarTrace; 00432 00433 /* 00434 * The following structure defines a command trace, which is used to invoke a 00435 * specific C procedure whenever certain operations are performed on a 00436 * command. 00437 */ 00438 00439 typedef struct CommandTrace { 00440 Tcl_CommandTraceProc *traceProc; 00441 /* Procedure to call when operations given by 00442 * flags are performed on command. */ 00443 ClientData clientData; /* Argument to pass to proc. */ 00444 int flags; /* What events the trace procedure is 00445 * interested in: OR-ed combination of 00446 * TCL_TRACE_RENAME, TCL_TRACE_DELETE. */ 00447 struct CommandTrace *nextPtr; 00448 /* Next in list of traces associated with a 00449 * particular command. */ 00450 int refCount; /* Used to ensure this structure is not 00451 * deleted too early. Keeps track of how many 00452 * pieces of code have a pointer to this 00453 * structure. */ 00454 } CommandTrace; 00455 00456 /* 00457 * When a command trace is active (i.e. its associated procedure is executing) 00458 * one of the following structures is linked into a list associated with the 00459 * command's interpreter. The information in the structure is needed in order 00460 * for Tcl to behave reasonably if traces are deleted while traces are active. 00461 */ 00462 00463 typedef struct ActiveCommandTrace { 00464 struct Command *cmdPtr; /* Command that's being traced. */ 00465 struct ActiveCommandTrace *nextPtr; 00466 /* Next in list of all active command traces 00467 * for the interpreter, or NULL if no more. */ 00468 CommandTrace *nextTracePtr; /* Next trace to check after current trace 00469 * procedure returns; if this trace gets 00470 * deleted, must update pointer to avoid using 00471 * free'd memory. */ 00472 int reverseScan; /* Boolean set true when traces are scanning 00473 * in reverse order. */ 00474 } ActiveCommandTrace; 00475 00476 /* 00477 * When a variable trace is active (i.e. its associated procedure is 00478 * executing) one of the following structures is linked into a list associated 00479 * with the variable's interpreter. The information in the structure is needed 00480 * in order for Tcl to behave reasonably if traces are deleted while traces 00481 * are active. 00482 */ 00483 00484 typedef struct ActiveVarTrace { 00485 struct Var *varPtr; /* Variable that's being traced. */ 00486 struct ActiveVarTrace *nextPtr; 00487 /* Next in list of all active variable traces 00488 * for the interpreter, or NULL if no more. */ 00489 VarTrace *nextTracePtr; /* Next trace to check after current trace 00490 * procedure returns; if this trace gets 00491 * deleted, must update pointer to avoid using 00492 * free'd memory. */ 00493 } ActiveVarTrace; 00494 00495 /* 00496 * The following structure describes an enumerative search in progress on an 00497 * array variable; this are invoked with options to the "array" command. 00498 */ 00499 00500 typedef struct ArraySearch { 00501 int id; /* Integer id used to distinguish among 00502 * multiple concurrent searches for the same 00503 * array. */ 00504 struct Var *varPtr; /* Pointer to array variable that's being 00505 * searched. */ 00506 Tcl_HashSearch search; /* Info kept by the hash module about progress 00507 * through the array. */ 00508 Tcl_HashEntry *nextEntry; /* Non-null means this is the next element to 00509 * be enumerated (it's leftover from the 00510 * Tcl_FirstHashEntry call or from an "array 00511 * anymore" command). NULL means must call 00512 * Tcl_NextHashEntry to get value to 00513 * return. */ 00514 struct ArraySearch *nextPtr;/* Next in list of all active searches for 00515 * this variable, or NULL if this is the last 00516 * one. */ 00517 } ArraySearch; 00518 00519 /* 00520 * The structure below defines a variable, which associates a string name with 00521 * a Tcl_Obj value. These structures are kept in procedure call frames (for 00522 * local variables recognized by the compiler) or in the heap (for global 00523 * variables and any variable not known to the compiler). For each Var 00524 * structure in the heap, a hash table entry holds the variable name and a 00525 * pointer to the Var structure. 00526 */ 00527 00528 typedef struct Var { 00529 int flags; /* Miscellaneous bits of information about 00530 * variable. See below for definitions. */ 00531 union { 00532 Tcl_Obj *objPtr; /* The variable's object value. Used for 00533 * scalar variables and array elements. */ 00534 TclVarHashTable *tablePtr;/* For array variables, this points to 00535 * information about the hash table used to 00536 * implement the associative array. Points to 00537 * ckalloc-ed data. */ 00538 struct Var *linkPtr; /* If this is a global variable being referred 00539 * to in a procedure, or a variable created by 00540 * "upvar", this field points to the 00541 * referenced variable's Var struct. */ 00542 } value; 00543 } Var; 00544 00545 typedef struct VarInHash { 00546 Var var; 00547 int refCount; /* Counts number of active uses of this 00548 * variable: 1 for the entry in the hash 00549 * table, 1 for each additional variable whose 00550 * linkPtr points here, 1 for each nested 00551 * trace active on variable, and 1 if the 00552 * variable is a namespace variable. This 00553 * record can't be deleted until refCount 00554 * becomes 0. */ 00555 Tcl_HashEntry entry; /* The hash table entry that refers to this 00556 * variable. This is used to find the name of 00557 * the variable and to delete it from its 00558 * hashtable if it is no longer needed. It 00559 * also holds the variable's name. */ 00560 } VarInHash; 00561 00562 /* 00563 * Flag bits for variables. The first two (VAR_ARRAY and VAR_LINK) are 00564 * mutually exclusive and give the "type" of the variable. If none is set, 00565 * this is a scalar variable. 00566 * 00567 * VAR_ARRAY - 1 means this is an array variable rather than 00568 * a scalar variable or link. The "tablePtr" 00569 * field points to the array's hashtable for its 00570 * elements. 00571 * VAR_LINK - 1 means this Var structure contains a pointer 00572 * to another Var structure that either has the 00573 * real value or is itself another VAR_LINK 00574 * pointer. Variables like this come about 00575 * through "upvar" and "global" commands, or 00576 * through references to variables in enclosing 00577 * namespaces. 00578 * 00579 * Flags that indicate the type and status of storage; none is set for 00580 * compiled local variables (Var structs). 00581 * 00582 * VAR_IN_HASHTABLE - 1 means this variable is in a hashtable and 00583 * the Var structure is malloced. 0 if it is a 00584 * local variable that was assigned a slot in a 00585 * procedure frame by the compiler so the Var 00586 * storage is part of the call frame. 00587 * VAR_DEAD_HASH 1 means that this var's entry in the hashtable 00588 * has already been deleted. 00589 * VAR_ARRAY_ELEMENT - 1 means that this variable is an array 00590 * element, so it is not legal for it to be an 00591 * array itself (the VAR_ARRAY flag had better 00592 * not be set). 00593 * VAR_NAMESPACE_VAR - 1 means that this variable was declared as a 00594 * namespace variable. This flag ensures it 00595 * persists until its namespace is destroyed or 00596 * until the variable is unset; it will persist 00597 * even if it has not been initialized and is 00598 * marked undefined. The variable's refCount is 00599 * incremented to reflect the "reference" from 00600 * its namespace. 00601 * 00602 * Flag values relating to the variable's trace and search status. 00603 * 00604 * VAR_TRACED_READ 00605 * VAR_TRACED_WRITE 00606 * VAR_TRACED_UNSET 00607 * VAR_TRACED_ARRAY 00608 * VAR_TRACE_ACTIVE - 1 means that trace processing is currently 00609 * underway for a read or write access, so new 00610 * read or write accesses should not cause trace 00611 * procedures to be called and the variable can't 00612 * be deleted. 00613 * VAR_SEARCH_ACTIVE 00614 * 00615 * The following additional flags are used with the CompiledLocal type defined 00616 * below: 00617 * 00618 * VAR_ARGUMENT - 1 means that this variable holds a procedure 00619 * argument. 00620 * VAR_TEMPORARY - 1 if the local variable is an anonymous 00621 * temporary variable. Temporaries have a NULL 00622 * name. 00623 * VAR_RESOLVED - 1 if name resolution has been done for this 00624 * variable. 00625 * VAR_IS_ARGS 1 if this variable is the last argument and is 00626 * named "args". 00627 */ 00628 00629 /* 00630 * FLAGS RENUMBERED: everything breaks already, make things simpler. 00631 * 00632 * IMPORTANT: skip the values 0x10, 0x20, 0x40, 0x800 corresponding to 00633 * TCL_TRACE_(READS/WRITES/UNSETS/ARRAY): makes code simpler in tclTrace.c 00634 * 00635 * Keep the flag values for VAR_ARGUMENT and VAR_TEMPORARY so that old values 00636 * in precompiled scripts keep working. 00637 */ 00638 00639 00640 /* Type of value (0 is scalar) */ 00641 #define VAR_ARRAY 0x1 00642 #define VAR_LINK 0x2 00643 00644 /* Type of storage (0 is compiled local) */ 00645 #define VAR_IN_HASHTABLE 0x4 00646 #define VAR_DEAD_HASH 0x8 00647 #define VAR_ARRAY_ELEMENT 0x1000 00648 #define VAR_NAMESPACE_VAR 0x80 /* KEEP OLD VALUE for Itcl */ 00649 00650 #define VAR_ALL_HASH \ 00651 (VAR_IN_HASHTABLE|VAR_DEAD_HASH|VAR_NAMESPACE_VAR|VAR_ARRAY_ELEMENT) 00652 00653 /* Trace and search state */ 00654 00655 #define VAR_TRACED_READ 0x10 /* TCL_TRACE_READS */ 00656 #define VAR_TRACED_WRITE 0x20 /* TCL_TRACE_WRITES */ 00657 #define VAR_TRACED_UNSET 0x40 /* TCL_TRACE_UNSETS */ 00658 #define VAR_TRACED_ARRAY 0x800 /* TCL_TRACE_ARRAY */ 00659 #define VAR_TRACE_ACTIVE 0x2000 00660 #define VAR_SEARCH_ACTIVE 0x4000 00661 #define VAR_ALL_TRACES \ 00662 (VAR_TRACED_READ|VAR_TRACED_WRITE|VAR_TRACED_ARRAY|VAR_TRACED_UNSET) 00663 00664 00665 /* Special handling on initialisation (only CompiledLocal) */ 00666 #define VAR_ARGUMENT 0x100 /* KEEP OLD VALUE! See tclProc.c */ 00667 #define VAR_TEMPORARY 0x200 /* KEEP OLD VALUE! See tclProc.c */ 00668 #define VAR_IS_ARGS 0x400 00669 #define VAR_RESOLVED 0x8000 00670 00671 /* 00672 * Macros to ensure that various flag bits are set properly for variables. 00673 * The ANSI C "prototypes" for these macros are: 00674 * 00675 * MODULE_SCOPE void TclSetVarScalar(Var *varPtr); 00676 * MODULE_SCOPE void TclSetVarArray(Var *varPtr); 00677 * MODULE_SCOPE void TclSetVarLink(Var *varPtr); 00678 * MODULE_SCOPE void TclSetVarArrayElement(Var *varPtr); 00679 * MODULE_SCOPE void TclSetVarUndefined(Var *varPtr); 00680 * MODULE_SCOPE void TclClearVarUndefined(Var *varPtr); 00681 */ 00682 00683 #define TclSetVarScalar(varPtr) \ 00684 (varPtr)->flags &= ~(VAR_ARRAY|VAR_LINK) 00685 00686 #define TclSetVarArray(varPtr) \ 00687 (varPtr)->flags = ((varPtr)->flags & ~VAR_LINK) | VAR_ARRAY 00688 00689 #define TclSetVarLink(varPtr) \ 00690 (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_LINK 00691 00692 #define TclSetVarArrayElement(varPtr) \ 00693 (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT 00694 00695 #define TclSetVarUndefined(varPtr) \ 00696 (varPtr)->flags &= ~(VAR_ARRAY|VAR_LINK);\ 00697 (varPtr)->value.objPtr = NULL 00698 00699 #define TclClearVarUndefined(varPtr) 00700 00701 #define TclSetVarTraceActive(varPtr) \ 00702 (varPtr)->flags |= VAR_TRACE_ACTIVE 00703 00704 #define TclClearVarTraceActive(varPtr) \ 00705 (varPtr)->flags &= ~VAR_TRACE_ACTIVE 00706 00707 #define TclSetVarNamespaceVar(varPtr) \ 00708 if (!TclIsVarNamespaceVar(varPtr)) {\ 00709 (varPtr)->flags |= VAR_NAMESPACE_VAR;\ 00710 ((VarInHash *)(varPtr))->refCount++;\ 00711 } 00712 00713 #define TclClearVarNamespaceVar(varPtr) \ 00714 if (TclIsVarNamespaceVar(varPtr)) {\ 00715 (varPtr)->flags &= ~VAR_NAMESPACE_VAR;\ 00716 ((VarInHash *)(varPtr))->refCount--;\ 00717 } 00718 00719 /* 00720 * Macros to read various flag bits of variables. 00721 * The ANSI C "prototypes" for these macros are: 00722 * 00723 * MODULE_SCOPE int TclIsVarScalar(Var *varPtr); 00724 * MODULE_SCOPE int TclIsVarLink(Var *varPtr); 00725 * MODULE_SCOPE int TclIsVarArray(Var *varPtr); 00726 * MODULE_SCOPE int TclIsVarUndefined(Var *varPtr); 00727 * MODULE_SCOPE int TclIsVarArrayElement(Var *varPtr); 00728 * MODULE_SCOPE int TclIsVarTemporary(Var *varPtr); 00729 * MODULE_SCOPE int TclIsVarArgument(Var *varPtr); 00730 * MODULE_SCOPE int TclIsVarResolved(Var *varPtr); 00731 */ 00732 00733 #define TclIsVarScalar(varPtr) \ 00734 !((varPtr)->flags & (VAR_ARRAY|VAR_LINK)) 00735 00736 #define TclIsVarLink(varPtr) \ 00737 ((varPtr)->flags & VAR_LINK) 00738 00739 #define TclIsVarArray(varPtr) \ 00740 ((varPtr)->flags & VAR_ARRAY) 00741 00742 #define TclIsVarUndefined(varPtr) \ 00743 ((varPtr)->value.objPtr == NULL) 00744 00745 #define TclIsVarArrayElement(varPtr) \ 00746 ((varPtr)->flags & VAR_ARRAY_ELEMENT) 00747 00748 #define TclIsVarNamespaceVar(varPtr) \ 00749 ((varPtr)->flags & VAR_NAMESPACE_VAR) 00750 00751 #define TclIsVarTemporary(varPtr) \ 00752 ((varPtr)->flags & VAR_TEMPORARY) 00753 00754 #define TclIsVarArgument(varPtr) \ 00755 ((varPtr)->flags & VAR_ARGUMENT) 00756 00757 #define TclIsVarResolved(varPtr) \ 00758 ((varPtr)->flags & VAR_RESOLVED) 00759 00760 #define TclIsVarTraceActive(varPtr) \ 00761 ((varPtr)->flags & VAR_TRACE_ACTIVE) 00762 00763 #define TclIsVarTraced(varPtr) \ 00764 ((varPtr)->flags & VAR_ALL_TRACES) 00765 00766 #define TclIsVarInHash(varPtr) \ 00767 ((varPtr)->flags & VAR_IN_HASHTABLE) 00768 00769 #define TclIsVarDeadHash(varPtr) \ 00770 ((varPtr)->flags & VAR_DEAD_HASH) 00771 00772 #define TclGetVarNsPtr(varPtr) \ 00773 (TclIsVarInHash(varPtr) \ 00774 ? ((TclVarHashTable *) ((((VarInHash *) (varPtr))->entry.tablePtr)))->nsPtr \ 00775 : NULL) 00776 00777 #define VarHashRefCount(varPtr) \ 00778 ((VarInHash *) (varPtr))->refCount 00779 00780 /* 00781 * Macros for direct variable access by TEBC 00782 */ 00783 00784 #define TclIsVarDirectReadable(varPtr) \ 00785 ( !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_READ)) \ 00786 && (varPtr)->value.objPtr) 00787 00788 #define TclIsVarDirectWritable(varPtr) \ 00789 !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_WRITE|VAR_DEAD_HASH)) 00790 00791 #define TclIsVarDirectModifyable(varPtr) \ 00792 ( !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_READ|VAR_TRACED_WRITE)) \ 00793 && (varPtr)->value.objPtr) 00794 00795 #define TclIsVarDirectReadable2(varPtr, arrayPtr) \ 00796 (TclIsVarDirectReadable(varPtr) &&\ 00797 (!(arrayPtr) || !((arrayPtr)->flags & VAR_TRACED_READ))) 00798 00799 #define TclIsVarDirectWritable2(varPtr, arrayPtr) \ 00800 (TclIsVarDirectWritable(varPtr) &&\ 00801 (!(arrayPtr) || !((arrayPtr)->flags & VAR_TRACED_WRITE))) 00802 00803 #define TclIsVarDirectModifyable2(varPtr, arrayPtr) \ 00804 (TclIsVarDirectModifyable(varPtr) &&\ 00805 (!(arrayPtr) || !((arrayPtr)->flags & (VAR_TRACED_READ|VAR_TRACED_WRITE)))) 00806 00807 00808 /* 00809 *---------------------------------------------------------------- 00810 * Data structures related to procedures. These are used primarily in 00811 * tclProc.c, tclCompile.c, and tclExecute.c. 00812 *---------------------------------------------------------------- 00813 */ 00814 00815 /* 00816 * Forward declaration to prevent an error when the forward reference to 00817 * Command is encountered in the Proc and ImportRef types declared below. 00818 */ 00819 00820 struct Command; 00821 00822 /* 00823 * The variable-length structure below describes a local variable of a 00824 * procedure that was recognized by the compiler. These variables have a name, 00825 * an element in the array of compiler-assigned local variables in the 00826 * procedure's call frame, and various other items of information. If the 00827 * local variable is a formal argument, it may also have a default value. The 00828 * compiler can't recognize local variables whose names are expressions (these 00829 * names are only known at runtime when the expressions are evaluated) or 00830 * local variables that are created as a result of an "upvar" or "uplevel" 00831 * command. These other local variables are kept separately in a hash table in 00832 * the call frame. 00833 */ 00834 00835 typedef struct CompiledLocal { 00836 struct CompiledLocal *nextPtr; 00837 /* Next compiler-recognized local variable for 00838 * this procedure, or NULL if this is the last 00839 * local. */ 00840 int nameLength; /* The number of characters in local 00841 * variable's name. Used to speed up variable 00842 * lookups. */ 00843 int frameIndex; /* Index in the array of compiler-assigned 00844 * variables in the procedure call frame. */ 00845 int flags; /* Flag bits for the local variable. Same as 00846 * the flags for the Var structure above, 00847 * although only VAR_ARGUMENT, VAR_TEMPORARY, 00848 * and VAR_RESOLVED make sense. */ 00849 Tcl_Obj *defValuePtr; /* Pointer to the default value of an 00850 * argument, if any. NULL if not an argument 00851 * or, if an argument, no default value. */ 00852 Tcl_ResolvedVarInfo *resolveInfo; 00853 /* Customized variable resolution info 00854 * supplied by the Tcl_ResolveCompiledVarProc 00855 * associated with a namespace. Each variable 00856 * is marked by a unique ClientData tag during 00857 * compilation, and that same tag is used to 00858 * find the variable at runtime. */ 00859 char name[4]; /* Name of the local variable starts here. If 00860 * the name is NULL, this will just be '\0'. 00861 * The actual size of this field will be large 00862 * enough to hold the name. MUST BE THE LAST 00863 * FIELD IN THE STRUCTURE! */ 00864 } CompiledLocal; 00865 00866 /* 00867 * The structure below defines a command procedure, which consists of a 00868 * collection of Tcl commands plus information about arguments and other local 00869 * variables recognized at compile time. 00870 */ 00871 00872 typedef struct Proc { 00873 struct Interp *iPtr; /* Interpreter for which this command is 00874 * defined. */ 00875 int refCount; /* Reference count: 1 if still present in 00876 * command table plus 1 for each call to the 00877 * procedure that is currently active. This 00878 * structure can be freed when refCount 00879 * becomes zero. */ 00880 struct Command *cmdPtr; /* Points to the Command structure for this 00881 * procedure. This is used to get the 00882 * namespace in which to execute the 00883 * procedure. */ 00884 Tcl_Obj *bodyPtr; /* Points to the ByteCode object for 00885 * procedure's body command. */ 00886 int numArgs; /* Number of formal parameters. */ 00887 int numCompiledLocals; /* Count of local variables recognized by the 00888 * compiler including arguments and 00889 * temporaries. */ 00890 CompiledLocal *firstLocalPtr; 00891 /* Pointer to first of the procedure's 00892 * compiler-allocated local variables, or NULL 00893 * if none. The first numArgs entries in this 00894 * list describe the procedure's formal 00895 * arguments. */ 00896 CompiledLocal *lastLocalPtr;/* Pointer to the last allocated local 00897 * variable or NULL if none. This has frame 00898 * index (numCompiledLocals-1). */ 00899 } Proc; 00900 00901 /* 00902 * The type of functions called to process errors found during the execution 00903 * of a procedure (or lambda term or ...). 00904 */ 00905 00906 typedef void (*ProcErrorProc)(Tcl_Interp *interp, Tcl_Obj *procNameObj); 00907 00908 /* 00909 * The structure below defines a command trace. This is used to allow Tcl 00910 * clients to find out whenever a command is about to be executed. 00911 */ 00912 00913 typedef struct Trace { 00914 int level; /* Only trace commands at nesting level less 00915 * than or equal to this. */ 00916 Tcl_CmdObjTraceProc *proc; /* Procedure to call to trace command. */ 00917 ClientData clientData; /* Arbitrary value to pass to proc. */ 00918 struct Trace *nextPtr; /* Next in list of traces for this interp. */ 00919 int flags; /* Flags governing the trace - see 00920 * Tcl_CreateObjTrace for details */ 00921 Tcl_CmdObjTraceDeleteProc* delProc; 00922 /* Procedure to call when trace is deleted */ 00923 } Trace; 00924 00925 /* 00926 * When an interpreter trace is active (i.e. its associated procedure is 00927 * executing), one of the following structures is linked into a list 00928 * associated with the interpreter. The information in the structure is needed 00929 * in order for Tcl to behave reasonably if traces are deleted while traces 00930 * are active. 00931 */ 00932 00933 typedef struct ActiveInterpTrace { 00934 struct ActiveInterpTrace *nextPtr; 00935 /* Next in list of all active command traces 00936 * for the interpreter, or NULL if no more. */ 00937 Trace *nextTracePtr; /* Next trace to check after current trace 00938 * procedure returns; if this trace gets 00939 * deleted, must update pointer to avoid using 00940 * free'd memory. */ 00941 int reverseScan; /* Boolean set true when traces are scanning 00942 * in reverse order. */ 00943 } ActiveInterpTrace; 00944 00945 /* 00946 * Flag values designating types of execution traces. See tclTrace.c for 00947 * related flag values. 00948 * 00949 * TCL_TRACE_ENTER_EXEC - triggers enter/enterstep traces. 00950 * - passed to Tcl_CreateObjTrace to set up 00951 * "enterstep" traces. 00952 * TCL_TRACE_LEAVE_EXEC - triggers leave/leavestep traces. 00953 * - passed to Tcl_CreateObjTrace to set up 00954 * "leavestep" traces. 00955 * 00956 */ 00957 #define TCL_TRACE_ENTER_EXEC 1 00958 #define TCL_TRACE_LEAVE_EXEC 2 00959 00960 /* 00961 * The structure below defines an entry in the assocData hash table which is 00962 * associated with an interpreter. The entry contains a pointer to a function 00963 * to call when the interpreter is deleted, and a pointer to a user-defined 00964 * piece of data. 00965 */ 00966 00967 typedef struct AssocData { 00968 Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */ 00969 ClientData clientData; /* Value to pass to proc. */ 00970 } AssocData; 00971 00972 /* 00973 * The structure below defines a call frame. A call frame defines a naming 00974 * context for a procedure call: its local naming scope (for local variables) 00975 * and its global naming scope (a namespace, perhaps the global :: namespace). 00976 * A call frame can also define the naming context for a namespace eval or 00977 * namespace inscope command: the namespace in which the command's code should 00978 * execute. The Tcl_CallFrame structures exist only while procedures or 00979 * namespace eval/inscope's are being executed, and provide a kind of Tcl call 00980 * stack. 00981 * 00982 * WARNING!! The structure definition must be kept consistent with the 00983 * Tcl_CallFrame structure in tcl.h. If you change one, change the other. 00984 */ 00985 00986 /* 00987 * Will be grown to contain: pointers to the varnames (allocated at the end), 00988 * plus the init values for each variable (suitable to be memcopied on init) 00989 */ 00990 00991 typedef struct LocalCache { 00992 int refCount; 00993 int numVars; 00994 Tcl_Obj *varName0; 00995 } LocalCache; 00996 00997 #define localName(framePtr, i) \ 00998 ((&((framePtr)->localCachePtr->varName0))[(i)]) 00999 01000 MODULE_SCOPE void TclFreeLocalCache(Tcl_Interp *interp, 01001 LocalCache *localCachePtr); 01002 01003 typedef struct CallFrame { 01004 Namespace *nsPtr; /* Points to the namespace used to resolve 01005 * commands and global variables. */ 01006 int isProcCallFrame; /* If 0, the frame was pushed to execute a 01007 * namespace command and var references are 01008 * treated as references to namespace vars; 01009 * varTablePtr and compiledLocals are ignored. 01010 * If FRAME_IS_PROC is set, the frame was 01011 * pushed to execute a Tcl procedure and may 01012 * have local vars. */ 01013 int objc; /* This and objv below describe the arguments 01014 * for this procedure call. */ 01015 Tcl_Obj *const *objv; /* Array of argument objects. */ 01016 struct CallFrame *callerPtr; 01017 /* Value of interp->framePtr when this 01018 * procedure was invoked (i.e. next higher in 01019 * stack of all active procedures). */ 01020 struct CallFrame *callerVarPtr; 01021 /* Value of interp->varFramePtr when this 01022 * procedure was invoked (i.e. determines 01023 * variable scoping within caller). Same as 01024 * callerPtr unless an "uplevel" command or 01025 * something equivalent was active in the 01026 * caller). */ 01027 int level; /* Level of this procedure, for "uplevel" 01028 * purposes (i.e. corresponds to nesting of 01029 * callerVarPtr's, not callerPtr's). 1 for 01030 * outermost procedure, 0 for top-level. */ 01031 Proc *procPtr; /* Points to the structure defining the called 01032 * procedure. Used to get information such as 01033 * the number of compiled local variables 01034 * (local variables assigned entries ["slots"] 01035 * in the compiledLocals array below). */ 01036 TclVarHashTable *varTablePtr; 01037 /* Hash table containing local variables not 01038 * recognized by the compiler, or created at 01039 * execution time through, e.g., upvar. 01040 * Initially NULL and created if needed. */ 01041 int numCompiledLocals; /* Count of local variables recognized by the 01042 * compiler including arguments. */ 01043 Var *compiledLocals; /* Points to the array of local variables 01044 * recognized by the compiler. The compiler 01045 * emits code that refers to these variables 01046 * using an index into this array. */ 01047 ClientData clientData; /* Pointer to some context that is used by 01048 * object systems. The meaning of the contents 01049 * of this field is defined by the code that 01050 * sets it, and it should only ever be set by 01051 * the code that is pushing the frame. In that 01052 * case, the code that sets it should also 01053 * have some means of discovering what the 01054 * meaning of the value is, which we do not 01055 * specify. */ 01056 LocalCache *localCachePtr; 01057 } CallFrame; 01058 01059 #define FRAME_IS_PROC 0x1 01060 #define FRAME_IS_LAMBDA 0x2 01061 01062 /* 01063 * TIP #280 01064 * The structure below defines a command frame. A command frame provides 01065 * location information for all commands executing a tcl script (source, eval, 01066 * uplevel, procedure bodies, ...). The runtime structure essentially contains 01067 * the stack trace as it would be if the currently executing command were to 01068 * throw an error. 01069 * 01070 * For commands where it makes sense it refers to the associated CallFrame as 01071 * well. 01072 * 01073 * The structures are chained in a single list, with the top of the stack 01074 * anchored in the Interp structure. 01075 * 01076 * Instances can be allocated on the C stack, or the heap, the former making 01077 * cleanup a bit simpler. 01078 */ 01079 01080 typedef struct CmdFrame { 01081 /* 01082 * General data. Always available. 01083 */ 01084 01085 int type; /* Values see below. */ 01086 int level; /* #Frames in stack, prevent O(n) scan of 01087 * list. */ 01088 int *line; /* Lines the words of the command start on. */ 01089 int nline; 01090 01091 CallFrame *framePtr; /* Procedure activation record, may be 01092 * NULL. */ 01093 struct CmdFrame *nextPtr; /* Link to calling frame */ 01094 01095 /* 01096 * Data needed for Eval vs TEBC 01097 * 01098 * EXECUTION CONTEXTS and usage of CmdFrame 01099 * 01100 * Field TEBC EvalEx EvalObjEx 01101 * ======= ==== ====== ========= 01102 * level yes yes yes 01103 * type BC/PREBC SRC/EVAL EVAL_LIST 01104 * line0 yes yes yes 01105 * framePtr yes yes yes 01106 * ======= ==== ====== ========= 01107 * 01108 * ======= ==== ====== ========= union data 01109 * line1 - yes - 01110 * line3 - yes - 01111 * path - yes - 01112 * ------- ---- ------ --------- 01113 * codePtr yes - - 01114 * pc yes - - 01115 * ======= ==== ====== ========= 01116 * 01117 * ======= ==== ====== ========= | union cmd 01118 * listPtr - - yes | 01119 * ------- ---- ------ --------- | 01120 * cmd yes yes - | 01121 * cmdlen yes yes - | 01122 * ------- ---- ------ --------- | 01123 */ 01124 01125 union { 01126 struct { 01127 Tcl_Obj *path; /* Path of the sourced file the command is 01128 * in. */ 01129 } eval; 01130 struct { 01131 const void *codePtr;/* Byte code currently executed */ 01132 const char *pc; /* and instruction pointer. */ 01133 } tebc; 01134 } data; 01135 union { 01136 struct { 01137 const char *cmd; /* The executed command, if possible */ 01138 int len; /* And its length */ 01139 } str; 01140 Tcl_Obj *listPtr; /* Tcl_EvalObjEx, cmd list */ 01141 } cmd; 01142 } CmdFrame; 01143 01144 /* 01145 * The following macros define the allowed values for the type field of the 01146 * CmdFrame structure above. Some of the values occur only in the extended 01147 * location data referenced via the 'baseLocPtr'. 01148 * 01149 * TCL_LOCATION_EVAL : Frame is for a script evaluated by EvalEx. 01150 * TCL_LOCATION_EVAL_LIST : Frame is for a script evaluated by the list 01151 * optimization path of EvalObjEx. 01152 * TCL_LOCATION_BC : Frame is for bytecode. 01153 * TCL_LOCATION_PREBC : Frame is for precompiled bytecode. 01154 * TCL_LOCATION_SOURCE : Frame is for a script evaluated by EvalEx, from a 01155 * sourced file. 01156 * TCL_LOCATION_PROC : Frame is for bytecode of a procedure. 01157 * 01158 * A TCL_LOCATION_BC type in a frame can be overridden by _SOURCE and _PROC 01159 * types, per the context of the byte code in execution. 01160 */ 01161 01162 #define TCL_LOCATION_EVAL (0) /* Location in a dynamic eval script */ 01163 #define TCL_LOCATION_EVAL_LIST (1) /* Location in a dynamic eval script, 01164 * list-path */ 01165 #define TCL_LOCATION_BC (2) /* Location in byte code */ 01166 #define TCL_LOCATION_PREBC (3) /* Location in precompiled byte code, no 01167 * location */ 01168 #define TCL_LOCATION_SOURCE (4) /* Location in a file */ 01169 #define TCL_LOCATION_PROC (5) /* Location in a dynamic proc */ 01170 01171 #define TCL_LOCATION_LAST (6) /* Number of values in the enum */ 01172 01173 /* 01174 * Structure passed to describe procedure-like "procedures" that are not 01175 * procedures (e.g. a lambda) so that their details can be reported correctly 01176 * by [info frame]. Contains a sub-structure for each extra field. 01177 */ 01178 01179 typedef Tcl_Obj *(*GetFrameInfoValueProc)(ClientData clientData); 01180 typedef struct { 01181 const char *name; /* Name of this field. */ 01182 GetFrameInfoValueProc proc; /* Function to generate a Tcl_Obj* from the 01183 * clientData, or just use the clientData 01184 * directly (after casting) if NULL. */ 01185 ClientData clientData; /* Context for above function, or Tcl_Obj* if 01186 * proc field is NULL. */ 01187 } ExtraFrameInfoField; 01188 typedef struct { 01189 int length; /* Length of array. */ 01190 ExtraFrameInfoField fields[2]; 01191 /* Really as long as necessary, but this is 01192 * long enough for nearly anything. */ 01193 } ExtraFrameInfo; 01194 01195 /* 01196 *---------------------------------------------------------------- 01197 * Data structures and procedures related to TclHandles, which are a very 01198 * lightweight method of preserving enough information to determine if an 01199 * arbitrary malloc'd block has been deleted. 01200 *---------------------------------------------------------------- 01201 */ 01202 01203 typedef void **TclHandle; 01204 01205 /* 01206 *---------------------------------------------------------------- 01207 * Experimental flag value passed to Tcl_GetRegExpFromObj. Intended for use 01208 * only by Expect. It will probably go away in a later release. 01209 *---------------------------------------------------------------- 01210 */ 01211 01212 #define TCL_REG_BOSONLY 002000 /* Prepend \A to pattern so it only matches at 01213 * the beginning of the string. */ 01214 01215 /* 01216 * These are a thin layer over TclpThreadKeyDataGet and TclpThreadKeyDataSet 01217 * when threads are used, or an emulation if there are no threads. These are 01218 * really internal and Tcl clients should use Tcl_GetThreadData. 01219 */ 01220 01221 MODULE_SCOPE void * TclThreadDataKeyGet(Tcl_ThreadDataKey *keyPtr); 01222 MODULE_SCOPE void TclThreadDataKeySet(Tcl_ThreadDataKey *keyPtr, 01223 void *data); 01224 01225 /* 01226 * This is a convenience macro used to initialize a thread local storage ptr. 01227 */ 01228 01229 #define TCL_TSD_INIT(keyPtr) \ 01230 (ThreadSpecificData *)Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData)) 01231 01232 01233 /* 01234 *---------------------------------------------------------------- 01235 * Data structures related to bytecode compilation and execution. These are 01236 * used primarily in tclCompile.c, tclExecute.c, and tclBasic.c. 01237 *---------------------------------------------------------------- 01238 */ 01239 01240 /* 01241 * Forward declaration to prevent errors when the forward references to 01242 * Tcl_Parse and CompileEnv are encountered in the procedure type CompileProc 01243 * declared below. 01244 */ 01245 01246 struct CompileEnv; 01247 01248 /* 01249 * The type of procedures called by the Tcl bytecode compiler to compile 01250 * commands. Pointers to these procedures are kept in the Command structure 01251 * describing each command. The integer value returned by a CompileProc must 01252 * be one of the following: 01253 * 01254 * TCL_OK Compilation completed normally. 01255 * TCL_ERROR Compilation could not be completed. This can be just a 01256 * judgment by the CompileProc that the command is too 01257 * complex to compile effectively, or it can indicate 01258 * that in the current state of the interp, the command 01259 * would raise an error. The bytecode compiler will not 01260 * do any error reporting at compiler time. Error 01261 * reporting is deferred until the actual runtime, 01262 * because by then changes in the interp state may allow 01263 * the command to be successfully evaluated. 01264 * TCL_OUT_LINE_COMPILE A source-compatible alias for TCL_ERROR, kept for the 01265 * sake of old code only. 01266 */ 01267 01268 #define TCL_OUT_LINE_COMPILE TCL_ERROR 01269 01270 typedef int (CompileProc) (Tcl_Interp *interp, Tcl_Parse *parsePtr, 01271 struct Command *cmdPtr, struct CompileEnv *compEnvPtr); 01272 01273 /* 01274 * The type of procedure called from the compilation hook point in 01275 * SetByteCodeFromAny. 01276 */ 01277 01278 typedef int (CompileHookProc) (Tcl_Interp *interp, 01279 struct CompileEnv *compEnvPtr, ClientData clientData); 01280 01281 /* 01282 * The data structure for a (linked list of) execution stacks. 01283 */ 01284 01285 typedef struct ExecStack { 01286 struct ExecStack *prevPtr; 01287 struct ExecStack *nextPtr; 01288 Tcl_Obj **markerPtr; 01289 Tcl_Obj **endPtr; 01290 Tcl_Obj **tosPtr; 01291 Tcl_Obj *stackWords[1]; 01292 } ExecStack; 01293 01294 /* 01295 * The data structure defining the execution environment for ByteCode's. 01296 * There is one ExecEnv structure per Tcl interpreter. It holds the evaluation 01297 * stack that holds command operands and results. The stack grows towards 01298 * increasing addresses. The member stackPtr points to the stackItems of the 01299 * currently active execution stack. 01300 */ 01301 01302 typedef struct ExecEnv { 01303 ExecStack *execStackPtr; /* Points to the first item in the evaluation 01304 * stack on the heap. */ 01305 Tcl_Obj *constants[2]; /* Pointers to constant "0" and "1" objs. */ 01306 } ExecEnv; 01307 01308 /* 01309 * The definitions for the LiteralTable and LiteralEntry structures. Each 01310 * interpreter contains a LiteralTable. It is used to reduce the storage 01311 * needed for all the Tcl objects that hold the literals of scripts compiled 01312 * by the interpreter. A literal's object is shared by all the ByteCodes that 01313 * refer to the literal. Each distinct literal has one LiteralEntry entry in 01314 * the LiteralTable. A literal table is a specialized hash table that is 01315 * indexed by the literal's string representation, which may contain null 01316 * characters. 01317 * 01318 * Note that we reduce the space needed for literals by sharing literal 01319 * objects both within a ByteCode (each ByteCode contains a local 01320 * LiteralTable) and across all an interpreter's ByteCodes (with the 01321 * interpreter's global LiteralTable). 01322 */ 01323 01324 typedef struct LiteralEntry { 01325 struct LiteralEntry *nextPtr; 01326 /* Points to next entry in this hash bucket or 01327 * NULL if end of chain. */ 01328 Tcl_Obj *objPtr; /* Points to Tcl object that holds the 01329 * literal's bytes and length. */ 01330 int refCount; /* If in an interpreter's global literal 01331 * table, the number of ByteCode structures 01332 * that share the literal object; the literal 01333 * entry can be freed when refCount drops to 01334 * 0. If in a local literal table, -1. */ 01335 Namespace *nsPtr; /* Namespace in which this literal is used. We 01336 * try to avoid sharing literal non-FQ command 01337 * names among different namespaces to reduce 01338 * shimmering. */ 01339 } LiteralEntry; 01340 01341 typedef struct LiteralTable { 01342 LiteralEntry **buckets; /* Pointer to bucket array. Each element 01343 * points to first entry in bucket's hash 01344 * chain, or NULL. */ 01345 LiteralEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; 01346 /* Bucket array used for small tables to avoid 01347 * mallocs and frees. */ 01348 int numBuckets; /* Total number of buckets allocated at 01349 * **buckets. */ 01350 int numEntries; /* Total number of entries present in 01351 * table. */ 01352 int rebuildSize; /* Enlarge table when numEntries gets to be 01353 * this large. */ 01354 int mask; /* Mask value used in hashing function. */ 01355 } LiteralTable; 01356 01357 /* 01358 * The following structure defines for each Tcl interpreter various 01359 * statistics-related information about the bytecode compiler and 01360 * interpreter's operation in that interpreter. 01361 */ 01362 01363 #ifdef TCL_COMPILE_STATS 01364 typedef struct ByteCodeStats { 01365 long numExecutions; /* Number of ByteCodes executed. */ 01366 long numCompilations; /* Number of ByteCodes created. */ 01367 long numByteCodesFreed; /* Number of ByteCodes destroyed. */ 01368 long instructionCount[256]; /* Number of times each instruction was 01369 * executed. */ 01370 01371 double totalSrcBytes; /* Total source bytes ever compiled. */ 01372 double totalByteCodeBytes; /* Total bytes for all ByteCodes. */ 01373 double currentSrcBytes; /* Src bytes for all current ByteCodes. */ 01374 double currentByteCodeBytes;/* Code bytes in all current ByteCodes. */ 01375 01376 long srcCount[32]; /* Source size distribution: # of srcs of 01377 * size [2**(n-1)..2**n), n in [0..32). */ 01378 long byteCodeCount[32]; /* ByteCode size distribution. */ 01379 long lifetimeCount[32]; /* ByteCode lifetime distribution (ms). */ 01380 01381 double currentInstBytes; /* Instruction bytes-current ByteCodes. */ 01382 double currentLitBytes; /* Current literal bytes. */ 01383 double currentExceptBytes; /* Current exception table bytes. */ 01384 double currentAuxBytes; /* Current auxiliary information bytes. */ 01385 double currentCmdMapBytes; /* Current src<->code map bytes. */ 01386 01387 long numLiteralsCreated; /* Total literal objects ever compiled. */ 01388 double totalLitStringBytes; /* Total string bytes in all literals. */ 01389 double currentLitStringBytes; 01390 /* String bytes in current literals. */ 01391 long literalCount[32]; /* Distribution of literal string sizes. */ 01392 } ByteCodeStats; 01393 #endif /* TCL_COMPILE_STATS */ 01394 01395 /* 01396 * Structure used in implementation of those core ensembles which are 01397 * partially compiled. 01398 */ 01399 01400 typedef struct { 01401 const char *name; /* The name of the subcommand. */ 01402 Tcl_ObjCmdProc *proc; /* The implementation of the subcommand. */ 01403 CompileProc *compileProc; /* The compiler for the subcommand. */ 01404 } EnsembleImplMap; 01405 01406 /* 01407 *---------------------------------------------------------------- 01408 * Data structures related to commands. 01409 *---------------------------------------------------------------- 01410 */ 01411 01412 /* 01413 * An imported command is created in an namespace when it imports a "real" 01414 * command from another namespace. An imported command has a Command structure 01415 * that points (via its ClientData value) to the "real" Command structure in 01416 * the source namespace's command table. The real command records all the 01417 * imported commands that refer to it in a list of ImportRef structures so 01418 * that they can be deleted when the real command is deleted. 01419 */ 01420 01421 typedef struct ImportRef { 01422 struct Command *importedCmdPtr; 01423 /* Points to the imported command created in 01424 * an importing namespace; this command 01425 * redirects its invocations to the "real" 01426 * command. */ 01427 struct ImportRef *nextPtr; /* Next element on the linked list of imported 01428 * commands that refer to the "real" command. 01429 * The real command deletes these imported 01430 * commands on this list when it is 01431 * deleted. */ 01432 } ImportRef; 01433 01434 /* 01435 * Data structure used as the ClientData of imported commands: commands 01436 * created in an namespace when it imports a "real" command from another 01437 * namespace. 01438 */ 01439 01440 typedef struct ImportedCmdData { 01441 struct Command *realCmdPtr; /* "Real" command that this imported command 01442 * refers to. */ 01443 struct Command *selfPtr; /* Pointer to this imported command. Needed 01444 * only when deleting it in order to remove it 01445 * from the real command's linked list of 01446 * imported commands that refer to it. */ 01447 } ImportedCmdData; 01448 01449 /* 01450 * A Command structure exists for each command in a namespace. The Tcl_Command 01451 * opaque type actually refers to these structures. 01452 */ 01453 01454 typedef struct Command { 01455 Tcl_HashEntry *hPtr; /* Pointer to the hash table entry that refers 01456 * to this command. The hash table is either a 01457 * namespace's command table or an 01458 * interpreter's hidden command table. This 01459 * pointer is used to get a command's name 01460 * from its Tcl_Command handle. NULL means 01461 * that the hash table entry has been removed 01462 * already (this can happen if deleteProc 01463 * causes the command to be deleted or 01464 * recreated). */ 01465 Namespace *nsPtr; /* Points to the namespace containing this 01466 * command. */ 01467 int refCount; /* 1 if in command hashtable plus 1 for each 01468 * reference from a CmdName Tcl object 01469 * representing a command's name in a ByteCode 01470 * instruction sequence. This structure can be 01471 * freed when refCount becomes zero. */ 01472 int cmdEpoch; /* Incremented to invalidate any references 01473 * that point to this command when it is 01474 * renamed, deleted, hidden, or exposed. */ 01475 CompileProc *compileProc; /* Procedure called to compile command. NULL 01476 * if no compile proc exists for command. */ 01477 Tcl_ObjCmdProc *objProc; /* Object-based command procedure. */ 01478 ClientData objClientData; /* Arbitrary value passed to object proc. */ 01479 Tcl_CmdProc *proc; /* String-based command procedure. */ 01480 ClientData clientData; /* Arbitrary value passed to string proc. */ 01481 Tcl_CmdDeleteProc *deleteProc; 01482 /* Procedure invoked when deleting command to, 01483 * e.g., free all client data. */ 01484 ClientData deleteData; /* Arbitrary value passed to deleteProc. */ 01485 int flags; /* Miscellaneous bits of information about 01486 * command. See below for definitions. */ 01487 ImportRef *importRefPtr; /* List of each imported Command created in 01488 * another namespace when this command is 01489 * imported. These imported commands redirect 01490 * invocations back to this command. The list 01491 * is used to remove all those imported 01492 * commands when deleting this "real" 01493 * command. */ 01494 CommandTrace *tracePtr; /* First in list of all traces set for this 01495 * command. */ 01496 } Command; 01497 01498 /* 01499 * Flag bits for commands. 01500 * 01501 * CMD_IS_DELETED - Means that the command is in the process of 01502 * being deleted (its deleteProc is currently 01503 * executing). Other attempts to delete the 01504 * command should be ignored. 01505 * CMD_TRACE_ACTIVE - 1 means that trace processing is currently 01506 * underway for a rename/delete change. See the 01507 * two flags below for which is currently being 01508 * processed. 01509 * CMD_HAS_EXEC_TRACES - 1 means that this command has at least one 01510 * execution trace (as opposed to simple 01511 * delete/rename traces) in its tracePtr list. 01512 * TCL_TRACE_RENAME - A rename trace is in progress. Further 01513 * recursive renames will not be traced. 01514 * TCL_TRACE_DELETE - A delete trace is in progress. Further 01515 * recursive deletes will not be traced. 01516 * (these last two flags are defined in tcl.h) 01517 */ 01518 01519 #define CMD_IS_DELETED 0x1 01520 #define CMD_TRACE_ACTIVE 0x2 01521 #define CMD_HAS_EXEC_TRACES 0x4 01522 01523 /* 01524 *---------------------------------------------------------------- 01525 * Data structures related to name resolution procedures. 01526 *---------------------------------------------------------------- 01527 */ 01528 01529 /* 01530 * The interpreter keeps a linked list of name resolution schemes. The scheme 01531 * for a namespace is consulted first, followed by the list of schemes in an 01532 * interpreter, followed by the default name resolution in Tcl. Schemes are 01533 * added/removed from the interpreter's list by calling Tcl_AddInterpResolver 01534 * and Tcl_RemoveInterpResolver. 01535 */ 01536 01537 typedef struct ResolverScheme { 01538 char *name; /* Name identifying this scheme. */ 01539 Tcl_ResolveCmdProc *cmdResProc; 01540 /* Procedure handling command name 01541 * resolution. */ 01542 Tcl_ResolveVarProc *varResProc; 01543 /* Procedure handling variable name resolution 01544 * for variables that can only be handled at 01545 * runtime. */ 01546 Tcl_ResolveCompiledVarProc *compiledVarResProc; 01547 /* Procedure handling variable name resolution 01548 * at compile time. */ 01549 01550 struct ResolverScheme *nextPtr; 01551 /* Pointer to next record in linked list. */ 01552 } ResolverScheme; 01553 01554 /* 01555 * Forward declaration of the TIP#143 limit handler structure. 01556 */ 01557 01558 typedef struct LimitHandler LimitHandler; 01559 01560 /* 01561 * TIP #268. 01562 * Values for the selection mode, i.e the package require preferences. 01563 */ 01564 01565 enum PkgPreferOptions { 01566 PKG_PREFER_LATEST, PKG_PREFER_STABLE 01567 }; 01568 01569 /* 01570 *---------------------------------------------------------------- 01571 * This structure defines an interpreter, which is a collection of commands 01572 * plus other state information related to interpreting commands, such as 01573 * variable storage. Primary responsibility for this data structure is in 01574 * tclBasic.c, but almost every Tcl source file uses something in here. 01575 *---------------------------------------------------------------- 01576 */ 01577 01578 typedef struct Interp { 01579 /* 01580 * Note: the first three fields must match exactly the fields in a 01581 * Tcl_Interp struct (see tcl.h). If you change one, be sure to change the 01582 * other. 01583 * 01584 * The interpreter's result is held in both the string and the 01585 * objResultPtr fields. These fields hold, respectively, the result's 01586 * string or object value. The interpreter's result is always in the 01587 * result field if that is non-empty, otherwise it is in objResultPtr. 01588 * The two fields are kept consistent unless some C code sets 01589 * interp->result directly. Programs should not access result and 01590 * objResultPtr directly; instead, they should always get and set the 01591 * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult, and 01592 * Tcl_GetStringResult. See the SetResult man page for details. 01593 */ 01594 01595 char *result; /* If the last command returned a string 01596 * result, this points to it. Should not be 01597 * accessed directly; see comment above. */ 01598 Tcl_FreeProc *freeProc; /* Zero means a string result is statically 01599 * allocated. TCL_DYNAMIC means string result 01600 * was allocated with ckalloc and should be 01601 * freed with ckfree. Other values give 01602 * address of procedure to invoke to free the 01603 * string result. Tcl_Eval must free it before 01604 * executing next command. */ 01605 int errorLine; /* When TCL_ERROR is returned, this gives the 01606 * line number in the command where the error 01607 * occurred (1 means first line). */ 01608 struct TclStubs *stubTable; /* Pointer to the exported Tcl stub table. On 01609 * previous versions of Tcl this is a pointer 01610 * to the objResultPtr or a pointer to a 01611 * buckets array in a hash table. We therefore 01612 * have to do some careful checking before we 01613 * can use this. */ 01614 01615 TclHandle handle; /* Handle used to keep track of when this 01616 * interp is deleted. */ 01617 01618 Namespace *globalNsPtr; /* The interpreter's global namespace. */ 01619 Tcl_HashTable *hiddenCmdTablePtr; 01620 /* Hash table used by tclBasic.c to keep track 01621 * of hidden commands on a per-interp 01622 * basis. */ 01623 ClientData interpInfo; /* Information used by tclInterp.c to keep 01624 * track of master/slave interps on a 01625 * per-interp basis. */ 01626 Tcl_HashTable unused2; /* No longer used (was mathFuncTable) */ 01627 01628 /* 01629 * Information related to procedures and variables. See tclProc.c and 01630 * tclVar.c for usage. 01631 */ 01632 01633 int numLevels; /* Keeps track of how many nested calls to 01634 * Tcl_Eval are in progress for this 01635 * interpreter. It's used to delay deletion of 01636 * the table until all Tcl_Eval invocations 01637 * are completed. */ 01638 int maxNestingDepth; /* If numLevels exceeds this value then Tcl 01639 * assumes that infinite recursion has 01640 * occurred and it generates an error. */ 01641 CallFrame *framePtr; /* Points to top-most in stack of all nested 01642 * procedure invocations. */ 01643 CallFrame *varFramePtr; /* Points to the call frame whose variables 01644 * are currently in use (same as framePtr 01645 * unless an "uplevel" command is 01646 * executing). */ 01647 ActiveVarTrace *activeVarTracePtr; 01648 /* First in list of active traces for interp, 01649 * or NULL if no active traces. */ 01650 int returnCode; /* [return -code] parameter */ 01651 CallFrame *rootFramePtr; /* Global frame pointer for this interpreter */ 01652 Namespace *lookupNsPtr; /* Namespace to use ONLY on the next 01653 * TCL_EVAL_INVOKE call to Tcl_EvalObjv */ 01654 01655 /* 01656 * Information used by Tcl_AppendResult to keep track of partial results. 01657 * See Tcl_AppendResult code for details. 01658 */ 01659 01660 char *appendResult; /* Storage space for results generated by 01661 * Tcl_AppendResult. Ckalloc-ed. NULL means 01662 * not yet allocated. */ 01663 int appendAvl; /* Total amount of space available at 01664 * partialResult. */ 01665 int appendUsed; /* Number of non-null bytes currently stored 01666 * at partialResult. */ 01667 01668 /* 01669 * Information about packages. Used only in tclPkg.c. 01670 */ 01671 01672 Tcl_HashTable packageTable; /* Describes all of the packages loaded in or 01673 * available to this interpreter. Keys are 01674 * package names, values are (Package *) 01675 * pointers. */ 01676 char *packageUnknown; /* Command to invoke during "package require" 01677 * commands for packages that aren't described 01678 * in packageTable. Ckalloc'ed, may be 01679 * NULL. */ 01680 /* 01681 * Miscellaneous information: 01682 */ 01683 01684 int cmdCount; /* Total number of times a command procedure 01685 * has been called for this interpreter. */ 01686 int evalFlags; /* Flags to control next call to Tcl_Eval. 01687 * Normally zero, but may be set before 01688 * calling Tcl_Eval. See below for valid 01689 * values. */ 01690 int unused1; /* No longer used (was termOffset) */ 01691 LiteralTable literalTable; /* Contains LiteralEntry's describing all Tcl 01692 * objects holding literals of scripts 01693 * compiled by the interpreter. Indexed by the 01694 * string representations of literals. Used to 01695 * avoid creating duplicate objects. */ 01696 int compileEpoch; /* Holds the current "compilation epoch" for 01697 * this interpreter. This is incremented to 01698 * invalidate existing ByteCodes when, e.g., a 01699 * command with a compile procedure is 01700 * redefined. */ 01701 Proc *compiledProcPtr; /* If a procedure is being compiled, a pointer 01702 * to its Proc structure; otherwise, this is 01703 * NULL. Set by ObjInterpProc in tclProc.c and 01704 * used by tclCompile.c to process local 01705 * variables appropriately. */ 01706 ResolverScheme *resolverPtr; 01707 /* Linked list of name resolution schemes 01708 * added to this interpreter. Schemes are 01709 * added and removed by calling 01710 * Tcl_AddInterpResolvers and 01711 * Tcl_RemoveInterpResolver respectively. */ 01712 Tcl_Obj *scriptFile; /* NULL means there is no nested source 01713 * command active; otherwise this points to 01714 * pathPtr of the file being sourced. */ 01715 int flags; /* Various flag bits. See below. */ 01716 long randSeed; /* Seed used for rand() function. */ 01717 Trace *tracePtr; /* List of traces for this interpreter. */ 01718 Tcl_HashTable *assocData; /* Hash table for associating data with this 01719 * interpreter. Cleaned up when this 01720 * interpreter is deleted. */ 01721 struct ExecEnv *execEnvPtr; /* Execution environment for Tcl bytecode 01722 * execution. Contains a pointer to the Tcl 01723 * evaluation stack. */ 01724 Tcl_Obj *emptyObjPtr; /* Points to an object holding an empty 01725 * string. Returned by Tcl_ObjSetVar2 when 01726 * variable traces change a variable in a 01727 * gross way. */ 01728 char resultSpace[TCL_RESULT_SIZE+1]; 01729 /* Static space holding small results. */ 01730 Tcl_Obj *objResultPtr; /* If the last command returned an object 01731 * result, this points to it. Should not be 01732 * accessed directly; see comment above. */ 01733 Tcl_ThreadId threadId; /* ID of thread that owns the interpreter */ 01734 01735 ActiveCommandTrace *activeCmdTracePtr; 01736 /* First in list of active command traces for 01737 * interp, or NULL if no active traces. */ 01738 ActiveInterpTrace *activeInterpTracePtr; 01739 /* First in list of active traces for interp, 01740 * or NULL if no active traces. */ 01741 01742 int tracesForbiddingInline; /* Count of traces (in the list headed by 01743 * tracePtr) that forbid inline bytecode 01744 * compilation */ 01745 01746 /* Fields used to manage extensible return options (TIP 90) */ 01747 Tcl_Obj *returnOpts; /* A dictionary holding the options to the 01748 * last [return] command */ 01749 01750 Tcl_Obj *errorInfo; /* errorInfo value (now as a Tcl_Obj) */ 01751 Tcl_Obj *eiVar; /* cached ref to ::errorInfo variable */ 01752 Tcl_Obj *errorCode; /* errorCode value (now as a Tcl_Obj) */ 01753 Tcl_Obj *ecVar; /* cached ref to ::errorInfo variable */ 01754 int returnLevel; /* [return -level] parameter */ 01755 01756 /* 01757 * Resource limiting framework support (TIP#143). 01758 */ 01759 01760 struct { 01761 int active; /* Flag values defining which limits have been 01762 * set. */ 01763 int granularityTicker; /* Counter used to determine how often to 01764 * check the limits. */ 01765 int exceeded; /* Which limits have been exceeded, described 01766 * as flag values the same as the 'active' 01767 * field. */ 01768 01769 int cmdCount; /* Limit for how many commands to execute in 01770 * the interpreter. */ 01771 LimitHandler *cmdHandlers; 01772 /* Handlers to execute when the limit is 01773 * reached. */ 01774 int cmdGranularity; /* Mod factor used to determine how often to 01775 * evaluate the limit check. */ 01776 01777 Tcl_Time time; /* Time limit for execution within the 01778 * interpreter. */ 01779 LimitHandler *timeHandlers; 01780 /* Handlers to execute when the limit is 01781 * reached. */ 01782 int timeGranularity; /* Mod factor used to determine how often to 01783 * evaluate the limit check. */ 01784 Tcl_TimerToken timeEvent; 01785 /* Handle for a timer callback that will occur 01786 * when the time-limit is exceeded. */ 01787 01788 Tcl_HashTable callbacks;/* Mapping from (interp,type) pair to data 01789 * used to install a limit handler callback to 01790 * run in _this_ interp when the limit is 01791 * exceeded. */ 01792 } limit; 01793 01794 /* 01795 * Information for improved default error generation from ensembles 01796 * (TIP#112). 01797 */ 01798 01799 struct { 01800 Tcl_Obj *const *sourceObjs; 01801 /* What arguments were actually input into the 01802 * *root* ensemble command? (Nested ensembles 01803 * don't rewrite this.) NULL if we're not 01804 * processing an ensemble. */ 01805 int numRemovedObjs; /* How many arguments have been stripped off 01806 * because of ensemble processing. */ 01807 int numInsertedObjs; /* How many of the current arguments were 01808 * inserted by an ensemble. */ 01809 } ensembleRewrite; 01810 01811 /* 01812 * TIP #219 ... Global info for the I/O system ... 01813 */ 01814 01815 Tcl_Obj *chanMsg; /* Error message set by channel drivers, for 01816 * the propagation of arbitrary Tcl errors. 01817 * This information, if present (chanMsg not 01818 * NULL), takes precedence over a POSIX error 01819 * code returned by a channel operation. */ 01820 01821 /* TIP #280 */ 01822 CmdFrame *cmdFramePtr; /* Points to the command frame containing 01823 * the location information for the current 01824 * command. */ 01825 const CmdFrame *invokeCmdFramePtr; 01826 /* Points to the command frame which is the 01827 * invoking context of the bytecode compiler. 01828 * NULL when the byte code compiler is not 01829 * active */ 01830 int invokeWord; /* Index of the word in the command which 01831 * is getting compiled. */ 01832 Tcl_HashTable *linePBodyPtr;/* This table remembers for each statically 01833 * defined procedure the location information 01834 * for its body. It is keyed by the address of 01835 * the Proc structure for a procedure. */ 01836 Tcl_HashTable *lineBCPtr; /* This table remembers for each ByteCode 01837 * object the location information for its 01838 * body. It is keyed by the address of the 01839 * Proc structure for a procedure. */ 01840 /* 01841 * TIP #268. The currently active selection mode, i.e. the package require 01842 * preferences. 01843 */ 01844 01845 int packagePrefer; /* Current package selection mode. */ 01846 01847 /* 01848 * Hashtables for variable traces and searches 01849 */ 01850 01851 Tcl_HashTable varTraces; /* Hashtable holding the start of a variable's 01852 * active trace list; varPtr is the key. */ 01853 Tcl_HashTable varSearches; /* Hashtable holding the start of a variable's 01854 * active searches list; varPtr is the key */ 01855 /* 01856 * The thread-specific data ekeko: cache pointers or values that 01857 * (a) do not change during the thread's lifetime 01858 * (b) require access to TSD to determine at runtime 01859 * (c) are accessed very often (e.g., at each command call) 01860 * 01861 * Note that these are the same for all interps in the same thread. They 01862 * just have to be initialised for the thread's master interp, slaves 01863 * inherit the value. 01864 * 01865 * They are used by the macros defined below. 01866 */ 01867 01868 void *allocCache; 01869 void *pendingObjDataPtr; /* Pointer to the Cache and PendingObjData 01870 * structs for this interp's thread; see 01871 * tclObj.c and tclThreadAlloc.c */ 01872 int *asyncReadyPtr; /* Pointer to the asyncReady indicator for 01873 * this interp's thread; see tclAsync.c */ 01874 int *stackBound; /* Pointer to the limit stack address 01875 * allowable for invoking a new command 01876 * without "risking" a C-stack overflow; see 01877 * TclpCheckStackSpace in the platform's 01878 * directory. */ 01879 01880 01881 #ifdef TCL_COMPILE_STATS 01882 /* 01883 * Statistical information about the bytecode compiler and interpreter's 01884 * operation. 01885 */ 01886 01887 ByteCodeStats stats; /* Holds compilation and execution statistics 01888 * for this interpreter. */ 01889 #endif /* TCL_COMPILE_STATS */ 01890 } Interp; 01891 01892 /* 01893 * Macros that use the TSD-ekeko. 01894 */ 01895 01896 #define TclAsyncReady(iPtr) \ 01897 *((iPtr)->asyncReadyPtr) 01898 01899 01900 /* 01901 * General list of interpreters. Doubly linked for easier removal of items 01902 * deep in the list. 01903 */ 01904 01905 typedef struct InterpList { 01906 Interp *interpPtr; 01907 struct InterpList *prevPtr; 01908 struct InterpList *nextPtr; 01909 } InterpList; 01910 01911 /* 01912 * Macros for splicing into and out of doubly linked lists. They assume 01913 * existence of struct items 'prevPtr' and 'nextPtr'. 01914 * 01915 * a = element to add or remove. 01916 * b = list head. 01917 * 01918 * TclSpliceIn adds to the head of the list. 01919 */ 01920 01921 #define TclSpliceIn(a,b) \ 01922 (a)->nextPtr = (b); \ 01923 if ((b) != NULL) { \ 01924 (b)->prevPtr = (a); \ 01925 } \ 01926 (a)->prevPtr = NULL, (b) = (a); 01927 01928 #define TclSpliceOut(a,b) \ 01929 if ((a)->prevPtr != NULL) { \ 01930 (a)->prevPtr->nextPtr = (a)->nextPtr; \ 01931 } else { \ 01932 (b) = (a)->nextPtr; \ 01933 } \ 01934 if ((a)->nextPtr != NULL) { \ 01935 (a)->nextPtr->prevPtr = (a)->prevPtr; \ 01936 } 01937 01938 /* 01939 * EvalFlag bits for Interp structures: 01940 * 01941 * TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with a 01942 * code other than TCL_OK or TCL_ERROR; 0 means codes 01943 * other than these should be turned into errors. 01944 */ 01945 01946 #define TCL_ALLOW_EXCEPTIONS 4 01947 #define TCL_EVAL_FILE 2 01948 #define TCL_EVAL_CTX 8 01949 01950 /* 01951 * Flag bits for Interp structures: 01952 * 01953 * DELETED: Non-zero means the interpreter has been deleted: 01954 * don't process any more commands for it, and destroy 01955 * the structure as soon as all nested invocations of 01956 * Tcl_Eval are done. 01957 * ERR_ALREADY_LOGGED: Non-zero means information has already been logged in 01958 * iPtr->errorInfo for the current Tcl_Eval instance, so 01959 * Tcl_Eval needn't log it (used to implement the "error 01960 * message log" command). 01961 * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler should 01962 * not compile any commands into an inline sequence of 01963 * instructions. This is set 1, for example, when command 01964 * traces are requested. 01965 * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the interp 01966 * has not be initialized. This is set 1 when we first 01967 * use the rand() or srand() functions. 01968 * SAFE_INTERP: Non zero means that the current interp is a safe 01969 * interp (i.e. it has only the safe commands installed, 01970 * less priviledge than a regular interp). 01971 * INTERP_TRACE_IN_PROGRESS: Non-zero means that an interp trace is currently 01972 * active; so no further trace callbacks should be 01973 * invoked. 01974 * INTERP_ALTERNATE_WRONG_ARGS: Used for listing second and subsequent forms 01975 * of the wrong-num-args string in Tcl_WrongNumArgs. 01976 * Makes it append instead of replacing and uses 01977 * different intermediate text. 01978 * 01979 * WARNING: For the sake of some extensions that have made use of former 01980 * internal values, do not re-use the flag values 2 (formerly ERR_IN_PROGRESS) 01981 * or 8 (formerly ERROR_CODE_SET). 01982 */ 01983 01984 #define DELETED 1 01985 #define ERR_ALREADY_LOGGED 4 01986 #define DONT_COMPILE_CMDS_INLINE 0x20 01987 #define RAND_SEED_INITIALIZED 0x40 01988 #define SAFE_INTERP 0x80 01989 #define INTERP_TRACE_IN_PROGRESS 0x200 01990 #define INTERP_ALTERNATE_WRONG_ARGS 0x400 01991 #define ERR_LEGACY_COPY 0x800 01992 01993 /* 01994 * Maximum number of levels of nesting permitted in Tcl commands (used to 01995 * catch infinite recursion). 01996 */ 01997 01998 #define MAX_NESTING_DEPTH 1000 01999 02000 /* 02001 * TIP#143 limit handler internal representation. 02002 */ 02003 02004 struct LimitHandler { 02005 int flags; /* The state of this particular handler. */ 02006 Tcl_LimitHandlerProc *handlerProc; 02007 /* The handler callback. */ 02008 ClientData clientData; /* Opaque argument to the handler callback. */ 02009 Tcl_LimitHandlerDeleteProc *deleteProc; 02010 /* How to delete the clientData */ 02011 LimitHandler *prevPtr; /* Previous item in linked list of handlers */ 02012 LimitHandler *nextPtr; /* Next item in linked list of handlers */ 02013 }; 02014 02015 /* 02016 * Values for the LimitHandler flags field. 02017 * LIMIT_HANDLER_ACTIVE - Whether the handler is currently being 02018 * processed; handlers are never to be entered reentrantly. 02019 * LIMIT_HANDLER_DELETED - Whether the handler has been deleted. This 02020 * should not normally be observed because when a handler is 02021 * deleted it is also spliced out of the list of handlers, but 02022 * even so we will be careful. 02023 */ 02024 02025 #define LIMIT_HANDLER_ACTIVE 0x01 02026 #define LIMIT_HANDLER_DELETED 0x02 02027 02028 /* 02029 * The macro below is used to modify a "char" value (e.g. by casting it to an 02030 * unsigned character) so that it can be used safely with macros such as 02031 * isspace. 02032 */ 02033 02034 #define UCHAR(c) ((unsigned char) (c)) 02035 02036 /* 02037 * This macro is used to properly align the memory allocated by Tcl, giving 02038 * the same alignment as the native malloc 02039 */ 02040 02041 #if defined(__APPLE__) 02042 #define TCL_ALLOCALIGN 16 02043 #else 02044 #define TCL_ALLOCALIGN (2*sizeof(void *)) 02045 #endif 02046 02047 /* 02048 * This macro is used to determine the offset needed to safely allocate any 02049 * data structure in memory. Given a starting offset or size, it "rounds up" 02050 * or "aligns" the offset to the next 8-byte boundary so that any data 02051 * structure can be placed at the resulting offset without fear of an 02052 * alignment error. 02053 * 02054 * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce the 02055 * wrong result on platforms that allocate addresses that are divisible by 4 02056 * or 2. Only use it for offsets or sizes. 02057 * 02058 * This macro is only used by tclCompile.c in the core (Bug 926445). It 02059 * however not be made file static, as extensions that touch bytecodes 02060 * (notably tbcload) require it. 02061 */ 02062 02063 #define TCL_ALIGN(x) (((int)(x) + 7) & ~7) 02064 02065 02066 /* 02067 * The following enum values are used to specify the runtime platform setting 02068 * of the tclPlatform variable. 02069 */ 02070 02071 typedef enum { 02072 TCL_PLATFORM_UNIX = 0, /* Any Unix-like OS. */ 02073 TCL_PLATFORM_WINDOWS = 2 /* Any Microsoft Windows OS. */ 02074 } TclPlatformType; 02075 02076 /* 02077 * The following enum values are used to indicate the translation of a Tcl 02078 * channel. Declared here so that each platform can define 02079 * TCL_PLATFORM_TRANSLATION to the native translation on that platform 02080 */ 02081 02082 typedef enum TclEolTranslation { 02083 TCL_TRANSLATE_AUTO, /* Eol == \r, \n and \r\n. */ 02084 TCL_TRANSLATE_CR, /* Eol == \r. */ 02085 TCL_TRANSLATE_LF, /* Eol == \n. */ 02086 TCL_TRANSLATE_CRLF /* Eol == \r\n. */ 02087 } TclEolTranslation; 02088 02089 /* 02090 * Flags for TclInvoke: 02091 * 02092 * TCL_INVOKE_HIDDEN Invoke a hidden command; if not set, invokes 02093 * an exposed command. 02094 * TCL_INVOKE_NO_UNKNOWN If set, "unknown" is not invoked if the 02095 * command to be invoked is not found. Only has 02096 * an effect if invoking an exposed command, 02097 * i.e. if TCL_INVOKE_HIDDEN is not also set. 02098 * TCL_INVOKE_NO_TRACEBACK Does not record traceback information if the 02099 * invoked command returns an error. Used if the 02100 * caller plans on recording its own traceback 02101 * information. 02102 */ 02103 02104 #define TCL_INVOKE_HIDDEN (1<<0) 02105 #define TCL_INVOKE_NO_UNKNOWN (1<<1) 02106 #define TCL_INVOKE_NO_TRACEBACK (1<<2) 02107 02108 /* 02109 * The structure used as the internal representation of Tcl list objects. This 02110 * struct is grown (reallocated and copied) as necessary to hold all the 02111 * list's element pointers. The struct might contain more slots than currently 02112 * used to hold all element pointers. This is done to make append operations 02113 * faster. 02114 */ 02115 02116 typedef struct List { 02117 int refCount; 02118 int maxElemCount; /* Total number of element array slots. */ 02119 int elemCount; /* Current number of list elements. */ 02120 int canonicalFlag; /* Set if the string representation was 02121 * derived from the list representation. May 02122 * be ignored if there is no string rep at 02123 * all.*/ 02124 Tcl_Obj *elements; /* First list element; the struct is grown to 02125 * accomodate all elements. */ 02126 } List; 02127 02128 /* 02129 * Macro used to get the elements of a list object. 02130 */ 02131 02132 #define ListRepPtr(listPtr) \ 02133 ((List *) (listPtr)->internalRep.twoPtrValue.ptr1) 02134 02135 #define ListObjGetElements(listPtr, objc, objv) \ 02136 ((objv) = &(ListRepPtr(listPtr)->elements), \ 02137 (objc) = ListRepPtr(listPtr)->elemCount) 02138 02139 #define ListObjLength(listPtr, len) \ 02140 ((len) = ListRepPtr(listPtr)->elemCount) 02141 02142 #define TclListObjGetElements(interp, listPtr, objcPtr, objvPtr) \ 02143 (((listPtr)->typePtr == &tclListType) \ 02144 ? ((ListObjGetElements((listPtr), *(objcPtr), *(objvPtr))), TCL_OK)\ 02145 : Tcl_ListObjGetElements((interp), (listPtr), (objcPtr), (objvPtr))) 02146 02147 #define TclListObjLength(interp, listPtr, lenPtr) \ 02148 (((listPtr)->typePtr == &tclListType) \ 02149 ? ((ListObjLength((listPtr), *(lenPtr))), TCL_OK)\ 02150 : Tcl_ListObjLength((interp), (listPtr), (lenPtr))) 02151 02152 /* 02153 * Macros providing a faster path to integers: Tcl_GetLongFromObj everywhere, 02154 * Tcl_GetIntFromObj and TclGetIntForIndex on platforms where longs are ints. 02155 * 02156 * WARNING: these macros eval their args more than once. 02157 */ 02158 02159 #define TclGetLongFromObj(interp, objPtr, longPtr) \ 02160 (((objPtr)->typePtr == &tclIntType) \ 02161 ? ((*(longPtr) = (long) (objPtr)->internalRep.otherValuePtr), TCL_OK) \ 02162 : Tcl_GetLongFromObj((interp), (objPtr), (longPtr))) 02163 02164 #if (LONG_MAX == INT_MAX) 02165 #define TclGetIntFromObj(interp, objPtr, intPtr) \ 02166 (((objPtr)->typePtr == &tclIntType) \ 02167 ? ((*(intPtr) = (long) (objPtr)->internalRep.otherValuePtr), TCL_OK) \ 02168 : Tcl_GetIntFromObj((interp), (objPtr), (intPtr))) 02169 #define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \ 02170 (((objPtr)->typePtr == &tclIntType) \ 02171 ? ((*(idxPtr) = (long) (objPtr)->internalRep.otherValuePtr), TCL_OK) \ 02172 : TclGetIntForIndex((interp), (objPtr), (endValue), (idxPtr))) 02173 #else 02174 #define TclGetIntFromObj(interp, objPtr, intPtr) \ 02175 Tcl_GetIntFromObj((interp), (objPtr), (intPtr)) 02176 #define TclGetIntForIndexM(interp, objPtr, ignore, idxPtr) \ 02177 TclGetIntForIndex(interp, objPtr, ignore, idxPtr) 02178 #endif 02179 02180 /* 02181 * Flag values for TclTraceDictPath(). 02182 * 02183 * DICT_PATH_READ indicates that all entries on the path must exist but no 02184 * updates will be needed. 02185 * 02186 * DICT_PATH_UPDATE indicates that we are going to be doing an update at the 02187 * tip of the path, so duplication of shared objects should be done along the 02188 * way. 02189 * 02190 * DICT_PATH_EXISTS indicates that we are performing an existance test and a 02191 * lookup failure should therefore not be an error. If (and only if) this flag 02192 * is set, TclTraceDictPath() will return the special value 02193 * DICT_PATH_NON_EXISTENT if the path is not traceable. 02194 * 02195 * DICT_PATH_CREATE (which also requires the DICT_PATH_UPDATE bit to be set) 02196 * indicates that we are to create non-existant dictionaries on the path. 02197 */ 02198 02199 #define DICT_PATH_READ 0 02200 #define DICT_PATH_UPDATE 1 02201 #define DICT_PATH_EXISTS 2 02202 #define DICT_PATH_CREATE 5 02203 02204 #define DICT_PATH_NON_EXISTENT ((Tcl_Obj *) (void *) 1) 02205 02206 /* 02207 *---------------------------------------------------------------- 02208 * Data structures related to the filesystem internals 02209 *---------------------------------------------------------------- 02210 */ 02211 02212 /* 02213 * The version_2 filesystem is private to Tcl. As and when these changes have 02214 * been thoroughly tested and investigated a new public filesystem interface 02215 * will be released. The aim is more versatile virtual filesystem interfaces, 02216 * more efficiency in 'path' manipulation and usage, and cleaner filesystem 02217 * code internally. 02218 */ 02219 02220 #define TCL_FILESYSTEM_VERSION_2 ((Tcl_FSVersion) 0x2) 02221 typedef ClientData (TclFSGetCwdProc2) (ClientData clientData); 02222 02223 /* 02224 * The following types are used for getting and storing platform-specific file 02225 * attributes in tclFCmd.c and the various platform-versions of that file. 02226 * This is done to have as much common code as possible in the file attributes 02227 * code. For more information about the callbacks, see TclFileAttrsCmd in 02228 * tclFCmd.c. 02229 */ 02230 02231 typedef int (TclGetFileAttrProc) (Tcl_Interp *interp, int objIndex, 02232 Tcl_Obj *fileName, Tcl_Obj **attrObjPtrPtr); 02233 typedef int (TclSetFileAttrProc) (Tcl_Interp *interp, int objIndex, 02234 Tcl_Obj *fileName, Tcl_Obj *attrObjPtr); 02235 02236 typedef struct TclFileAttrProcs { 02237 TclGetFileAttrProc *getProc;/* The procedure for getting attrs. */ 02238 TclSetFileAttrProc *setProc;/* The procedure for setting attrs. */ 02239 } TclFileAttrProcs; 02240 02241 /* 02242 * Opaque handle used in pipeline routines to encapsulate platform-dependent 02243 * state. 02244 */ 02245 02246 typedef struct TclFile_ *TclFile; 02247 02248 /* 02249 * The "globParameters" argument of the function TclGlob is an or'ed 02250 * combination of the following values: 02251 */ 02252 02253 #define TCL_GLOBMODE_NO_COMPLAIN 1 02254 #define TCL_GLOBMODE_JOIN 2 02255 #define TCL_GLOBMODE_DIR 4 02256 #define TCL_GLOBMODE_TAILS 8 02257 02258 typedef enum Tcl_PathPart { 02259 TCL_PATH_DIRNAME, 02260 TCL_PATH_TAIL, 02261 TCL_PATH_EXTENSION, 02262 TCL_PATH_ROOT 02263 } Tcl_PathPart; 02264 02265 /* 02266 *---------------------------------------------------------------- 02267 * Data structures related to obsolete filesystem hooks 02268 *---------------------------------------------------------------- 02269 */ 02270 02271 typedef int (TclStatProc_) (CONST char *path, struct stat *buf); 02272 typedef int (TclAccessProc_) (CONST char *path, int mode); 02273 typedef Tcl_Channel (TclOpenFileChannelProc_) (Tcl_Interp *interp, 02274 CONST char *fileName, CONST char *modeString, int permissions); 02275 02276 /* 02277 *---------------------------------------------------------------- 02278 * Data structures related to procedures 02279 *---------------------------------------------------------------- 02280 */ 02281 02282 typedef Tcl_CmdProc *TclCmdProcType; 02283 typedef Tcl_ObjCmdProc *TclObjCmdProcType; 02284 02285 /* 02286 *---------------------------------------------------------------- 02287 * Data structures for process-global values. 02288 *---------------------------------------------------------------- 02289 */ 02290 02291 typedef void (TclInitProcessGlobalValueProc) (char **valuePtr, int *lengthPtr, 02292 Tcl_Encoding *encodingPtr); 02293 02294 /* 02295 * A ProcessGlobalValue struct exists for each internal value in Tcl that is 02296 * to be shared among several threads. Each thread sees a (Tcl_Obj) copy of 02297 * the value, and the master is kept as a counted string, with epoch and mutex 02298 * control. Each ProcessGlobalValue struct should be a static variable in some 02299 * file. 02300 */ 02301 02302 typedef struct ProcessGlobalValue { 02303 int epoch; /* Epoch counter to detect changes in the 02304 * master value. */ 02305 int numBytes; /* Length of the master string. */ 02306 char *value; /* The master string value. */ 02307 Tcl_Encoding encoding; /* system encoding when master string was 02308 * initialized. */ 02309 TclInitProcessGlobalValueProc *proc; 02310 /* A procedure to initialize the master string 02311 * copy when a "get" request comes in before 02312 * any "set" request has been received. */ 02313 Tcl_Mutex mutex; /* Enforce orderly access from multiple 02314 * threads. */ 02315 Tcl_ThreadDataKey key; /* Key for per-thread data holding the 02316 * (Tcl_Obj) copy for each thread. */ 02317 } ProcessGlobalValue; 02318 02319 /* 02320 *---------------------------------------------------------------------- 02321 * Flags for TclParseNumber 02322 *---------------------------------------------------------------------- 02323 */ 02324 02325 #define TCL_PARSE_DECIMAL_ONLY 1 02326 /* Leading zero doesn't denote octal or hex */ 02327 #define TCL_PARSE_OCTAL_ONLY 2 02328 /* Parse octal even without prefix */ 02329 #define TCL_PARSE_HEXADECIMAL_ONLY 4 02330 /* Parse hexadecimal even without prefix */ 02331 #define TCL_PARSE_INTEGER_ONLY 8 02332 /* Disable floating point parsing */ 02333 #define TCL_PARSE_SCAN_PREFIXES 16 02334 /* Use [scan] rules dealing with 0? prefixes */ 02335 #define TCL_PARSE_NO_WHITESPACE 32 02336 /* Reject leading/trailing whitespace */ 02337 02338 /* 02339 *---------------------------------------------------------------------- 02340 * Type values TclGetNumberFromObj 02341 *---------------------------------------------------------------------- 02342 */ 02343 02344 #define TCL_NUMBER_LONG 1 02345 #define TCL_NUMBER_WIDE 2 02346 #define TCL_NUMBER_BIG 3 02347 #define TCL_NUMBER_DOUBLE 4 02348 #define TCL_NUMBER_NAN 5 02349 02350 /* 02351 *---------------------------------------------------------------- 02352 * Variables shared among Tcl modules but not used by the outside world. 02353 *---------------------------------------------------------------- 02354 */ 02355 02356 MODULE_SCOPE char * tclNativeExecutableName; 02357 MODULE_SCOPE int tclFindExecutableSearchDone; 02358 MODULE_SCOPE char * tclMemDumpFileName; 02359 MODULE_SCOPE TclPlatformType tclPlatform; 02360 MODULE_SCOPE Tcl_NotifierProcs tclOriginalNotifier; 02361 02362 /* 02363 * TIP #233 (Virtualized Time) 02364 * Data for the time hooks, if any. 02365 */ 02366 02367 MODULE_SCOPE Tcl_GetTimeProc* tclGetTimeProcPtr; 02368 MODULE_SCOPE Tcl_ScaleTimeProc* tclScaleTimeProcPtr; 02369 MODULE_SCOPE ClientData tclTimeClientData; 02370 02371 /* 02372 * Variables denoting the Tcl object types defined in the core. 02373 */ 02374 02375 MODULE_SCOPE Tcl_ObjType tclBignumType; 02376 MODULE_SCOPE Tcl_ObjType tclBooleanType; 02377 MODULE_SCOPE Tcl_ObjType tclByteArrayType; 02378 MODULE_SCOPE Tcl_ObjType tclByteCodeType; 02379 MODULE_SCOPE Tcl_ObjType tclDoubleType; 02380 MODULE_SCOPE Tcl_ObjType tclEndOffsetType; 02381 MODULE_SCOPE Tcl_ObjType tclIntType; 02382 MODULE_SCOPE Tcl_ObjType tclListType; 02383 MODULE_SCOPE Tcl_ObjType tclDictType; 02384 MODULE_SCOPE Tcl_ObjType tclProcBodyType; 02385 MODULE_SCOPE Tcl_ObjType tclStringType; 02386 MODULE_SCOPE Tcl_ObjType tclArraySearchType; 02387 MODULE_SCOPE Tcl_ObjType tclEnsembleCmdType; 02388 #ifndef NO_WIDE_TYPE 02389 MODULE_SCOPE Tcl_ObjType tclWideIntType; 02390 #endif 02391 MODULE_SCOPE Tcl_ObjType tclRegexpType; 02392 02393 /* 02394 * Variables denoting the hash key types defined in the core. 02395 */ 02396 02397 MODULE_SCOPE Tcl_HashKeyType tclArrayHashKeyType; 02398 MODULE_SCOPE Tcl_HashKeyType tclOneWordHashKeyType; 02399 MODULE_SCOPE Tcl_HashKeyType tclStringHashKeyType; 02400 MODULE_SCOPE Tcl_HashKeyType tclObjHashKeyType; 02401 02402 /* 02403 * The head of the list of free Tcl objects, and the total number of Tcl 02404 * objects ever allocated and freed. 02405 */ 02406 02407 MODULE_SCOPE Tcl_Obj * tclFreeObjList; 02408 02409 #ifdef TCL_COMPILE_STATS 02410 MODULE_SCOPE long tclObjsAlloced; 02411 MODULE_SCOPE long tclObjsFreed; 02412 #define TCL_MAX_SHARED_OBJ_STATS 5 02413 MODULE_SCOPE long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS]; 02414 #endif /* TCL_COMPILE_STATS */ 02415 02416 /* 02417 * Pointer to a heap-allocated string of length zero that the Tcl core uses as 02418 * the value of an empty string representation for an object. This value is 02419 * shared by all new objects allocated by Tcl_NewObj. 02420 */ 02421 02422 MODULE_SCOPE char * tclEmptyStringRep; 02423 MODULE_SCOPE char tclEmptyString; 02424 02425 /* 02426 *---------------------------------------------------------------- 02427 * Procedures shared among Tcl modules but not used by the outside world: 02428 *---------------------------------------------------------------- 02429 */ 02430 02431 MODULE_SCOPE void TclAdvanceLines(int *line, const char *start, 02432 const char *end); 02433 MODULE_SCOPE int TclArraySet(Tcl_Interp *interp, 02434 Tcl_Obj *arrayNameObj, Tcl_Obj *arrayElemObj); 02435 MODULE_SCOPE double TclBignumToDouble(mp_int *bignum); 02436 MODULE_SCOPE int TclByteArrayMatch(const unsigned char *string, 02437 int strLen, const unsigned char *pattern, 02438 int ptnLen, int flags); 02439 MODULE_SCOPE double TclCeil(mp_int *a); 02440 MODULE_SCOPE int TclCheckBadOctal(Tcl_Interp *interp,const char *value); 02441 MODULE_SCOPE int TclChanCaughtErrorBypass(Tcl_Interp *interp, 02442 Tcl_Channel chan); 02443 MODULE_SCOPE void TclCleanupLiteralTable(Tcl_Interp *interp, 02444 LiteralTable *tablePtr); 02445 MODULE_SCOPE int TclDoubleDigits(char *buf, double value, int *signum); 02446 MODULE_SCOPE void TclDeleteNamespaceVars(Namespace *nsPtr); 02447 /* TIP #280 - Modified token based evulation, with line information */ 02448 MODULE_SCOPE int TclEvalEx(Tcl_Interp *interp, const char *script, 02449 int numBytes, int flags, int line); 02450 MODULE_SCOPE int TclFileAttrsCmd(Tcl_Interp *interp, 02451 int objc, Tcl_Obj *const objv[]); 02452 MODULE_SCOPE int TclFileCopyCmd(Tcl_Interp *interp, 02453 int objc, Tcl_Obj *const objv[]); 02454 MODULE_SCOPE int TclFileDeleteCmd(Tcl_Interp *interp, 02455 int objc, Tcl_Obj *const objv[]); 02456 MODULE_SCOPE int TclFileMakeDirsCmd(Tcl_Interp *interp, 02457 int objc, Tcl_Obj *const objv[]); 02458 MODULE_SCOPE int TclFileRenameCmd(Tcl_Interp *interp, 02459 int objc, Tcl_Obj *const objv[]); 02460 MODULE_SCOPE void TclFinalizeAllocSubsystem(void); 02461 MODULE_SCOPE void TclFinalizeAsync(void); 02462 MODULE_SCOPE void TclFinalizeDoubleConversion(void); 02463 MODULE_SCOPE void TclFinalizeEncodingSubsystem(void); 02464 MODULE_SCOPE void TclFinalizeEnvironment(void); 02465 MODULE_SCOPE void TclFinalizeExecution(void); 02466 MODULE_SCOPE void TclFinalizeIOSubsystem(void); 02467 MODULE_SCOPE void TclFinalizeFilesystem(void); 02468 MODULE_SCOPE void TclResetFilesystem(void); 02469 MODULE_SCOPE void TclFinalizeLoad(void); 02470 MODULE_SCOPE void TclFinalizeLock(void); 02471 MODULE_SCOPE void TclFinalizeMemorySubsystem(void); 02472 MODULE_SCOPE void TclFinalizeNotifier(void); 02473 MODULE_SCOPE void TclFinalizeObjects(void); 02474 MODULE_SCOPE void TclFinalizePreserve(void); 02475 MODULE_SCOPE void TclFinalizeSynchronization(void); 02476 MODULE_SCOPE void TclFinalizeThreadAlloc(void); 02477 MODULE_SCOPE void TclFinalizeThreadData(void); 02478 MODULE_SCOPE double TclFloor(mp_int *a); 02479 MODULE_SCOPE void TclFormatNaN(double value, char *buffer); 02480 MODULE_SCOPE int TclFSFileAttrIndex(Tcl_Obj *pathPtr, 02481 const char *attributeName, int *indexPtr); 02482 MODULE_SCOPE int * TclGetAsyncReadyPtr(void); 02483 MODULE_SCOPE Tcl_Obj * TclGetBgErrorHandler(Tcl_Interp *interp); 02484 MODULE_SCOPE int TclGetChannelFromObj(Tcl_Interp *interp, 02485 Tcl_Obj *objPtr, Tcl_Channel *chanPtr, 02486 int *modePtr, int flags); 02487 MODULE_SCOPE int TclGetNumberFromObj(Tcl_Interp *interp, 02488 Tcl_Obj *objPtr, ClientData *clientDataPtr, 02489 int *typePtr); 02490 MODULE_SCOPE int TclGetOpenModeEx(Tcl_Interp *interp, 02491 const char *modeString, int *seekFlagPtr, 02492 int *binaryPtr); 02493 MODULE_SCOPE Tcl_Obj * TclGetProcessGlobalValue(ProcessGlobalValue *pgvPtr); 02494 MODULE_SCOPE const char *TclGetSrcInfoForCmd(Interp *iPtr, int *lenPtr); 02495 MODULE_SCOPE int TclGlob(Tcl_Interp *interp, char *pattern, 02496 Tcl_Obj *unquotedPrefix, int globFlags, 02497 Tcl_GlobTypeData *types); 02498 MODULE_SCOPE int TclIncrObj(Tcl_Interp *interp, Tcl_Obj *valuePtr, 02499 Tcl_Obj *incrPtr); 02500 MODULE_SCOPE Tcl_Obj * TclIncrObjVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, 02501 Tcl_Obj *part2Ptr, Tcl_Obj *incrPtr, int flags); 02502 MODULE_SCOPE int TclInfoExistsCmd(ClientData dummy, Tcl_Interp *interp, 02503 int objc, Tcl_Obj *const objv[]); 02504 MODULE_SCOPE Tcl_Obj * TclInfoFrame(Tcl_Interp *interp, CmdFrame *framePtr); 02505 MODULE_SCOPE int TclInfoGlobalsCmd(ClientData dummy, Tcl_Interp *interp, 02506 int objc, Tcl_Obj *const objv[]); 02507 MODULE_SCOPE int TclInfoLocalsCmd(ClientData dummy, Tcl_Interp *interp, 02508 int objc, Tcl_Obj *const objv[]); 02509 MODULE_SCOPE int TclInfoVarsCmd(ClientData dummy, Tcl_Interp *interp, 02510 int objc, Tcl_Obj *const objv[]); 02511 MODULE_SCOPE void TclInitAlloc(void); 02512 MODULE_SCOPE void TclInitDbCkalloc(void); 02513 MODULE_SCOPE void TclInitDoubleConversion(void); 02514 MODULE_SCOPE void TclInitEmbeddedConfigurationInformation( 02515 Tcl_Interp *interp); 02516 MODULE_SCOPE void TclInitEncodingSubsystem(void); 02517 MODULE_SCOPE void TclInitIOSubsystem(void); 02518 MODULE_SCOPE void TclInitLimitSupport(Tcl_Interp *interp); 02519 MODULE_SCOPE void TclInitNamespaceSubsystem(void); 02520 MODULE_SCOPE void TclInitNotifier(void); 02521 MODULE_SCOPE void TclInitObjSubsystem(void); 02522 MODULE_SCOPE void TclInitSubsystems(void); 02523 MODULE_SCOPE int TclInterpReady(Tcl_Interp *interp); 02524 MODULE_SCOPE int TclIsLocalScalar(const char *src, int len); 02525 MODULE_SCOPE int TclJoinThread(Tcl_ThreadId id, int *result); 02526 MODULE_SCOPE void TclLimitRemoveAllHandlers(Tcl_Interp *interp); 02527 MODULE_SCOPE Tcl_Obj * TclLindexList(Tcl_Interp *interp, 02528 Tcl_Obj *listPtr, Tcl_Obj *argPtr); 02529 MODULE_SCOPE Tcl_Obj * TclLindexFlat(Tcl_Interp *interp, Tcl_Obj *listPtr, 02530 int indexCount, Tcl_Obj *const indexArray[]); 02531 /* TIP #280 */ 02532 MODULE_SCOPE void TclListLines(const char *listStr, int line, int n, 02533 int *lines); 02534 MODULE_SCOPE Tcl_Obj * TclListObjCopy(Tcl_Interp *interp, Tcl_Obj *listPtr); 02535 MODULE_SCOPE int TclLoadFile(Tcl_Interp *interp, Tcl_Obj *pathPtr, 02536 int symc, const char *symbols[], 02537 Tcl_PackageInitProc **procPtrs[], 02538 Tcl_LoadHandle *handlePtr, 02539 ClientData *clientDataPtr, 02540 Tcl_FSUnloadFileProc **unloadProcPtr); 02541 MODULE_SCOPE Tcl_Obj * TclLsetList(Tcl_Interp *interp, Tcl_Obj *listPtr, 02542 Tcl_Obj *indexPtr, Tcl_Obj *valuePtr); 02543 MODULE_SCOPE Tcl_Obj * TclLsetFlat(Tcl_Interp *interp, Tcl_Obj *listPtr, 02544 int indexCount, Tcl_Obj *const indexArray[], 02545 Tcl_Obj *valuePtr); 02546 MODULE_SCOPE Tcl_Command TclMakeEnsemble(Tcl_Interp *interp, const char *name, 02547 const EnsembleImplMap map[]); 02548 MODULE_SCOPE int TclMarkList(Tcl_Interp *interp, const char *list, 02549 const char *end, int *argcPtr, 02550 const int **argszPtr, const char ***argvPtr); 02551 MODULE_SCOPE int TclMergeReturnOptions(Tcl_Interp *interp, int objc, 02552 Tcl_Obj *const objv[], Tcl_Obj **optionsPtrPtr, 02553 int *codePtr, int *levelPtr); 02554 MODULE_SCOPE int TclNokia770Doubles(); 02555 MODULE_SCOPE void TclObjVarErrMsg(Tcl_Interp *interp, Tcl_Obj *part1Ptr, 02556 Tcl_Obj *part2Ptr, const char *operation, 02557 const char *reason, int index); 02558 MODULE_SCOPE int TclObjInvokeNamespace(Tcl_Interp *interp, 02559 int objc, Tcl_Obj *const objv[], 02560 Tcl_Namespace *nsPtr, int flags); 02561 MODULE_SCOPE int TclObjUnsetVar2(Tcl_Interp *interp, 02562 Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags); 02563 MODULE_SCOPE int TclParseBackslash(const char *src, 02564 int numBytes, int *readPtr, char *dst); 02565 MODULE_SCOPE int TclParseHex(const char *src, int numBytes, 02566 Tcl_UniChar *resultPtr); 02567 MODULE_SCOPE int TclParseNumber(Tcl_Interp *interp, Tcl_Obj *objPtr, 02568 const char *expected, const char *bytes, 02569 int numBytes, const char **endPtrPtr, int flags); 02570 MODULE_SCOPE void TclParseInit(Tcl_Interp *interp, const char *string, 02571 int numBytes, Tcl_Parse *parsePtr); 02572 MODULE_SCOPE int TclParseAllWhiteSpace(const char *src, int numBytes); 02573 MODULE_SCOPE int TclProcessReturn(Tcl_Interp *interp, 02574 int code, int level, Tcl_Obj *returnOpts); 02575 #ifndef TCL_NO_STACK_CHECK 02576 MODULE_SCOPE int TclpGetCStackParams(int **stackBoundPtr); 02577 #endif 02578 MODULE_SCOPE int TclpObjLstat(Tcl_Obj *pathPtr, Tcl_StatBuf *buf); 02579 MODULE_SCOPE Tcl_Obj * TclpTempFileName(void); 02580 MODULE_SCOPE Tcl_Obj * TclNewFSPathObj(Tcl_Obj *dirPtr, const char *addStrRep, 02581 int len); 02582 MODULE_SCOPE int TclpDeleteFile(const char *path); 02583 MODULE_SCOPE void TclpFinalizeCondition(Tcl_Condition *condPtr); 02584 MODULE_SCOPE void TclpFinalizeMutex(Tcl_Mutex *mutexPtr); 02585 MODULE_SCOPE void TclpFinalizePipes(void); 02586 MODULE_SCOPE void TclpFinalizeSockets(void); 02587 MODULE_SCOPE int TclpThreadCreate(Tcl_ThreadId *idPtr, 02588 Tcl_ThreadCreateProc proc, ClientData clientData, 02589 int stackSize, int flags); 02590 MODULE_SCOPE int TclpFindVariable(const char *name, int *lengthPtr); 02591 MODULE_SCOPE void TclpInitLibraryPath(char **valuePtr, 02592 int *lengthPtr, Tcl_Encoding *encodingPtr); 02593 MODULE_SCOPE void TclpInitLock(void); 02594 MODULE_SCOPE void TclpInitPlatform(void); 02595 MODULE_SCOPE void TclpInitUnlock(void); 02596 MODULE_SCOPE int TclpLoadFile(Tcl_Interp *interp, Tcl_Obj *pathPtr, 02597 const char *sym1, const char *sym2, 02598 Tcl_PackageInitProc **proc1Ptr, 02599 Tcl_PackageInitProc **proc2Ptr, 02600 ClientData *clientDataPtr, 02601 Tcl_FSUnloadFileProc **unloadProcPtr); 02602 MODULE_SCOPE Tcl_Obj * TclpObjListVolumes(void); 02603 MODULE_SCOPE void TclpMasterLock(void); 02604 MODULE_SCOPE void TclpMasterUnlock(void); 02605 MODULE_SCOPE int TclpMatchFiles(Tcl_Interp *interp, char *separators, 02606 Tcl_DString *dirPtr, char *pattern, char *tail); 02607 MODULE_SCOPE int TclpObjNormalizePath(Tcl_Interp *interp, 02608 Tcl_Obj *pathPtr, int nextCheckpoint); 02609 MODULE_SCOPE void TclpNativeJoinPath(Tcl_Obj *prefix, char *joining); 02610 MODULE_SCOPE Tcl_Obj * TclpNativeSplitPath(Tcl_Obj *pathPtr, int *lenPtr); 02611 MODULE_SCOPE Tcl_PathType TclpGetNativePathType(Tcl_Obj *pathPtr, 02612 int *driveNameLengthPtr, Tcl_Obj **driveNameRef); 02613 MODULE_SCOPE int TclCrossFilesystemCopy(Tcl_Interp *interp, 02614 Tcl_Obj *source, Tcl_Obj *target); 02615 MODULE_SCOPE int TclpMatchInDirectory(Tcl_Interp *interp, 02616 Tcl_Obj *resultPtr, Tcl_Obj *pathPtr, 02617 const char *pattern, Tcl_GlobTypeData *types); 02618 MODULE_SCOPE ClientData TclpGetNativeCwd(ClientData clientData); 02619 MODULE_SCOPE Tcl_FSDupInternalRepProc TclNativeDupInternalRep; 02620 MODULE_SCOPE Tcl_Obj* TclpObjLink(Tcl_Obj *pathPtr, Tcl_Obj *toPtr, 02621 int linkType); 02622 MODULE_SCOPE int TclpObjChdir(Tcl_Obj *pathPtr); 02623 MODULE_SCOPE Tcl_Obj * TclPathPart(Tcl_Interp *interp, Tcl_Obj *pathPtr, 02624 Tcl_PathPart portion); 02625 MODULE_SCOPE void TclpPanic(const char *format, ...); 02626 MODULE_SCOPE char * TclpReadlink(const char *fileName, 02627 Tcl_DString *linkPtr); 02628 MODULE_SCOPE void TclpReleaseFile(TclFile file); 02629 MODULE_SCOPE void TclpSetInterfaces(void); 02630 MODULE_SCOPE void TclpSetVariables(Tcl_Interp *interp); 02631 MODULE_SCOPE void TclpUnloadFile(Tcl_LoadHandle loadHandle); 02632 MODULE_SCOPE void * TclpThreadDataKeyGet(Tcl_ThreadDataKey *keyPtr); 02633 MODULE_SCOPE void TclpThreadDataKeySet(Tcl_ThreadDataKey *keyPtr, 02634 void *data); 02635 MODULE_SCOPE void TclpThreadExit(int status); 02636 MODULE_SCOPE size_t TclpThreadGetStackSize(void); 02637 MODULE_SCOPE void TclRememberCondition(Tcl_Condition *mutex); 02638 MODULE_SCOPE void TclRememberJoinableThread(Tcl_ThreadId id); 02639 MODULE_SCOPE void TclRememberMutex(Tcl_Mutex *mutex); 02640 MODULE_SCOPE void TclRemoveScriptLimitCallbacks(Tcl_Interp *interp); 02641 MODULE_SCOPE int TclReToGlob(Tcl_Interp *interp, const char *reStr, 02642 int reStrLen, Tcl_DString *dsPtr, int *flagsPtr); 02643 MODULE_SCOPE void TclSetBgErrorHandler(Tcl_Interp *interp, 02644 Tcl_Obj *cmdPrefix); 02645 MODULE_SCOPE void TclSetBignumIntRep(Tcl_Obj *objPtr, 02646 mp_int *bignumValue); 02647 MODULE_SCOPE void TclSetCmdNameObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 02648 Command *cmdPtr); 02649 MODULE_SCOPE void TclSetProcessGlobalValue(ProcessGlobalValue *pgvPtr, 02650 Tcl_Obj *newValue, Tcl_Encoding encoding); 02651 MODULE_SCOPE void TclSignalExitThread(Tcl_ThreadId id, int result); 02652 MODULE_SCOPE void * TclStackRealloc(Tcl_Interp *interp, void *ptr, 02653 int numBytes); 02654 MODULE_SCOPE int TclStringMatch(const char *str, int strLen, 02655 const char *pattern, int ptnLen, int flags); 02656 MODULE_SCOPE int TclStringMatchObj(Tcl_Obj *stringObj, 02657 Tcl_Obj *patternObj, int flags); 02658 MODULE_SCOPE Tcl_Obj * TclStringObjReverse(Tcl_Obj *objPtr); 02659 MODULE_SCOPE int TclSubstTokens(Tcl_Interp *interp, Tcl_Token *tokenPtr, 02660 int count, int *tokensLeftPtr, int line); 02661 MODULE_SCOPE void TclTransferResult(Tcl_Interp *sourceInterp, int result, 02662 Tcl_Interp *targetInterp); 02663 MODULE_SCOPE Tcl_Obj * TclpNativeToNormalized(ClientData clientData); 02664 MODULE_SCOPE Tcl_Obj * TclpFilesystemPathType(Tcl_Obj *pathPtr); 02665 MODULE_SCOPE Tcl_PackageInitProc *TclpFindSymbol(Tcl_Interp *interp, 02666 Tcl_LoadHandle loadHandle, const char *symbol); 02667 MODULE_SCOPE int TclpDlopen(Tcl_Interp *interp, Tcl_Obj *pathPtr, 02668 Tcl_LoadHandle *loadHandle, 02669 Tcl_FSUnloadFileProc **unloadProcPtr); 02670 MODULE_SCOPE int TclpUtime(Tcl_Obj *pathPtr, struct utimbuf *tval); 02671 #ifdef TCL_LOAD_FROM_MEMORY 02672 MODULE_SCOPE void* TclpLoadMemoryGetBuffer(Tcl_Interp *interp, int size); 02673 MODULE_SCOPE int TclpLoadMemory(Tcl_Interp *interp, void *buffer, 02674 int size, int codeSize, Tcl_LoadHandle *loadHandle, 02675 Tcl_FSUnloadFileProc **unloadProcPtr); 02676 #endif 02677 MODULE_SCOPE void TclInitThreadStorage(void); 02678 MODULE_SCOPE void TclpFinalizeThreadDataThread(void); 02679 MODULE_SCOPE void TclFinalizeThreadStorage(void); 02680 #ifdef TCL_WIDE_CLICKS 02681 MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void); 02682 MODULE_SCOPE double TclpWideClicksToNanoseconds(Tcl_WideInt clicks); 02683 #endif 02684 MODULE_SCOPE Tcl_Obj * TclDisassembleByteCodeObj(Tcl_Obj *objPtr); 02685 02686 /* 02687 *---------------------------------------------------------------- 02688 * Command procedures in the generic core: 02689 *---------------------------------------------------------------- 02690 */ 02691 02692 MODULE_SCOPE int Tcl_AfterObjCmd(ClientData clientData, 02693 Tcl_Interp *interp, int objc, 02694 Tcl_Obj *const objv[]); 02695 MODULE_SCOPE int Tcl_AppendObjCmd(ClientData clientData, 02696 Tcl_Interp *interp, int objc, 02697 Tcl_Obj *const objv[]); 02698 MODULE_SCOPE int Tcl_ApplyObjCmd(ClientData clientData, 02699 Tcl_Interp *interp, int objc, 02700 Tcl_Obj *const objv[]); 02701 MODULE_SCOPE int Tcl_ArrayObjCmd(ClientData clientData, 02702 Tcl_Interp *interp, int objc, 02703 Tcl_Obj *const objv[]); 02704 MODULE_SCOPE int Tcl_BinaryObjCmd(ClientData clientData, 02705 Tcl_Interp *interp, int objc, 02706 Tcl_Obj *const objv[]); 02707 MODULE_SCOPE int Tcl_BreakObjCmd(ClientData clientData, 02708 Tcl_Interp *interp, int objc, 02709 Tcl_Obj *const objv[]); 02710 MODULE_SCOPE int Tcl_CaseObjCmd(ClientData clientData, 02711 Tcl_Interp *interp, int objc, 02712 Tcl_Obj *const objv[]); 02713 MODULE_SCOPE int Tcl_CatchObjCmd(ClientData clientData, 02714 Tcl_Interp *interp, int objc, 02715 Tcl_Obj *const objv[]); 02716 MODULE_SCOPE int Tcl_CdObjCmd(ClientData clientData, 02717 Tcl_Interp *interp, int objc, 02718 Tcl_Obj *const objv[]); 02719 MODULE_SCOPE Tcl_Command TclInitChanCmd(Tcl_Interp *interp); 02720 MODULE_SCOPE int TclChanCreateObjCmd(ClientData clientData, 02721 Tcl_Interp *interp, int objc, 02722 Tcl_Obj *const objv[]); 02723 MODULE_SCOPE int TclChanPostEventObjCmd(ClientData clientData, 02724 Tcl_Interp *interp, int objc, 02725 Tcl_Obj *const objv[]); 02726 MODULE_SCOPE void TclClockInit(Tcl_Interp *interp); 02727 MODULE_SCOPE int TclClockOldscanObjCmd( 02728 ClientData clientData, Tcl_Interp *interp, 02729 int objc, Tcl_Obj *const objv[]); 02730 MODULE_SCOPE int Tcl_CloseObjCmd(ClientData clientData, 02731 Tcl_Interp *interp, int objc, 02732 Tcl_Obj *const objv[]); 02733 MODULE_SCOPE int Tcl_ConcatObjCmd(ClientData clientData, 02734 Tcl_Interp *interp, int objc, 02735 Tcl_Obj *const objv[]); 02736 MODULE_SCOPE int Tcl_ContinueObjCmd(ClientData clientData, 02737 Tcl_Interp *interp, int objc, 02738 Tcl_Obj *const objv[]); 02739 MODULE_SCOPE Tcl_TimerToken TclCreateAbsoluteTimerHandler( 02740 Tcl_Time *timePtr, Tcl_TimerProc *proc, 02741 ClientData clientData); 02742 MODULE_SCOPE int TclDefaultBgErrorHandlerObjCmd( 02743 ClientData clientData, Tcl_Interp *interp, 02744 int objc, Tcl_Obj *const objv[]); 02745 MODULE_SCOPE Tcl_Command TclInitDictCmd(Tcl_Interp *interp); 02746 MODULE_SCOPE int Tcl_DisassembleObjCmd(ClientData clientData, 02747 Tcl_Interp *interp, int objc, 02748 Tcl_Obj *const objv[]); 02749 MODULE_SCOPE int Tcl_EncodingObjCmd(ClientData clientData, 02750 Tcl_Interp *interp, int objc, 02751 Tcl_Obj *const objv[]); 02752 MODULE_SCOPE int Tcl_EofObjCmd(ClientData clientData, 02753 Tcl_Interp *interp, int objc, 02754 Tcl_Obj *const objv[]); 02755 MODULE_SCOPE int Tcl_ErrorObjCmd(ClientData clientData, 02756 Tcl_Interp *interp, int objc, 02757 Tcl_Obj *const objv[]); 02758 MODULE_SCOPE int Tcl_EvalObjCmd(ClientData clientData, 02759 Tcl_Interp *interp, int objc, 02760 Tcl_Obj *const objv[]); 02761 MODULE_SCOPE int Tcl_ExecObjCmd(ClientData clientData, 02762 Tcl_Interp *interp, int objc, 02763 Tcl_Obj *const objv[]); 02764 MODULE_SCOPE int Tcl_ExitObjCmd(ClientData clientData, 02765 Tcl_Interp *interp, int objc, 02766 Tcl_Obj *const objv[]); 02767 MODULE_SCOPE int Tcl_ExprObjCmd(ClientData clientData, 02768 Tcl_Interp *interp, int objc, 02769 Tcl_Obj *const objv[]); 02770 MODULE_SCOPE int Tcl_FblockedObjCmd(ClientData clientData, 02771 Tcl_Interp *interp, int objc, 02772 Tcl_Obj *const objv[]); 02773 MODULE_SCOPE int Tcl_FconfigureObjCmd( 02774 ClientData clientData, Tcl_Interp *interp, 02775 int objc, Tcl_Obj *const objv[]); 02776 MODULE_SCOPE int Tcl_FcopyObjCmd(ClientData dummy, 02777 Tcl_Interp *interp, int objc, 02778 Tcl_Obj *const objv[]); 02779 MODULE_SCOPE int Tcl_FileObjCmd(ClientData dummy, 02780 Tcl_Interp *interp, int objc, 02781 Tcl_Obj *const objv[]); 02782 MODULE_SCOPE int Tcl_FileEventObjCmd(ClientData clientData, 02783 Tcl_Interp *interp, int objc, 02784 Tcl_Obj *const objv[]); 02785 MODULE_SCOPE int Tcl_FlushObjCmd(ClientData clientData, 02786 Tcl_Interp *interp, int objc, 02787 Tcl_Obj *const objv[]); 02788 MODULE_SCOPE int Tcl_ForObjCmd(ClientData clientData, 02789 Tcl_Interp *interp, int objc, 02790 Tcl_Obj *const objv[]); 02791 MODULE_SCOPE int Tcl_ForeachObjCmd(ClientData clientData, 02792 Tcl_Interp *interp, int objc, 02793 Tcl_Obj *const objv[]); 02794 MODULE_SCOPE int Tcl_FormatObjCmd(ClientData dummy, 02795 Tcl_Interp *interp, int objc, 02796 Tcl_Obj *const objv[]); 02797 MODULE_SCOPE int Tcl_GetsObjCmd(ClientData clientData, 02798 Tcl_Interp *interp, int objc, 02799 Tcl_Obj *const objv[]); 02800 MODULE_SCOPE int Tcl_GlobalObjCmd(ClientData clientData, 02801 Tcl_Interp *interp, int objc, 02802 Tcl_Obj *const objv[]); 02803 MODULE_SCOPE int Tcl_GlobObjCmd(ClientData clientData, 02804 Tcl_Interp *interp, int objc, 02805 Tcl_Obj *const objv[]); 02806 MODULE_SCOPE int Tcl_IfObjCmd(ClientData clientData, 02807 Tcl_Interp *interp, int objc, 02808 Tcl_Obj *const objv[]); 02809 MODULE_SCOPE int Tcl_IncrObjCmd(ClientData clientData, 02810 Tcl_Interp *interp, int objc, 02811 Tcl_Obj *const objv[]); 02812 MODULE_SCOPE Tcl_Command TclInitInfoCmd(Tcl_Interp *interp); 02813 MODULE_SCOPE int Tcl_InterpObjCmd(ClientData clientData, 02814 Tcl_Interp *interp, int argc, 02815 Tcl_Obj *const objv[]); 02816 MODULE_SCOPE int Tcl_JoinObjCmd(ClientData clientData, 02817 Tcl_Interp *interp, int objc, 02818 Tcl_Obj *const objv[]); 02819 MODULE_SCOPE int Tcl_LappendObjCmd(ClientData clientData, 02820 Tcl_Interp *interp, int objc, 02821 Tcl_Obj *const objv[]); 02822 MODULE_SCOPE int Tcl_LassignObjCmd(ClientData clientData, 02823 Tcl_Interp *interp, int objc, 02824 Tcl_Obj *const objv[]); 02825 MODULE_SCOPE int Tcl_LindexObjCmd(ClientData clientData, 02826 Tcl_Interp *interp, int objc, 02827 Tcl_Obj *const objv[]); 02828 MODULE_SCOPE int Tcl_LinsertObjCmd(ClientData clientData, 02829 Tcl_Interp *interp, int objc, 02830 Tcl_Obj *const objv[]); 02831 MODULE_SCOPE int Tcl_LlengthObjCmd(ClientData clientData, 02832 Tcl_Interp *interp, int objc, 02833 Tcl_Obj *const objv[]); 02834 MODULE_SCOPE int Tcl_ListObjCmd(ClientData clientData, 02835 Tcl_Interp *interp, int objc, 02836 Tcl_Obj *const objv[]); 02837 MODULE_SCOPE int Tcl_LoadObjCmd(ClientData clientData, 02838 Tcl_Interp *interp, int objc, 02839 Tcl_Obj *const objv[]); 02840 MODULE_SCOPE int Tcl_LrangeObjCmd(ClientData clientData, 02841 Tcl_Interp *interp, int objc, 02842 Tcl_Obj *const objv[]); 02843 MODULE_SCOPE int Tcl_LrepeatObjCmd(ClientData clientData, 02844 Tcl_Interp *interp, int objc, 02845 Tcl_Obj *const objv[]); 02846 MODULE_SCOPE int Tcl_LreplaceObjCmd(ClientData clientData, 02847 Tcl_Interp *interp, int objc, 02848 Tcl_Obj *const objv[]); 02849 MODULE_SCOPE int Tcl_LreverseObjCmd(ClientData clientData, 02850 Tcl_Interp *interp, int objc, 02851 Tcl_Obj *const objv[]); 02852 MODULE_SCOPE int Tcl_LsearchObjCmd(ClientData clientData, 02853 Tcl_Interp *interp, int objc, 02854 Tcl_Obj *const objv[]); 02855 MODULE_SCOPE int Tcl_LsetObjCmd(ClientData clientData, 02856 Tcl_Interp *interp, int objc, 02857 Tcl_Obj *const objv[]); 02858 MODULE_SCOPE int Tcl_LsortObjCmd(ClientData clientData, 02859 Tcl_Interp *interp, int objc, 02860 Tcl_Obj *const objv[]); 02861 MODULE_SCOPE int Tcl_NamespaceObjCmd(ClientData clientData, 02862 Tcl_Interp *interp, int objc, 02863 Tcl_Obj *const objv[]); 02864 MODULE_SCOPE int Tcl_OpenObjCmd(ClientData clientData, 02865 Tcl_Interp *interp, int objc, 02866 Tcl_Obj *const objv[]); 02867 MODULE_SCOPE int Tcl_PackageObjCmd(ClientData clientData, 02868 Tcl_Interp *interp, int objc, 02869 Tcl_Obj *const objv[]); 02870 MODULE_SCOPE int Tcl_PidObjCmd(ClientData clientData, 02871 Tcl_Interp *interp, int objc, 02872 Tcl_Obj *const objv[]); 02873 MODULE_SCOPE int Tcl_PutsObjCmd(ClientData clientData, 02874 Tcl_Interp *interp, int objc, 02875 Tcl_Obj *const objv[]); 02876 MODULE_SCOPE int Tcl_PwdObjCmd(ClientData clientData, 02877 Tcl_Interp *interp, int objc, 02878 Tcl_Obj *const objv[]); 02879 MODULE_SCOPE int Tcl_ReadObjCmd(ClientData clientData, 02880 Tcl_Interp *interp, int objc, 02881 Tcl_Obj *const objv[]); 02882 MODULE_SCOPE int Tcl_RegexpObjCmd(ClientData clientData, 02883 Tcl_Interp *interp, int objc, 02884 Tcl_Obj *const objv[]); 02885 MODULE_SCOPE int Tcl_RegsubObjCmd(ClientData clientData, 02886 Tcl_Interp *interp, int objc, 02887 Tcl_Obj *const objv[]); 02888 MODULE_SCOPE int Tcl_RenameObjCmd(ClientData clientData, 02889 Tcl_Interp *interp, int objc, 02890 Tcl_Obj *const objv[]); 02891 MODULE_SCOPE int Tcl_ReturnObjCmd(ClientData clientData, 02892 Tcl_Interp *interp, int objc, 02893 Tcl_Obj *const objv[]); 02894 MODULE_SCOPE int Tcl_ScanObjCmd(ClientData clientData, 02895 Tcl_Interp *interp, int objc, 02896 Tcl_Obj *const objv[]); 02897 MODULE_SCOPE int Tcl_SeekObjCmd(ClientData clientData, 02898 Tcl_Interp *interp, int objc, 02899 Tcl_Obj *const objv[]); 02900 MODULE_SCOPE int Tcl_SetObjCmd(ClientData clientData, 02901 Tcl_Interp *interp, int objc, 02902 Tcl_Obj *const objv[]); 02903 MODULE_SCOPE int Tcl_SplitObjCmd(ClientData clientData, 02904 Tcl_Interp *interp, int objc, 02905 Tcl_Obj *const objv[]); 02906 MODULE_SCOPE int Tcl_SocketObjCmd(ClientData clientData, 02907 Tcl_Interp *interp, int objc, 02908 Tcl_Obj *const objv[]); 02909 MODULE_SCOPE int Tcl_SourceObjCmd(ClientData clientData, 02910 Tcl_Interp *interp, int objc, 02911 Tcl_Obj *const objv[]); 02912 MODULE_SCOPE Tcl_Command TclInitStringCmd(Tcl_Interp *interp); 02913 MODULE_SCOPE int Tcl_SubstObjCmd(ClientData clientData, 02914 Tcl_Interp *interp, int objc, 02915 Tcl_Obj *const objv[]); 02916 MODULE_SCOPE int Tcl_SwitchObjCmd(ClientData clientData, 02917 Tcl_Interp *interp, int objc, 02918 Tcl_Obj *const objv[]); 02919 MODULE_SCOPE int Tcl_TellObjCmd(ClientData clientData, 02920 Tcl_Interp *interp, int objc, 02921 Tcl_Obj *const objv[]); 02922 MODULE_SCOPE int Tcl_TimeObjCmd(ClientData clientData, 02923 Tcl_Interp *interp, int objc, 02924 Tcl_Obj *const objv[]); 02925 MODULE_SCOPE int Tcl_TraceObjCmd(ClientData clientData, 02926 Tcl_Interp *interp, int objc, 02927 Tcl_Obj *const objv[]); 02928 MODULE_SCOPE int Tcl_UnloadObjCmd(ClientData clientData, 02929 Tcl_Interp *interp, int objc, 02930 Tcl_Obj *const objv[]); 02931 MODULE_SCOPE int Tcl_UnsetObjCmd(ClientData clientData, 02932 Tcl_Interp *interp, int objc, 02933 Tcl_Obj *const objv[]); 02934 MODULE_SCOPE int Tcl_UpdateObjCmd(ClientData clientData, 02935 Tcl_Interp *interp, int objc, 02936 Tcl_Obj *const objv[]); 02937 MODULE_SCOPE int Tcl_UplevelObjCmd(ClientData clientData, 02938 Tcl_Interp *interp, int objc, 02939 Tcl_Obj *const objv[]); 02940 MODULE_SCOPE int Tcl_UpvarObjCmd(ClientData clientData, 02941 Tcl_Interp *interp, int objc, 02942 Tcl_Obj *const objv[]); 02943 MODULE_SCOPE int Tcl_VariableObjCmd(ClientData clientData, 02944 Tcl_Interp *interp, int objc, 02945 Tcl_Obj *const objv[]); 02946 MODULE_SCOPE int Tcl_VwaitObjCmd(ClientData clientData, 02947 Tcl_Interp *interp, int objc, 02948 Tcl_Obj *const objv[]); 02949 MODULE_SCOPE int Tcl_WhileObjCmd(ClientData clientData, 02950 Tcl_Interp *interp, int objc, 02951 Tcl_Obj *const objv[]); 02952 02953 /* 02954 *---------------------------------------------------------------- 02955 * Compilation procedures for commands in the generic core: 02956 *---------------------------------------------------------------- 02957 */ 02958 02959 MODULE_SCOPE int TclCompileAppendCmd(Tcl_Interp *interp, 02960 Tcl_Parse *parsePtr, Command *cmdPtr, 02961 struct CompileEnv *envPtr); 02962 MODULE_SCOPE int TclCompileBreakCmd(Tcl_Interp *interp, 02963 Tcl_Parse *parsePtr, Command *cmdPtr, 02964 struct CompileEnv *envPtr); 02965 MODULE_SCOPE int TclCompileCatchCmd(Tcl_Interp *interp, 02966 Tcl_Parse *parsePtr, Command *cmdPtr, 02967 struct CompileEnv *envPtr); 02968 MODULE_SCOPE int TclCompileContinueCmd(Tcl_Interp *interp, 02969 Tcl_Parse *parsePtr, Command *cmdPtr, 02970 struct CompileEnv *envPtr); 02971 MODULE_SCOPE int TclCompileDictAppendCmd(Tcl_Interp *interp, 02972 Tcl_Parse *parsePtr, Command *cmdPtr, 02973 struct CompileEnv *envPtr); 02974 MODULE_SCOPE int TclCompileDictForCmd(Tcl_Interp *interp, 02975 Tcl_Parse *parsePtr, Command *cmdPtr, 02976 struct CompileEnv *envPtr); 02977 MODULE_SCOPE int TclCompileDictGetCmd(Tcl_Interp *interp, 02978 Tcl_Parse *parsePtr, Command *cmdPtr, 02979 struct CompileEnv *envPtr); 02980 MODULE_SCOPE int TclCompileDictIncrCmd(Tcl_Interp *interp, 02981 Tcl_Parse *parsePtr, Command *cmdPtr, 02982 struct CompileEnv *envPtr); 02983 MODULE_SCOPE int TclCompileDictLappendCmd(Tcl_Interp *interp, 02984 Tcl_Parse *parsePtr, Command *cmdPtr, 02985 struct CompileEnv *envPtr); 02986 MODULE_SCOPE int TclCompileDictSetCmd(Tcl_Interp *interp, 02987 Tcl_Parse *parsePtr, Command *cmdPtr, 02988 struct CompileEnv *envPtr); 02989 MODULE_SCOPE int TclCompileDictUpdateCmd(Tcl_Interp *interp, 02990 Tcl_Parse *parsePtr, Command *cmdPtr, 02991 struct CompileEnv *envPtr); 02992 MODULE_SCOPE int TclCompileEnsemble(Tcl_Interp *interp, 02993 Tcl_Parse *parsePtr, Command *cmdPtr, 02994 struct CompileEnv *envPtr); 02995 MODULE_SCOPE int TclCompileExprCmd(Tcl_Interp *interp, 02996 Tcl_Parse *parsePtr, Command *cmdPtr, 02997 struct CompileEnv *envPtr); 02998 MODULE_SCOPE int TclCompileForCmd(Tcl_Interp *interp, 02999 Tcl_Parse *parsePtr, Command *cmdPtr, 03000 struct CompileEnv *envPtr); 03001 MODULE_SCOPE int TclCompileForeachCmd(Tcl_Interp *interp, 03002 Tcl_Parse *parsePtr, Command *cmdPtr, 03003 struct CompileEnv *envPtr); 03004 MODULE_SCOPE int TclCompileGlobalCmd(Tcl_Interp *interp, 03005 Tcl_Parse *parsePtr, Command *cmdPtr, 03006 struct CompileEnv *envPtr); 03007 MODULE_SCOPE int TclCompileIfCmd(Tcl_Interp *interp, 03008 Tcl_Parse *parsePtr, Command *cmdPtr, 03009 struct CompileEnv *envPtr); 03010 MODULE_SCOPE int TclCompileInfoExistsCmd(Tcl_Interp *interp, 03011 Tcl_Parse *parsePtr, Command *cmdPtr, 03012 struct CompileEnv *envPtr); 03013 MODULE_SCOPE int TclCompileIncrCmd(Tcl_Interp *interp, 03014 Tcl_Parse *parsePtr, Command *cmdPtr, 03015 struct CompileEnv *envPtr); 03016 MODULE_SCOPE int TclCompileLappendCmd(Tcl_Interp *interp, 03017 Tcl_Parse *parsePtr, Command *cmdPtr, 03018 struct CompileEnv *envPtr); 03019 MODULE_SCOPE int TclCompileLassignCmd(Tcl_Interp *interp, 03020 Tcl_Parse *parsePtr, Command *cmdPtr, 03021 struct CompileEnv *envPtr); 03022 MODULE_SCOPE int TclCompileLindexCmd(Tcl_Interp *interp, 03023 Tcl_Parse *parsePtr, Command *cmdPtr, 03024 struct CompileEnv *envPtr); 03025 MODULE_SCOPE int TclCompileListCmd(Tcl_Interp *interp, 03026 Tcl_Parse *parsePtr, Command *cmdPtr, 03027 struct CompileEnv *envPtr); 03028 MODULE_SCOPE int TclCompileLlengthCmd(Tcl_Interp *interp, 03029 Tcl_Parse *parsePtr, Command *cmdPtr, 03030 struct CompileEnv *envPtr); 03031 MODULE_SCOPE int TclCompileLsetCmd(Tcl_Interp *interp, 03032 Tcl_Parse *parsePtr, Command *cmdPtr, 03033 struct CompileEnv *envPtr); 03034 MODULE_SCOPE int TclCompileNamespaceCmd(Tcl_Interp *interp, 03035 Tcl_Parse *parsePtr, Command *cmdPtr, 03036 struct CompileEnv *envPtr); 03037 MODULE_SCOPE int TclCompileNoOp(Tcl_Interp *interp, 03038 Tcl_Parse *parsePtr, Command *cmdPtr, 03039 struct CompileEnv *envPtr); 03040 MODULE_SCOPE int TclCompileRegexpCmd(Tcl_Interp *interp, 03041 Tcl_Parse *parsePtr, Command *cmdPtr, 03042 struct CompileEnv *envPtr); 03043 MODULE_SCOPE int TclCompileReturnCmd(Tcl_Interp *interp, 03044 Tcl_Parse *parsePtr, Command *cmdPtr, 03045 struct CompileEnv *envPtr); 03046 MODULE_SCOPE int TclCompileSetCmd(Tcl_Interp *interp, 03047 Tcl_Parse *parsePtr, Command *cmdPtr, 03048 struct CompileEnv *envPtr); 03049 MODULE_SCOPE int TclCompileStringCmpCmd(Tcl_Interp *interp, 03050 Tcl_Parse *parsePtr, Command *cmdPtr, 03051 struct CompileEnv *envPtr); 03052 MODULE_SCOPE int TclCompileStringEqualCmd(Tcl_Interp *interp, 03053 Tcl_Parse *parsePtr, Command *cmdPtr, 03054 struct CompileEnv *envPtr); 03055 MODULE_SCOPE int TclCompileStringIndexCmd(Tcl_Interp *interp, 03056 Tcl_Parse *parsePtr, Command *cmdPtr, 03057 struct CompileEnv *envPtr); 03058 MODULE_SCOPE int TclCompileStringLenCmd(Tcl_Interp *interp, 03059 Tcl_Parse *parsePtr, Command *cmdPtr, 03060 struct CompileEnv *envPtr); 03061 MODULE_SCOPE int TclCompileStringMatchCmd(Tcl_Interp *interp, 03062 Tcl_Parse *parsePtr, Command *cmdPtr, 03063 struct CompileEnv *envPtr); 03064 MODULE_SCOPE int TclCompileSwitchCmd(Tcl_Interp *interp, 03065 Tcl_Parse *parsePtr, Command *cmdPtr, 03066 struct CompileEnv *envPtr); 03067 MODULE_SCOPE int TclCompileUpvarCmd(Tcl_Interp *interp, 03068 Tcl_Parse *parsePtr, Command *cmdPtr, 03069 struct CompileEnv *envPtr); 03070 MODULE_SCOPE int TclCompileVariableCmd(Tcl_Interp *interp, 03071 Tcl_Parse *parsePtr, Command *cmdPtr, 03072 struct CompileEnv *envPtr); 03073 MODULE_SCOPE int TclCompileWhileCmd(Tcl_Interp *interp, 03074 Tcl_Parse *parsePtr, Command *cmdPtr, 03075 struct CompileEnv *envPtr); 03076 03077 MODULE_SCOPE int TclInvertOpCmd(ClientData clientData, 03078 Tcl_Interp *interp, int objc, 03079 Tcl_Obj *const objv[]); 03080 MODULE_SCOPE int TclCompileInvertOpCmd(Tcl_Interp *interp, 03081 Tcl_Parse *parsePtr, Command *cmdPtr, 03082 struct CompileEnv *envPtr); 03083 MODULE_SCOPE int TclNotOpCmd(ClientData clientData, 03084 Tcl_Interp *interp, int objc, 03085 Tcl_Obj *const objv[]); 03086 MODULE_SCOPE int TclCompileNotOpCmd(Tcl_Interp *interp, 03087 Tcl_Parse *parsePtr, Command *cmdPtr, 03088 struct CompileEnv *envPtr); 03089 MODULE_SCOPE int TclAddOpCmd(ClientData clientData, 03090 Tcl_Interp *interp, int objc, 03091 Tcl_Obj *const objv[]); 03092 MODULE_SCOPE int TclCompileAddOpCmd(Tcl_Interp *interp, 03093 Tcl_Parse *parsePtr, Command *cmdPtr, 03094 struct CompileEnv *envPtr); 03095 MODULE_SCOPE int TclMulOpCmd(ClientData clientData, 03096 Tcl_Interp *interp, int objc, 03097 Tcl_Obj *const objv[]); 03098 MODULE_SCOPE int TclCompileMulOpCmd(Tcl_Interp *interp, 03099 Tcl_Parse *parsePtr, Command *cmdPtr, 03100 struct CompileEnv *envPtr); 03101 MODULE_SCOPE int TclAndOpCmd(ClientData clientData, 03102 Tcl_Interp *interp, int objc, 03103 Tcl_Obj *const objv[]); 03104 MODULE_SCOPE int TclCompileAndOpCmd(Tcl_Interp *interp, 03105 Tcl_Parse *parsePtr, Command *cmdPtr, 03106 struct CompileEnv *envPtr); 03107 MODULE_SCOPE int TclOrOpCmd(ClientData clientData, 03108 Tcl_Interp *interp, int objc, 03109 Tcl_Obj *const objv[]); 03110 MODULE_SCOPE int TclCompileOrOpCmd(Tcl_Interp *interp, 03111 Tcl_Parse *parsePtr, Command *cmdPtr, 03112 struct CompileEnv *envPtr); 03113 MODULE_SCOPE int TclXorOpCmd(ClientData clientData, 03114 Tcl_Interp *interp, int objc, 03115 Tcl_Obj *const objv[]); 03116 MODULE_SCOPE int TclCompileXorOpCmd(Tcl_Interp *interp, 03117 Tcl_Parse *parsePtr, Command *cmdPtr, 03118 struct CompileEnv *envPtr); 03119 MODULE_SCOPE int TclPowOpCmd(ClientData clientData, 03120 Tcl_Interp *interp, int objc, 03121 Tcl_Obj *const objv[]); 03122 MODULE_SCOPE int TclCompilePowOpCmd(Tcl_Interp *interp, 03123 Tcl_Parse *parsePtr, Command *cmdPtr, 03124 struct CompileEnv *envPtr); 03125 MODULE_SCOPE int TclLshiftOpCmd(ClientData clientData, 03126 Tcl_Interp *interp, int objc, 03127 Tcl_Obj *const objv[]); 03128 MODULE_SCOPE int TclCompileLshiftOpCmd(Tcl_Interp *interp, 03129 Tcl_Parse *parsePtr, Command *cmdPtr, 03130 struct CompileEnv *envPtr); 03131 MODULE_SCOPE int TclRshiftOpCmd(ClientData clientData, 03132 Tcl_Interp *interp, int objc, 03133 Tcl_Obj *const objv[]); 03134 MODULE_SCOPE int TclCompileRshiftOpCmd(Tcl_Interp *interp, 03135 Tcl_Parse *parsePtr, Command *cmdPtr, 03136 struct CompileEnv *envPtr); 03137 MODULE_SCOPE int TclModOpCmd(ClientData clientData, 03138 Tcl_Interp *interp, int objc, 03139 Tcl_Obj *const objv[]); 03140 MODULE_SCOPE int TclCompileModOpCmd(Tcl_Interp *interp, 03141 Tcl_Parse *parsePtr, Command *cmdPtr, 03142 struct CompileEnv *envPtr); 03143 MODULE_SCOPE int TclNeqOpCmd(ClientData clientData, 03144 Tcl_Interp *interp, int objc, 03145 Tcl_Obj *const objv[]); 03146 MODULE_SCOPE int TclCompileNeqOpCmd(Tcl_Interp *interp, 03147 Tcl_Parse *parsePtr, Command *cmdPtr, 03148 struct CompileEnv *envPtr); 03149 MODULE_SCOPE int TclStrneqOpCmd(ClientData clientData, 03150 Tcl_Interp *interp, int objc, 03151 Tcl_Obj *const objv[]); 03152 MODULE_SCOPE int TclCompileStrneqOpCmd(Tcl_Interp *interp, 03153 Tcl_Parse *parsePtr, Command *cmdPtr, 03154 struct CompileEnv *envPtr); 03155 MODULE_SCOPE int TclInOpCmd(ClientData clientData, 03156 Tcl_Interp *interp, int objc, 03157 Tcl_Obj *const objv[]); 03158 MODULE_SCOPE int TclCompileInOpCmd(Tcl_Interp *interp, 03159 Tcl_Parse *parsePtr, Command *cmdPtr, 03160 struct CompileEnv *envPtr); 03161 MODULE_SCOPE int TclNiOpCmd(ClientData clientData, 03162 Tcl_Interp *interp, int objc, 03163 Tcl_Obj *const objv[]); 03164 MODULE_SCOPE int TclCompileNiOpCmd(Tcl_Interp *interp, 03165 Tcl_Parse *parsePtr, Command *cmdPtr, 03166 struct CompileEnv *envPtr); 03167 MODULE_SCOPE int TclMinusOpCmd(ClientData clientData, 03168 Tcl_Interp *interp, int objc, 03169 Tcl_Obj *const objv[]); 03170 MODULE_SCOPE int TclCompileMinusOpCmd(Tcl_Interp *interp, 03171 Tcl_Parse *parsePtr, Command *cmdPtr, 03172 struct CompileEnv *envPtr); 03173 MODULE_SCOPE int TclDivOpCmd(ClientData clientData, 03174 Tcl_Interp *interp, int objc, 03175 Tcl_Obj *const objv[]); 03176 MODULE_SCOPE int TclCompileDivOpCmd(Tcl_Interp *interp, 03177 Tcl_Parse *parsePtr, Command *cmdPtr, 03178 struct CompileEnv *envPtr); 03179 MODULE_SCOPE int TclLessOpCmd(ClientData clientData, 03180 Tcl_Interp *interp, int objc, 03181 Tcl_Obj *const objv[]); 03182 MODULE_SCOPE int TclCompileLessOpCmd(Tcl_Interp *interp, 03183 Tcl_Parse *parsePtr, Command *cmdPtr, 03184 struct CompileEnv *envPtr); 03185 MODULE_SCOPE int TclLeqOpCmd(ClientData clientData, 03186 Tcl_Interp *interp, int objc, 03187 Tcl_Obj *const objv[]); 03188 MODULE_SCOPE int TclCompileLeqOpCmd(Tcl_Interp *interp, 03189 Tcl_Parse *parsePtr, Command *cmdPtr, 03190 struct CompileEnv *envPtr); 03191 MODULE_SCOPE int TclGreaterOpCmd(ClientData clientData, 03192 Tcl_Interp *interp, int objc, 03193 Tcl_Obj *const objv[]); 03194 MODULE_SCOPE int TclCompileGreaterOpCmd(Tcl_Interp *interp, 03195 Tcl_Parse *parsePtr, Command *cmdPtr, 03196 struct CompileEnv *envPtr); 03197 MODULE_SCOPE int TclGeqOpCmd(ClientData clientData, 03198 Tcl_Interp *interp, int objc, 03199 Tcl_Obj *const objv[]); 03200 MODULE_SCOPE int TclCompileGeqOpCmd(Tcl_Interp *interp, 03201 Tcl_Parse *parsePtr, Command *cmdPtr, 03202 struct CompileEnv *envPtr); 03203 MODULE_SCOPE int TclEqOpCmd(ClientData clientData, 03204 Tcl_Interp *interp, int objc, 03205 Tcl_Obj *const objv[]); 03206 MODULE_SCOPE int TclCompileEqOpCmd(Tcl_Interp *interp, 03207 Tcl_Parse *parsePtr, Command *cmdPtr, 03208 struct CompileEnv *envPtr); 03209 MODULE_SCOPE int TclStreqOpCmd(ClientData clientData, 03210 Tcl_Interp *interp, int objc, 03211 Tcl_Obj *const objv[]); 03212 MODULE_SCOPE int TclCompileStreqOpCmd(Tcl_Interp *interp, 03213 Tcl_Parse *parsePtr, Command *cmdPtr, 03214 struct CompileEnv *envPtr); 03215 03216 /* 03217 * Functions defined in generic/tclVar.c and currenttly exported only for use 03218 * by the bytecode compiler and engine. Some of these could later be placed in 03219 * the public interface. 03220 */ 03221 03222 MODULE_SCOPE Var * TclObjLookupVarEx(Tcl_Interp * interp, 03223 Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags, 03224 const char * msg, const int createPart1, 03225 const int createPart2, Var **arrayPtrPtr); 03226 MODULE_SCOPE Var * TclLookupArrayElement(Tcl_Interp *interp, 03227 Tcl_Obj *arrayNamePtr, Tcl_Obj *elNamePtr, 03228 const int flags, const char *msg, 03229 const int createPart1, const int createPart2, 03230 Var *arrayPtr, int index); 03231 MODULE_SCOPE Tcl_Obj * TclPtrGetVar(Tcl_Interp *interp, 03232 Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr, 03233 Tcl_Obj *part2Ptr, const int flags, int index); 03234 MODULE_SCOPE Tcl_Obj * TclPtrSetVar(Tcl_Interp *interp, 03235 Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr, 03236 Tcl_Obj *part2Ptr, Tcl_Obj *newValuePtr, 03237 const int flags, int index); 03238 MODULE_SCOPE Tcl_Obj * TclPtrIncrObjVar(Tcl_Interp *interp, 03239 Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr, 03240 Tcl_Obj *part2Ptr, Tcl_Obj *incrPtr, 03241 const int flags, int index); 03242 MODULE_SCOPE int TclPtrObjMakeUpvar(Tcl_Interp *interp, Var *otherPtr, 03243 Tcl_Obj *myNamePtr, int myFlags, int index); 03244 MODULE_SCOPE void TclInvalidateNsPath(Namespace *nsPtr); 03245 03246 /* 03247 * The new extended interface to the variable traces. 03248 */ 03249 03250 MODULE_SCOPE int TclObjCallVarTraces(Interp *iPtr, Var *arrayPtr, 03251 Var *varPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, 03252 int flags, int leaveErrMsg, int index); 03253 03254 /* 03255 * So tclObj.c and tclDictObj.c can share these implementations. 03256 */ 03257 03258 MODULE_SCOPE int TclCompareObjKeys(void *keyPtr, Tcl_HashEntry *hPtr); 03259 MODULE_SCOPE void TclFreeObjEntry(Tcl_HashEntry *hPtr); 03260 MODULE_SCOPE unsigned TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr); 03261 03262 /* 03263 *---------------------------------------------------------------- 03264 * Macros used by the Tcl core to create and release Tcl objects. 03265 * TclNewObj(objPtr) creates a new object denoting an empty string. 03266 * TclDecrRefCount(objPtr) decrements the object's reference count, and frees 03267 * the object if its reference count is zero. These macros are inline versions 03268 * of Tcl_NewObj() and Tcl_DecrRefCount(). Notice that the names differ in not 03269 * having a "_" after the "Tcl". Notice also that these macros reference their 03270 * argument more than once, so you should avoid calling them with an 03271 * expression that is expensive to compute or has side effects. The ANSI C 03272 * "prototypes" for these macros are: 03273 * 03274 * MODULE_SCOPE void TclNewObj(Tcl_Obj *objPtr); 03275 * MODULE_SCOPE void TclDecrRefCount(Tcl_Obj *objPtr); 03276 * 03277 * These macros are defined in terms of two macros that depend on memory 03278 * allocator in use: TclAllocObjStorage, TclFreeObjStorage. They are defined 03279 * below. 03280 *---------------------------------------------------------------- 03281 */ 03282 03283 /* 03284 * DTrace object allocation probe macros. 03285 */ 03286 03287 #ifdef USE_DTRACE 03288 #include "tclDTrace.h" 03289 #define TCL_DTRACE_OBJ_CREATE(objPtr) TCL_OBJ_CREATE(objPtr) 03290 #define TCL_DTRACE_OBJ_FREE(objPtr) TCL_OBJ_FREE(objPtr) 03291 #else /* USE_DTRACE */ 03292 #define TCL_DTRACE_OBJ_CREATE(objPtr) {} 03293 #define TCL_DTRACE_OBJ_FREE(objPtr) {} 03294 #endif /* USE_DTRACE */ 03295 03296 #ifdef TCL_COMPILE_STATS 03297 # define TclIncrObjsAllocated() \ 03298 tclObjsAlloced++ 03299 # define TclIncrObjsFreed() \ 03300 tclObjsFreed++ 03301 #else 03302 # define TclIncrObjsAllocated() 03303 # define TclIncrObjsFreed() 03304 #endif /* TCL_COMPILE_STATS */ 03305 03306 #ifndef TCL_MEM_DEBUG 03307 # define TclNewObj(objPtr) \ 03308 TclIncrObjsAllocated(); \ 03309 TclAllocObjStorage(objPtr); \ 03310 (objPtr)->refCount = 0; \ 03311 (objPtr)->bytes = tclEmptyStringRep; \ 03312 (objPtr)->length = 0; \ 03313 (objPtr)->typePtr = NULL; \ 03314 TCL_DTRACE_OBJ_CREATE(objPtr) 03315 03316 /* 03317 * Invalidate the string rep first so we can use the bytes value for our 03318 * pointer chain, and signal an obj deletion (as opposed to shimmering) with 03319 * 'length == -1'. 03320 * Use empty 'if ; else' to handle use in unbraced outer if/else conditions 03321 */ 03322 03323 # define TclDecrRefCount(objPtr) \ 03324 if (--(objPtr)->refCount > 0) ; else { \ 03325 if (!(objPtr)->typePtr || !(objPtr)->typePtr->freeIntRepProc) { \ 03326 TCL_DTRACE_OBJ_FREE(objPtr); \ 03327 if ((objPtr)->bytes \ 03328 && ((objPtr)->bytes != tclEmptyStringRep)) { \ 03329 ckfree((char *) (objPtr)->bytes); \ 03330 } \ 03331 (objPtr)->length = -1; \ 03332 TclFreeObjStorage(objPtr); \ 03333 TclIncrObjsFreed(); \ 03334 } else { \ 03335 TclFreeObj(objPtr); \ 03336 } \ 03337 } 03338 03339 #if defined(PURIFY) 03340 03341 /* 03342 * The PURIFY mode is like the regular mode, but instead of doing block 03343 * Tcl_Obj allocation and keeping a freed list for efficiency, it always 03344 * allocates and frees a single Tcl_Obj so that tools like Purify can better 03345 * track memory leaks 03346 */ 03347 03348 # define TclAllocObjStorage(objPtr) \ 03349 (objPtr) = (Tcl_Obj *) Tcl_Alloc(sizeof(Tcl_Obj)) 03350 03351 # define TclFreeObjStorage(objPtr) \ 03352 ckfree((char *) (objPtr)) 03353 03354 #undef USE_THREAD_ALLOC 03355 #elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) 03356 03357 /* 03358 * The TCL_THREADS mode is like the regular mode but allocates Tcl_Obj's from 03359 * per-thread caches. 03360 */ 03361 03362 MODULE_SCOPE Tcl_Obj * TclThreadAllocObj(void); 03363 MODULE_SCOPE void TclThreadFreeObj(Tcl_Obj *); 03364 MODULE_SCOPE Tcl_Mutex *TclpNewAllocMutex(void); 03365 MODULE_SCOPE void TclFreeAllocCache(void *); 03366 MODULE_SCOPE void * TclpGetAllocCache(void); 03367 MODULE_SCOPE void TclpSetAllocCache(void *); 03368 MODULE_SCOPE void TclpFreeAllocMutex(Tcl_Mutex *mutex); 03369 MODULE_SCOPE void TclpFreeAllocCache(void *); 03370 03371 # define TclAllocObjStorage(objPtr) \ 03372 (objPtr) = TclThreadAllocObj() 03373 03374 # define TclFreeObjStorage(objPtr) \ 03375 TclThreadFreeObj((objPtr)) 03376 03377 #else /* not PURIFY or USE_THREAD_ALLOC */ 03378 03379 #ifdef TCL_THREADS 03380 /* declared in tclObj.c */ 03381 MODULE_SCOPE Tcl_Mutex tclObjMutex; 03382 #endif 03383 03384 # define TclAllocObjStorage(objPtr) \ 03385 Tcl_MutexLock(&tclObjMutex); \ 03386 if (tclFreeObjList == NULL) { \ 03387 TclAllocateFreeObjects(); \ 03388 } \ 03389 (objPtr) = tclFreeObjList; \ 03390 tclFreeObjList = (Tcl_Obj *) \ 03391 tclFreeObjList->internalRep.otherValuePtr; \ 03392 Tcl_MutexUnlock(&tclObjMutex) 03393 03394 # define TclFreeObjStorage(objPtr) \ 03395 Tcl_MutexLock(&tclObjMutex); \ 03396 (objPtr)->internalRep.otherValuePtr = (void *) tclFreeObjList; \ 03397 tclFreeObjList = (objPtr); \ 03398 Tcl_MutexUnlock(&tclObjMutex) 03399 #endif 03400 03401 #else /* TCL_MEM_DEBUG */ 03402 MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr); 03403 03404 # define TclDbNewObj(objPtr, file, line) \ 03405 TclIncrObjsAllocated(); \ 03406 (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \ 03407 TclDbInitNewObj(objPtr); \ 03408 TCL_DTRACE_OBJ_CREATE(objPtr) 03409 03410 # define TclNewObj(objPtr) \ 03411 TclDbNewObj(objPtr, __FILE__, __LINE__); 03412 03413 # define TclDecrRefCount(objPtr) \ 03414 Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__) 03415 03416 # define TclNewListObjDirect(objc, objv) \ 03417 TclDbNewListObjDirect(objc, objv, __FILE__, __LINE__) 03418 03419 #undef USE_THREAD_ALLOC 03420 #endif /* TCL_MEM_DEBUG */ 03421 03422 /* 03423 *---------------------------------------------------------------- 03424 * Macro used by the Tcl core to set a Tcl_Obj's string representation to a 03425 * copy of the "len" bytes starting at "bytePtr". This code works even if the 03426 * byte array contains NULLs as long as the length is correct. Because "len" 03427 * is referenced multiple times, it should be as simple an expression as 03428 * possible. The ANSI C "prototype" for this macro is: 03429 * 03430 * MODULE_SCOPE void TclInitStringRep(Tcl_Obj *objPtr, char *bytePtr, int len); 03431 * 03432 * This macro should only be called on an unshared objPtr where 03433 * objPtr->typePtr->freeIntRepProc == NULL 03434 *---------------------------------------------------------------- 03435 */ 03436 03437 #define TclInitStringRep(objPtr, bytePtr, len) \ 03438 if ((len) == 0) { \ 03439 (objPtr)->bytes = tclEmptyStringRep; \ 03440 (objPtr)->length = 0; \ 03441 } else { \ 03442 (objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \ 03443 memcpy((void *) (objPtr)->bytes, (void *) (bytePtr), \ 03444 (unsigned) (len)); \ 03445 (objPtr)->bytes[len] = '\0'; \ 03446 (objPtr)->length = (len); \ 03447 } 03448 03449 /* 03450 *---------------------------------------------------------------- 03451 * Macro used by the Tcl core to get the string representation's byte array 03452 * pointer from a Tcl_Obj. This is an inline version of Tcl_GetString(). The 03453 * macro's expression result is the string rep's byte pointer which might be 03454 * NULL. The bytes referenced by this pointer must not be modified by the 03455 * caller. The ANSI C "prototype" for this macro is: 03456 * 03457 * MODULE_SCOPE char * TclGetString(Tcl_Obj *objPtr); 03458 *---------------------------------------------------------------- 03459 */ 03460 03461 #define TclGetString(objPtr) \ 03462 ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr))) 03463 03464 03465 #define TclGetStringFromObj(objPtr, lenPtr) \ 03466 ((objPtr)->bytes \ 03467 ? (*(lenPtr) = (objPtr)->length, (objPtr)->bytes) \ 03468 : Tcl_GetStringFromObj((objPtr), (lenPtr))) 03469 03470 /* 03471 *---------------------------------------------------------------- 03472 * Macro used by the Tcl core to clean out an object's internal 03473 * representation. Does not actually reset the rep's bytes. The ANSI C 03474 * "prototype" for this macro is: 03475 * 03476 * MODULE_SCOPE void TclFreeIntRep(Tcl_Obj *objPtr); 03477 *---------------------------------------------------------------- 03478 */ 03479 03480 #define TclFreeIntRep(objPtr) \ 03481 if ((objPtr)->typePtr != NULL && \ 03482 (objPtr)->typePtr->freeIntRepProc != NULL) { \ 03483 (objPtr)->typePtr->freeIntRepProc(objPtr); \ 03484 } 03485 03486 /* 03487 *---------------------------------------------------------------- 03488 * Macro used by the Tcl core to clean out an object's string representation. 03489 * The ANSI C "prototype" for this macro is: 03490 * 03491 * MODULE_SCOPE void TclInvalidateStringRep(Tcl_Obj *objPtr); 03492 *---------------------------------------------------------------- 03493 */ 03494 03495 #define TclInvalidateStringRep(objPtr) \ 03496 if (objPtr->bytes != NULL) { \ 03497 if (objPtr->bytes != tclEmptyStringRep) {\ 03498 ckfree((char *) objPtr->bytes);\ 03499 }\ 03500 objPtr->bytes = NULL;\ 03501 }\ 03502 03503 /* 03504 *---------------------------------------------------------------- 03505 * Macros used by the Tcl core to grow Tcl_Token arrays. They use 03506 * the same growth algorithm as used in tclStringObj.c for growing 03507 * strings. The ANSI C "prototype" for this macro is: 03508 * 03509 * MODULE_SCOPE void TclGrowTokenArray(Tcl_Token *tokenPtr, int used, 03510 * int available, int append, 03511 * Tcl_Token *staticPtr); 03512 * MODULE_SCOPE void TclGrowParseTokenArray(Tcl_Parse *parsePtr, 03513 * int append); 03514 *---------------------------------------------------------------- 03515 */ 03516 03517 #define TCL_MIN_TOKEN_GROWTH 50 03518 #define TclGrowTokenArray(tokenPtr, used, available, append, staticPtr) \ 03519 { \ 03520 int needed = (used) + (append); \ 03521 if (needed > (available)) { \ 03522 int allocated = 2 * needed; \ 03523 Tcl_Token *oldPtr = (tokenPtr); \ 03524 Tcl_Token *newPtr; \ 03525 if (oldPtr == (staticPtr)) { \ 03526 oldPtr = NULL; \ 03527 } \ 03528 newPtr = (Tcl_Token *) attemptckrealloc( (char *) oldPtr, \ 03529 (unsigned int) (allocated * sizeof(Tcl_Token))); \ 03530 if (newPtr == NULL) { \ 03531 allocated = needed + (append) + TCL_MIN_TOKEN_GROWTH; \ 03532 newPtr = (Tcl_Token *) ckrealloc( (char *) oldPtr, \ 03533 (unsigned int) (allocated * sizeof(Tcl_Token))); \ 03534 } \ 03535 (available) = allocated; \ 03536 if (oldPtr == NULL) { \ 03537 memcpy((VOID *) newPtr, (VOID *) staticPtr, \ 03538 (size_t) ((used) * sizeof(Tcl_Token))); \ 03539 } \ 03540 (tokenPtr) = newPtr; \ 03541 } \ 03542 } 03543 03544 #define TclGrowParseTokenArray(parsePtr, append) \ 03545 TclGrowTokenArray((parsePtr)->tokenPtr, (parsePtr)->numTokens, \ 03546 (parsePtr)->tokensAvailable, (append), \ 03547 (parsePtr)->staticTokens) 03548 03549 /* 03550 *---------------------------------------------------------------- 03551 * Macro used by the Tcl core get a unicode char from a utf string. It checks 03552 * to see if we have a one-byte utf char before calling the real 03553 * Tcl_UtfToUniChar, as this will save a lot of time for primarily ascii 03554 * string handling. The macro's expression result is 1 for the 1-byte case or 03555 * the result of Tcl_UtfToUniChar. The ANSI C "prototype" for this macro is: 03556 * 03557 * MODULE_SCOPE int TclUtfToUniChar(const char *string, Tcl_UniChar *ch); 03558 *---------------------------------------------------------------- 03559 */ 03560 03561 #define TclUtfToUniChar(str, chPtr) \ 03562 ((((unsigned char) *(str)) < 0xC0) ? \ 03563 ((*(chPtr) = (Tcl_UniChar) *(str)), 1) \ 03564 : Tcl_UtfToUniChar(str, chPtr)) 03565 03566 /* 03567 *---------------------------------------------------------------- 03568 * Macro used by the Tcl core to compare Unicode strings. On big-endian 03569 * systems we can use the more efficient memcmp, but this would not be 03570 * lexically correct on little-endian systems. The ANSI C "prototype" for 03571 * this macro is: 03572 * 03573 * MODULE_SCOPE int TclUniCharNcmp(const Tcl_UniChar *cs, 03574 * const Tcl_UniChar *ct, unsigned long n); 03575 *---------------------------------------------------------------- 03576 */ 03577 03578 #ifdef WORDS_BIGENDIAN 03579 # define TclUniCharNcmp(cs,ct,n) memcmp((cs),(ct),(n)*sizeof(Tcl_UniChar)) 03580 #else /* !WORDS_BIGENDIAN */ 03581 # define TclUniCharNcmp Tcl_UniCharNcmp 03582 #endif /* WORDS_BIGENDIAN */ 03583 03584 /* 03585 *---------------------------------------------------------------- 03586 * Macro used by the Tcl core to increment a namespace's export export epoch 03587 * counter. The ANSI C "prototype" for this macro is: 03588 * 03589 * MODULE_SCOPE void TclInvalidateNsCmdLookup(Namespace *nsPtr); 03590 *---------------------------------------------------------------- 03591 */ 03592 03593 #define TclInvalidateNsCmdLookup(nsPtr) \ 03594 if ((nsPtr)->numExportPatterns) { \ 03595 (nsPtr)->exportLookupEpoch++; \ 03596 } 03597 03598 /* 03599 *---------------------------------------------------------------------- 03600 * 03601 * Core procedures added to libtommath for bignum manipulation. 03602 * 03603 *---------------------------------------------------------------------- 03604 */ 03605 03606 MODULE_SCOPE int TclTommath_Init(Tcl_Interp *interp); 03607 MODULE_SCOPE void TclBNInitBignumFromLong(mp_int *bignum, long initVal); 03608 MODULE_SCOPE void TclBNInitBignumFromWideInt(mp_int *bignum, 03609 Tcl_WideInt initVal); 03610 MODULE_SCOPE void TclBNInitBignumFromWideUInt(mp_int *bignum, 03611 Tcl_WideUInt initVal); 03612 03613 /* 03614 *---------------------------------------------------------------- 03615 * Macro used by the Tcl core to check whether a pattern has any characters 03616 * special to [string match]. The ANSI C "prototype" for this macro is: 03617 * 03618 * MODULE_SCOPE int TclMatchIsTrivial(const char *pattern); 03619 *---------------------------------------------------------------- 03620 */ 03621 03622 #define TclMatchIsTrivial(pattern) strpbrk((pattern), "*[?\\") == NULL 03623 03624 /* 03625 *---------------------------------------------------------------- 03626 * Macro used by the Tcl core to write the string rep of a long integer to a 03627 * character buffer. The ANSI C "prototype" for this macro is: 03628 * 03629 * MODULE_SCOPE int TclFormatInt(char *buf, long n); 03630 *---------------------------------------------------------------- 03631 */ 03632 03633 #define TclFormatInt(buf, n) sprintf((buf), "%ld", (long)(n)) 03634 03635 /* 03636 *---------------------------------------------------------------- 03637 * Macros used by the Tcl core to set a Tcl_Obj's numeric representation 03638 * avoiding the corresponding function calls in time critical parts of the 03639 * core. They should only be called on unshared objects. The ANSI C 03640 * "prototypes" for these macros are: 03641 * 03642 * MODULE_SCOPE void TclSetIntObj(Tcl_Obj *objPtr, int intValue); 03643 * MODULE_SCOPE void TclSetLongObj(Tcl_Obj *objPtr, long longValue); 03644 * MODULE_SCOPE void TclSetBooleanObj(Tcl_Obj *objPtr, long boolValue); 03645 * MODULE_SCOPE void TclSetWideIntObj(Tcl_Obj *objPtr, Tcl_WideInt w); 03646 * MODULE_SCOPE void TclSetDoubleObj(Tcl_Obj *objPtr, double d); 03647 *---------------------------------------------------------------- 03648 */ 03649 03650 #define TclSetIntObj(objPtr, i) \ 03651 TclInvalidateStringRep(objPtr);\ 03652 TclFreeIntRep(objPtr); \ 03653 (objPtr)->internalRep.longValue = (long)(i); \ 03654 (objPtr)->typePtr = &tclIntType 03655 03656 #define TclSetLongObj(objPtr, l) \ 03657 TclSetIntObj((objPtr), (l)) 03658 03659 /* 03660 * NOTE: There is to be no such thing as a "pure" boolean. Boolean values set 03661 * programmatically go straight to being "int" Tcl_Obj's, with value 0 or 1. 03662 * The only "boolean" Tcl_Obj's shall be those holding the cached boolean 03663 * value of strings like: "yes", "no", "true", "false", "on", "off". 03664 */ 03665 03666 #define TclSetBooleanObj(objPtr, b) \ 03667 TclSetIntObj((objPtr), ((b)? 1 : 0)); 03668 03669 #ifndef NO_WIDE_TYPE 03670 #define TclSetWideIntObj(objPtr, w) \ 03671 TclInvalidateStringRep(objPtr);\ 03672 TclFreeIntRep(objPtr); \ 03673 (objPtr)->internalRep.wideValue = (Tcl_WideInt)(w); \ 03674 (objPtr)->typePtr = &tclWideIntType 03675 #endif 03676 03677 #define TclSetDoubleObj(objPtr, d) \ 03678 TclInvalidateStringRep(objPtr);\ 03679 TclFreeIntRep(objPtr); \ 03680 (objPtr)->internalRep.doubleValue = (double)(d); \ 03681 (objPtr)->typePtr = &tclDoubleType 03682 03683 /* 03684 *---------------------------------------------------------------- 03685 * Macros used by the Tcl core to create and initialise objects of standard 03686 * types, avoiding the corresponding function calls in time critical parts of 03687 * the core. The ANSI C "prototypes" for these macros are: 03688 * 03689 * MODULE_SCOPE void TclNewIntObj(Tcl_Obj *objPtr, int i); 03690 * MODULE_SCOPE void TclNewLongObj(Tcl_Obj *objPtr, long l); 03691 * MODULE_SCOPE void TclNewBooleanObj(Tcl_Obj *objPtr, int b); 03692 * MODULE_SCOPE void TclNewWideObj(Tcl_Obj *objPtr, Tcl_WideInt w); 03693 * MODULE_SCOPE void TclNewDoubleObj(Tcl_Obj *objPtr, double d); 03694 * MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, char *s, int len); 03695 * MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, char*sLiteral); 03696 * 03697 *---------------------------------------------------------------- 03698 */ 03699 03700 #ifndef TCL_MEM_DEBUG 03701 #define TclNewIntObj(objPtr, i) \ 03702 TclIncrObjsAllocated(); \ 03703 TclAllocObjStorage(objPtr); \ 03704 (objPtr)->refCount = 0; \ 03705 (objPtr)->bytes = NULL; \ 03706 (objPtr)->internalRep.longValue = (long)(i); \ 03707 (objPtr)->typePtr = &tclIntType; \ 03708 TCL_DTRACE_OBJ_CREATE(objPtr) 03709 03710 #define TclNewLongObj(objPtr, l) \ 03711 TclNewIntObj((objPtr), (l)) 03712 03713 /* 03714 * NOTE: There is to be no such thing as a "pure" boolean. 03715 * See comment above TclSetBooleanObj macro above. 03716 */ 03717 #define TclNewBooleanObj(objPtr, b) \ 03718 TclNewIntObj((objPtr), ((b)? 1 : 0)) 03719 03720 #define TclNewDoubleObj(objPtr, d) \ 03721 TclIncrObjsAllocated(); \ 03722 TclAllocObjStorage(objPtr); \ 03723 (objPtr)->refCount = 0; \ 03724 (objPtr)->bytes = NULL; \ 03725 (objPtr)->internalRep.doubleValue = (double)(d); \ 03726 (objPtr)->typePtr = &tclDoubleType; \ 03727 TCL_DTRACE_OBJ_CREATE(objPtr) 03728 03729 #define TclNewStringObj(objPtr, s, len) \ 03730 TclIncrObjsAllocated(); \ 03731 TclAllocObjStorage(objPtr); \ 03732 (objPtr)->refCount = 0; \ 03733 TclInitStringRep((objPtr), (s), (len));\ 03734 (objPtr)->typePtr = NULL; \ 03735 TCL_DTRACE_OBJ_CREATE(objPtr) 03736 03737 #else /* TCL_MEM_DEBUG */ 03738 #define TclNewIntObj(objPtr, i) \ 03739 (objPtr) = Tcl_NewIntObj(i) 03740 03741 #define TclNewLongObj(objPtr, l) \ 03742 (objPtr) = Tcl_NewLongObj(l) 03743 03744 #define TclNewBooleanObj(objPtr, b) \ 03745 (objPtr) = Tcl_NewBooleanObj(b) 03746 03747 #define TclNewDoubleObj(objPtr, d) \ 03748 (objPtr) = Tcl_NewDoubleObj(d) 03749 03750 #define TclNewStringObj(objPtr, s, len) \ 03751 (objPtr) = Tcl_NewStringObj((s), (len)) 03752 #endif /* TCL_MEM_DEBUG */ 03753 03754 /* 03755 * The sLiteral argument *must* be a string literal; the incantation with 03756 * sizeof(sLiteral "") will fail to compile otherwise. 03757 */ 03758 #define TclNewLiteralStringObj(objPtr, sLiteral) \ 03759 TclNewStringObj((objPtr), (sLiteral), (int) (sizeof(sLiteral "") - 1)) 03760 03761 /* 03762 *---------------------------------------------------------------- 03763 * Macros used by the Tcl core to test for some special double values. 03764 * The ANSI C "prototypes" for these macros are: 03765 * 03766 * MODULE_SCOPE int TclIsInfinite(double d); 03767 * MODULE_SCOPE int TclIsNaN(double d); 03768 */ 03769 03770 #ifdef _MSC_VER 03771 #define TclIsInfinite(d) ( ! (_finite((d))) ) 03772 #define TclIsNaN(d) (_isnan((d))) 03773 #else 03774 #define TclIsInfinite(d) ( (d) > DBL_MAX || (d) < -DBL_MAX ) 03775 #define TclIsNaN(d) ((d) != (d)) 03776 #endif 03777 03778 /* 03779 * ---------------------------------------------------------------------- 03780 * Macro to use to find the offset of a field in a structure. 03781 * Computes number of bytes from beginning of structure to a given field. 03782 */ 03783 03784 #ifdef offsetof 03785 #define TclOffset(type, field) ((int) offsetof(type, field)) 03786 #else 03787 #define TclOffset(type, field) ((int) ((char *) &((type *) 0)->field)) 03788 #endif 03789 03790 /* 03791 *---------------------------------------------------------------- 03792 * Inline version of Tcl_GetCurrentNamespace and Tcl_GetGlobalNamespace 03793 */ 03794 03795 #define TclGetCurrentNamespace(interp) \ 03796 (Tcl_Namespace *) ((Interp *)(interp))->varFramePtr->nsPtr 03797 03798 #define TclGetGlobalNamespace(interp) \ 03799 (Tcl_Namespace *) ((Interp *)(interp))->globalNsPtr 03800 03801 /* 03802 *---------------------------------------------------------------- 03803 * Inline version of TclCleanupCommand; still need the function as it is in 03804 * the internal stubs, but the core can use the macro instead. 03805 */ 03806 03807 #define TclCleanupCommandMacro(cmdPtr) \ 03808 if (--(cmdPtr)->refCount <= 0) { \ 03809 ckfree((char *) (cmdPtr));\ 03810 } 03811 03812 /* 03813 *---------------------------------------------------------------- 03814 * Inline versions of Tcl_LimitReady() and Tcl_LimitExceeded to limit number 03815 * of calls out of the critical path. Note that this code isn't particularly 03816 * readable; the non-inline version (in tclInterp.c) is much easier to 03817 * understand. Note also that these macros takes different args (iPtr->limit) 03818 * to the non-inline version. 03819 */ 03820 03821 #define TclLimitExceeded(limit) ((limit).exceeded != 0) 03822 03823 #define TclLimitReady(limit) \ 03824 (((limit).active == 0) ? 0 : \ 03825 (++(limit).granularityTicker, \ 03826 ((((limit).active & TCL_LIMIT_COMMANDS) && \ 03827 (((limit).cmdGranularity == 1) || \ 03828 ((limit).granularityTicker % (limit).cmdGranularity == 0))) \ 03829 ? 1 : \ 03830 (((limit).active & TCL_LIMIT_TIME) && \ 03831 (((limit).timeGranularity == 1) || \ 03832 ((limit).granularityTicker % (limit).timeGranularity == 0)))\ 03833 ? 1 : 0))) 03834 03835 03836 #include "tclPort.h" 03837 #include "tclIntDecls.h" 03838 #include "tclIntPlatDecls.h" 03839 #include "tclTomMathDecls.h" 03840 03841 #endif /* _TCLINT */ 03842 03843 /* 03844 * Local Variables: 03845 * mode: c 03846 * c-basic-offset: 4 03847 * fill-column: 78 03848 * End: 03849 */
Generated on Wed Mar 12 12:18:16 2008 by 1.5.1 |