os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/generic/tclInt.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2  * tclInt.h --
     3  *
     4  *	Declarations of things used internally by the Tcl interpreter.
     5  *
     6  * Copyright (c) 1987-1993 The Regents of the University of California.
     7  * Copyright (c) 1993-1997 Lucent Technologies.
     8  * Copyright (c) 1994-1998 Sun Microsystems, Inc.
     9  * Copyright (c) 1998-1999 by Scriptics Corporation.
    10  * Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
    11  * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiaries. All rights reserved.  
    12  *
    13  * See the file "license.terms" for information on usage and redistribution
    14  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    15  *
    16  * RCS: @(#) $Id: tclInt.h,v 1.118.2.28 2007/05/10 21:32:17 dgp Exp $
    17  */
    18 
    19 #ifndef _TCLINT
    20 #define _TCLINT
    21 
    22 /*
    23  * Common include files needed by most of the Tcl source files are
    24  * included here, so that system-dependent personalizations for the
    25  * include files only have to be made in once place.  This results
    26  * in a few extra includes, but greater modularity.  The order of
    27  * the three groups of #includes is important.	For example, stdio.h
    28  * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
    29  * needed by stdlib.h in some configurations.
    30  */
    31 
    32 #ifndef _TCL
    33 #include "tcl.h"
    34 #endif
    35 
    36 #include <stdio.h>
    37 
    38 #include <ctype.h>
    39 #ifdef NO_LIMITS_H
    40 #   include "../compat/limits.h"
    41 #else
    42 #   include <limits.h>
    43 #endif
    44 #ifdef NO_STDLIB_H
    45 #   include "../compat/stdlib.h"
    46 #else
    47 #   include <stdlib.h>
    48 #endif
    49 #ifdef NO_STRING_H
    50 #include "../compat/string.h"
    51 #else
    52 #include <string.h>
    53 #endif
    54 
    55 /*
    56  * Ensure WORDS_BIGENDIAN is defined correcly:
    57  * Needs to happen here in addition to configure to work with fat compiles on
    58  * Darwin (where configure runs only once for multiple architectures).
    59  */
    60 
    61 #ifdef HAVE_SYS_TYPES_H
    62 #    include <sys/types.h>
    63 #endif
    64 #ifdef HAVE_SYS_PARAM_H
    65 #    include <sys/param.h>
    66 #endif
    67 #ifdef BYTE_ORDER
    68 #    ifdef BIG_ENDIAN
    69 #        if BYTE_ORDER == BIG_ENDIAN
    70 #            undef WORDS_BIGENDIAN
    71 #            define WORDS_BIGENDIAN
    72 #        endif
    73 #    endif
    74 #    ifdef LITTLE_ENDIAN
    75 #        if BYTE_ORDER == LITTLE_ENDIAN
    76 #            undef WORDS_BIGENDIAN
    77 #        endif
    78 #    endif
    79 #endif
    80 
    81 /*
    82  * Used to tag functions that are only to be visible within the module being
    83  * built and not outside it (where this is supported by the linker).
    84  */
    85 
    86 #ifndef MODULE_SCOPE
    87 #   ifdef __cplusplus
    88 #	define MODULE_SCOPE extern "C"
    89 #   else
    90 #	define MODULE_SCOPE extern
    91 #   endif
    92 #endif
    93 
    94 #undef TCL_STORAGE_CLASS
    95 #ifdef BUILD_tcl
    96 # define TCL_STORAGE_CLASS DLLEXPORT
    97 #else
    98 # ifdef USE_TCL_STUBS
    99 #  define TCL_STORAGE_CLASS
   100 # else
   101 #  define TCL_STORAGE_CLASS DLLIMPORT
   102 # endif
   103 #endif
   104 
   105 /*
   106  * The following procedures allow namespaces to be customized to
   107  * support special name resolution rules for commands/variables.
   108  * 
   109  */
   110 
   111 struct Tcl_ResolvedVarInfo;
   112 
   113 typedef Tcl_Var (Tcl_ResolveRuntimeVarProc) _ANSI_ARGS_((
   114     Tcl_Interp* interp, struct Tcl_ResolvedVarInfo *vinfoPtr));
   115 
   116 typedef void (Tcl_ResolveVarDeleteProc) _ANSI_ARGS_((
   117     struct Tcl_ResolvedVarInfo *vinfoPtr));
   118 
   119 /*
   120  * The following structure encapsulates the routines needed to resolve a
   121  * variable reference at runtime.  Any variable specific state will typically
   122  * be appended to this structure.
   123  */
   124 
   125 
   126 typedef struct Tcl_ResolvedVarInfo {
   127     Tcl_ResolveRuntimeVarProc *fetchProc;
   128     Tcl_ResolveVarDeleteProc *deleteProc;
   129 } Tcl_ResolvedVarInfo;
   130 
   131 
   132 
   133 typedef int (Tcl_ResolveCompiledVarProc) _ANSI_ARGS_((
   134     Tcl_Interp* interp, CONST84 char* name, int length,
   135     Tcl_Namespace *context, Tcl_ResolvedVarInfo **rPtr));
   136 
   137 typedef int (Tcl_ResolveVarProc) _ANSI_ARGS_((
   138     Tcl_Interp* interp, CONST84 char* name, Tcl_Namespace *context,
   139     int flags, Tcl_Var *rPtr));
   140 
   141 typedef int (Tcl_ResolveCmdProc) _ANSI_ARGS_((Tcl_Interp* interp,
   142     CONST84 char* name, Tcl_Namespace *context, int flags,
   143     Tcl_Command *rPtr));
   144  
   145 typedef struct Tcl_ResolverInfo {
   146     Tcl_ResolveCmdProc *cmdResProc;	/* Procedure handling command name
   147 					 * resolution. */
   148     Tcl_ResolveVarProc *varResProc;	/* Procedure handling variable name
   149 					 * resolution for variables that
   150 					 * can only be handled at runtime. */
   151     Tcl_ResolveCompiledVarProc *compiledVarResProc;
   152 					/* Procedure handling variable name
   153 					 * resolution at compile time. */
   154 } Tcl_ResolverInfo;
   155 
   156 /*
   157  *----------------------------------------------------------------
   158  * Data structures related to namespaces.
   159  *----------------------------------------------------------------
   160  */
   161 
   162 /*
   163  * The structure below defines a namespace.
   164  * Note: the first five fields must match exactly the fields in a
   165  * Tcl_Namespace structure (see tcl.h). If you change one, be sure to
   166  * change the other.
   167  */
   168 
   169 typedef struct Namespace {
   170     char *name;			 /* The namespace's simple (unqualified)
   171 				  * name. This contains no ::'s. The name of
   172 				  * the global namespace is "" although "::"
   173 				  * is an synonym. */
   174     char *fullName;		 /* The namespace's fully qualified name.
   175 				  * This starts with ::. */
   176     ClientData clientData;	 /* An arbitrary value associated with this
   177 				  * namespace. */
   178     Tcl_NamespaceDeleteProc *deleteProc;
   179 				 /* Procedure invoked when deleting the
   180 				  * namespace to, e.g., free clientData. */
   181     struct Namespace *parentPtr; /* Points to the namespace that contains
   182 				  * this one. NULL if this is the global
   183 				  * namespace. */
   184     Tcl_HashTable childTable;	 /* Contains any child namespaces. Indexed
   185 				  * by strings; values have type
   186 				  * (Namespace *). */
   187     long nsId;			 /* Unique id for the namespace. */
   188     Tcl_Interp *interp;		 /* The interpreter containing this
   189 				  * namespace. */
   190     int flags;			 /* OR-ed combination of the namespace
   191 				  * status flags NS_DYING and NS_DEAD
   192 				  * listed below. */
   193     int activationCount;	 /* Number of "activations" or active call
   194 				  * frames for this namespace that are on
   195 				  * the Tcl call stack. The namespace won't
   196 				  * be freed until activationCount becomes
   197 				  * zero. */
   198     int refCount;		 /* Count of references by namespaceName *
   199 				  * objects. The namespace can't be freed
   200 				  * until refCount becomes zero. */
   201     Tcl_HashTable cmdTable;	 /* Contains all the commands currently
   202 				  * registered in the namespace. Indexed by
   203 				  * strings; values have type (Command *).
   204 				  * Commands imported by Tcl_Import have
   205 				  * Command structures that point (via an
   206 				  * ImportedCmdRef structure) to the
   207 				  * Command structure in the source
   208 				  * namespace's command table. */
   209     Tcl_HashTable varTable;	 /* Contains all the (global) variables
   210 				  * currently in this namespace. Indexed
   211 				  * by strings; values have type (Var *). */
   212     char **exportArrayPtr;	 /* Points to an array of string patterns
   213 				  * specifying which commands are exported.
   214 				  * A pattern may include "string match"
   215 				  * style wildcard characters to specify
   216 				  * multiple commands; however, no namespace
   217 				  * qualifiers are allowed. NULL if no
   218 				  * export patterns are registered. */
   219     int numExportPatterns;	 /* Number of export patterns currently
   220 				  * registered using "namespace export". */
   221     int maxExportPatterns;	 /* Mumber of export patterns for which
   222 				  * space is currently allocated. */
   223     int cmdRefEpoch;		 /* Incremented if a newly added command
   224 				  * shadows a command for which this
   225 				  * namespace has already cached a Command *
   226 				  * pointer; this causes all its cached
   227 				  * Command* pointers to be invalidated. */
   228     int resolverEpoch;		 /* Incremented whenever (a) the name resolution
   229 				  * rules change for this namespace or (b) a 
   230 				  * newly added command shadows a command that
   231 				  * is compiled to bytecodes.
   232 				  * This invalidates all byte codes compiled
   233 				  * in the namespace, causing the code to be
   234 				  * recompiled under the new rules.*/
   235     Tcl_ResolveCmdProc *cmdResProc;
   236 				 /* If non-null, this procedure overrides
   237 				  * the usual command resolution mechanism
   238 				  * in Tcl.  This procedure is invoked
   239 				  * within Tcl_FindCommand to resolve all
   240 				  * command references within the namespace. */
   241     Tcl_ResolveVarProc *varResProc;
   242 				 /* If non-null, this procedure overrides
   243 				  * the usual variable resolution mechanism
   244 				  * in Tcl.  This procedure is invoked
   245 				  * within Tcl_FindNamespaceVar to resolve all
   246 				  * variable references within the namespace
   247 				  * at runtime. */
   248     Tcl_ResolveCompiledVarProc *compiledVarResProc;
   249 				 /* If non-null, this procedure overrides
   250 				  * the usual variable resolution mechanism
   251 				  * in Tcl.  This procedure is invoked
   252 				  * within LookupCompiledLocal to resolve
   253 				  * variable references within the namespace
   254 				  * at compile time. */
   255 } Namespace;
   256 
   257 /*
   258  * Flags used to represent the status of a namespace:
   259  *
   260  * NS_DYING -	1 means Tcl_DeleteNamespace has been called to delete the
   261  *		namespace but there are still active call frames on the Tcl
   262  *		stack that refer to the namespace. When the last call frame
   263  *		referring to it has been popped, it's variables and command
   264  *		will be destroyed and it will be marked "dead" (NS_DEAD).
   265  *		The namespace can no longer be looked up by name.
   266  * NS_DEAD -	1 means Tcl_DeleteNamespace has been called to delete the
   267  *		namespace and no call frames still refer to it. Its
   268  *		variables and command have already been destroyed. This bit
   269  *		allows the namespace resolution code to recognize that the
   270  *		namespace is "deleted". When the last namespaceName object
   271  *		in any byte code code unit that refers to the namespace has
   272  *		been freed (i.e., when the namespace's refCount is 0), the
   273  *		namespace's storage will be freed.
   274  * NS_KILLED    1 means that TclTeardownNamespace has already been called on
   275  *              this namespace and it should not be called again [Bug 1355942]
   276  */
   277 
   278 #define NS_DYING	0x01
   279 #define NS_DEAD		0x02
   280 #define NS_KILLED       0x04
   281 
   282 /*
   283  * Flag passed to TclGetNamespaceForQualName to have it create all namespace
   284  * components of a namespace-qualified name that cannot be found. The new
   285  * namespaces are created within their specified parent. Note that this
   286  * flag's value must not conflict with the values of the flags
   287  * TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, and FIND_ONLY_NS (defined in
   288  * tclNamesp.c).
   289  */
   290 
   291 #define CREATE_NS_IF_UNKNOWN 0x800
   292 
   293 /*
   294  *----------------------------------------------------------------
   295  * Data structures related to variables.   These are used primarily
   296  * in tclVar.c
   297  *----------------------------------------------------------------
   298  */
   299 
   300 /*
   301  * The following structure defines a variable trace, which is used to
   302  * invoke a specific C procedure whenever certain operations are performed
   303  * on a variable.
   304  */
   305 
   306 typedef struct VarTrace {
   307     Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
   308 				 * by flags are performed on variable. */
   309     ClientData clientData;	/* Argument to pass to proc. */
   310     int flags;			/* What events the trace procedure is
   311 				 * interested in:  OR-ed combination of
   312 				 * TCL_TRACE_READS, TCL_TRACE_WRITES,
   313 				 * TCL_TRACE_UNSETS and TCL_TRACE_ARRAY. */
   314     struct VarTrace *nextPtr;	/* Next in list of traces associated with
   315 				 * a particular variable. */
   316 } VarTrace;
   317 
   318 /*
   319  * The following structure defines a command trace, which is used to
   320  * invoke a specific C procedure whenever certain operations are performed
   321  * on a command.
   322  */
   323 
   324 typedef struct CommandTrace {
   325     Tcl_CommandTraceProc *traceProc;/* Procedure to call when operations given
   326 				     * by flags are performed on command. */
   327     ClientData clientData;	    /* Argument to pass to proc. */
   328     int flags;			    /* What events the trace procedure is
   329 				     * interested in:  OR-ed combination of
   330 				     * TCL_TRACE_RENAME, TCL_TRACE_DELETE. */
   331     struct CommandTrace *nextPtr;   /* Next in list of traces associated with
   332 				     * a particular command. */
   333     int refCount;                   /* Used to ensure this structure is
   334                                      * not deleted too early.  Keeps track
   335                                      * of how many pieces of code have
   336                                      * a pointer to this structure. */
   337 } CommandTrace;
   338 
   339 /*
   340  * When a command trace is active (i.e. its associated procedure is
   341  * executing), one of the following structures is linked into a list
   342  * associated with the command's interpreter.  The information in
   343  * the structure is needed in order for Tcl to behave reasonably
   344  * if traces are deleted while traces are active.
   345  */
   346 
   347 typedef struct ActiveCommandTrace {
   348     struct Command *cmdPtr;	/* Command that's being traced. */
   349     struct ActiveCommandTrace *nextPtr;
   350 				/* Next in list of all active command
   351 				 * traces for the interpreter, or NULL
   352 				 * if no more. */
   353     CommandTrace *nextTracePtr;	/* Next trace to check after current
   354 				 * trace procedure returns;  if this
   355 				 * trace gets deleted, must update pointer
   356 				 * to avoid using free'd memory. */
   357     int reverseScan;		/* Boolean set true when the traces
   358 				 * are scanning in reverse order. */
   359 } ActiveCommandTrace;
   360 
   361 /*
   362  * When a variable trace is active (i.e. its associated procedure is
   363  * executing), one of the following structures is linked into a list
   364  * associated with the variable's interpreter.	The information in
   365  * the structure is needed in order for Tcl to behave reasonably
   366  * if traces are deleted while traces are active.
   367  */
   368 
   369 typedef struct ActiveVarTrace {
   370     struct Var *varPtr;		/* Variable that's being traced. */
   371     struct ActiveVarTrace *nextPtr;
   372 				/* Next in list of all active variable
   373 				 * traces for the interpreter, or NULL
   374 				 * if no more. */
   375     VarTrace *nextTracePtr;	/* Next trace to check after current
   376 				 * trace procedure returns;  if this
   377 				 * trace gets deleted, must update pointer
   378 				 * to avoid using free'd memory. */
   379 } ActiveVarTrace;
   380 
   381 /*
   382  * The following structure describes an enumerative search in progress on
   383  * an array variable;  this are invoked with options to the "array"
   384  * command.
   385  */
   386 
   387 typedef struct ArraySearch {
   388     int id;			/* Integer id used to distinguish among
   389 				 * multiple concurrent searches for the
   390 				 * same array. */
   391     struct Var *varPtr;		/* Pointer to array variable that's being
   392 				 * searched. */
   393     Tcl_HashSearch search;	/* Info kept by the hash module about
   394 				 * progress through the array. */
   395     Tcl_HashEntry *nextEntry;	/* Non-null means this is the next element
   396 				 * to be enumerated (it's leftover from
   397 				 * the Tcl_FirstHashEntry call or from
   398 				 * an "array anymore" command).	 NULL
   399 				 * means must call Tcl_NextHashEntry
   400 				 * to get value to return. */
   401     struct ArraySearch *nextPtr;/* Next in list of all active searches
   402 				 * for this variable, or NULL if this is
   403 				 * the last one. */
   404 } ArraySearch;
   405 
   406 /*
   407  * The structure below defines a variable, which associates a string name
   408  * with a Tcl_Obj value. These structures are kept in procedure call frames
   409  * (for local variables recognized by the compiler) or in the heap (for
   410  * global variables and any variable not known to the compiler). For each
   411  * Var structure in the heap, a hash table entry holds the variable name and
   412  * a pointer to the Var structure.
   413  */
   414 
   415 typedef struct Var {
   416     union {
   417 	Tcl_Obj *objPtr;	/* The variable's object value. Used for 
   418 				 * scalar variables and array elements. */
   419 	Tcl_HashTable *tablePtr;/* For array variables, this points to
   420 				 * information about the hash table used
   421 				 * to implement the associative array. 
   422 				 * Points to malloc-ed data. */
   423 	struct Var *linkPtr;	/* If this is a global variable being
   424 				 * referred to in a procedure, or a variable
   425 				 * created by "upvar", this field points to
   426 				 * the referenced variable's Var struct. */
   427     } value;
   428     char *name;			/* NULL if the variable is in a hashtable,
   429 				 * otherwise points to the variable's
   430 				 * name. It is used, e.g., by TclLookupVar
   431 				 * and "info locals". The storage for the
   432 				 * characters of the name is not owned by
   433 				 * the Var and must not be freed when
   434 				 * freeing the Var. */
   435     Namespace *nsPtr;		/* Points to the namespace that contains
   436 				 * this variable or NULL if the variable is
   437 				 * a local variable in a Tcl procedure. */
   438     Tcl_HashEntry *hPtr;	/* If variable is in a hashtable, either the
   439 				 * hash table entry that refers to this
   440 				 * variable or NULL if the variable has been
   441 				 * detached from its hash table (e.g. an
   442 				 * array is deleted, but some of its
   443 				 * elements are still referred to in
   444 				 * upvars). NULL if the variable is not in a
   445 				 * hashtable. This is used to delete an
   446 				 * variable from its hashtable if it is no
   447 				 * longer needed. */
   448     int refCount;		/* Counts number of active uses of this
   449 				 * variable, not including its entry in the
   450 				 * call frame or the hash table: 1 for each
   451 				 * additional variable whose linkPtr points
   452 				 * here, 1 for each nested trace active on
   453 				 * variable, and 1 if the variable is a 
   454 				 * namespace variable. This record can't be
   455 				 * deleted until refCount becomes 0. */
   456     VarTrace *tracePtr;		/* First in list of all traces set for this
   457 				 * variable. */
   458     ArraySearch *searchPtr;	/* First in list of all searches active
   459 				 * for this variable, or NULL if none. */
   460     int flags;			/* Miscellaneous bits of information about
   461 				 * variable. See below for definitions. */
   462 } Var;
   463 
   464 /*
   465  * Flag bits for variables. The first three (VAR_SCALAR, VAR_ARRAY, and
   466  * VAR_LINK) are mutually exclusive and give the "type" of the variable.
   467  * VAR_UNDEFINED is independent of the variable's type. 
   468  *
   469  * VAR_SCALAR -			1 means this is a scalar variable and not
   470  *				an array or link. The "objPtr" field points
   471  *				to the variable's value, a Tcl object.
   472  * VAR_ARRAY -			1 means this is an array variable rather
   473  *				than a scalar variable or link. The
   474  *				"tablePtr" field points to the array's
   475  *				hashtable for its elements.
   476  * VAR_LINK -			1 means this Var structure contains a
   477  *				pointer to another Var structure that
   478  *				either has the real value or is itself
   479  *				another VAR_LINK pointer. Variables like
   480  *				this come about through "upvar" and "global"
   481  *				commands, or through references to variables
   482  *				in enclosing namespaces.
   483  * VAR_UNDEFINED -		1 means that the variable is in the process
   484  *				of being deleted. An undefined variable
   485  *				logically does not exist and survives only
   486  *				while it has a trace, or if it is a global
   487  *				variable currently being used by some
   488  *				procedure.
   489  * VAR_IN_HASHTABLE -		1 means this variable is in a hashtable and
   490  *				the Var structure is malloced. 0 if it is
   491  *				a local variable that was assigned a slot
   492  *				in a procedure frame by	the compiler so the
   493  *				Var storage is part of the call frame.
   494  * VAR_TRACE_ACTIVE -		1 means that trace processing is currently
   495  *				underway for a read or write access, so
   496  *				new read or write accesses should not cause
   497  *				trace procedures to be called and the
   498  *				variable can't be deleted.
   499  * VAR_ARRAY_ELEMENT -		1 means that this variable is an array
   500  *				element, so it is not legal for it to be
   501  *				an array itself (the VAR_ARRAY flag had
   502  *				better not be set).
   503  * VAR_NAMESPACE_VAR -		1 means that this variable was declared
   504  *				as a namespace variable. This flag ensures
   505  *				it persists until its namespace is
   506  *				destroyed or until the variable is unset;
   507  *				it will persist even if it has not been
   508  *				initialized and is marked undefined.
   509  *				The variable's refCount is incremented to
   510  *				reflect the "reference" from its namespace.
   511  *
   512  * The following additional flags are used with the CompiledLocal type
   513  * defined below:
   514  *
   515  * VAR_ARGUMENT -		1 means that this variable holds a procedure
   516  *				argument. 
   517  * VAR_TEMPORARY -		1 if the local variable is an anonymous
   518  *				temporary variable. Temporaries have a NULL
   519  *				name.
   520  * VAR_RESOLVED -		1 if name resolution has been done for this
   521  *				variable.
   522  */
   523 
   524 #define VAR_SCALAR		0x1
   525 #define VAR_ARRAY		0x2
   526 #define VAR_LINK		0x4
   527 #define VAR_UNDEFINED		0x8
   528 #define VAR_IN_HASHTABLE	0x10
   529 #define VAR_TRACE_ACTIVE	0x20
   530 #define VAR_ARRAY_ELEMENT	0x40
   531 #define VAR_NAMESPACE_VAR	0x80
   532 
   533 #define VAR_ARGUMENT		0x100
   534 #define VAR_TEMPORARY		0x200
   535 #define VAR_RESOLVED		0x400	
   536 
   537 /*
   538  * Macros to ensure that various flag bits are set properly for variables.
   539  * The ANSI C "prototypes" for these macros are:
   540  *
   541  * EXTERN void	TclSetVarScalar _ANSI_ARGS_((Var *varPtr));
   542  * EXTERN void	TclSetVarArray _ANSI_ARGS_((Var *varPtr));
   543  * EXTERN void	TclSetVarLink _ANSI_ARGS_((Var *varPtr));
   544  * EXTERN void	TclSetVarArrayElement _ANSI_ARGS_((Var *varPtr));
   545  * EXTERN void	TclSetVarUndefined _ANSI_ARGS_((Var *varPtr));
   546  * EXTERN void	TclClearVarUndefined _ANSI_ARGS_((Var *varPtr));
   547  */
   548 
   549 #define TclSetVarScalar(varPtr) \
   550     (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK)) | VAR_SCALAR
   551 
   552 #define TclSetVarArray(varPtr) \
   553     (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_LINK)) | VAR_ARRAY
   554 
   555 #define TclSetVarLink(varPtr) \
   556     (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_ARRAY)) | VAR_LINK
   557 
   558 #define TclSetVarArrayElement(varPtr) \
   559     (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
   560 
   561 #define TclSetVarUndefined(varPtr) \
   562     (varPtr)->flags |= VAR_UNDEFINED
   563 
   564 #define TclClearVarUndefined(varPtr) \
   565     (varPtr)->flags &= ~VAR_UNDEFINED
   566 
   567 /*
   568  * Macros to read various flag bits of variables.
   569  * The ANSI C "prototypes" for these macros are:
   570  *
   571  * EXTERN int	TclIsVarScalar _ANSI_ARGS_((Var *varPtr));
   572  * EXTERN int	TclIsVarLink _ANSI_ARGS_((Var *varPtr));
   573  * EXTERN int	TclIsVarArray _ANSI_ARGS_((Var *varPtr));
   574  * EXTERN int	TclIsVarUndefined _ANSI_ARGS_((Var *varPtr));
   575  * EXTERN int	TclIsVarArrayElement _ANSI_ARGS_((Var *varPtr));
   576  * EXTERN int	TclIsVarTemporary _ANSI_ARGS_((Var *varPtr));
   577  * EXTERN int	TclIsVarArgument _ANSI_ARGS_((Var *varPtr));
   578  * EXTERN int	TclIsVarResolved _ANSI_ARGS_((Var *varPtr));
   579  */
   580     
   581 #define TclIsVarScalar(varPtr) \
   582     ((varPtr)->flags & VAR_SCALAR)
   583 
   584 #define TclIsVarLink(varPtr) \
   585     ((varPtr)->flags & VAR_LINK)
   586 
   587 #define TclIsVarArray(varPtr) \
   588     ((varPtr)->flags & VAR_ARRAY)
   589 
   590 #define TclIsVarUndefined(varPtr) \
   591     ((varPtr)->flags & VAR_UNDEFINED)
   592 
   593 #define TclIsVarArrayElement(varPtr) \
   594     ((varPtr)->flags & VAR_ARRAY_ELEMENT)
   595 
   596 #define TclIsVarTemporary(varPtr) \
   597     ((varPtr)->flags & VAR_TEMPORARY)
   598     
   599 #define TclIsVarArgument(varPtr) \
   600     ((varPtr)->flags & VAR_ARGUMENT)
   601     
   602 #define TclIsVarResolved(varPtr) \
   603     ((varPtr)->flags & VAR_RESOLVED)
   604 
   605 /*
   606  *----------------------------------------------------------------
   607  * Data structures related to procedures.  These are used primarily
   608  * in tclProc.c, tclCompile.c, and tclExecute.c.
   609  *----------------------------------------------------------------
   610  */
   611 
   612 /*
   613  * Forward declaration to prevent an error when the forward reference to
   614  * Command is encountered in the Proc and ImportRef types declared below.
   615  */
   616 
   617 struct Command;
   618 
   619 /*
   620  * The variable-length structure below describes a local variable of a
   621  * procedure that was recognized by the compiler. These variables have a
   622  * name, an element in the array of compiler-assigned local variables in the
   623  * procedure's call frame, and various other items of information. If the
   624  * local variable is a formal argument, it may also have a default value.
   625  * The compiler can't recognize local variables whose names are
   626  * expressions (these names are only known at runtime when the expressions
   627  * are evaluated) or local variables that are created as a result of an
   628  * "upvar" or "uplevel" command. These other local variables are kept
   629  * separately in a hash table in the call frame.
   630  */
   631 
   632 typedef struct CompiledLocal {
   633     struct CompiledLocal *nextPtr;
   634 				/* Next compiler-recognized local variable
   635 				 * for this procedure, or NULL if this is
   636 				 * the last local. */
   637     int nameLength;		/* The number of characters in local
   638 				 * variable's name. Used to speed up
   639 				 * variable lookups. */
   640     int frameIndex;		/* Index in the array of compiler-assigned
   641 				 * variables in the procedure call frame. */
   642     int flags;			/* Flag bits for the local variable. Same as
   643 				 * the flags for the Var structure above,
   644 				 * although only VAR_SCALAR, VAR_ARRAY, 
   645 				 * VAR_LINK, VAR_ARGUMENT, VAR_TEMPORARY, and
   646 				 * VAR_RESOLVED make sense. */
   647     Tcl_Obj *defValuePtr;	/* Pointer to the default value of an
   648 				 * argument, if any. NULL if not an argument
   649 				 * or, if an argument, no default value. */
   650     Tcl_ResolvedVarInfo *resolveInfo;
   651 				/* Customized variable resolution info
   652 				 * supplied by the Tcl_ResolveCompiledVarProc
   653 				 * associated with a namespace. Each variable
   654 				 * is marked by a unique ClientData tag
   655 				 * during compilation, and that same tag
   656 				 * is used to find the variable at runtime. */
   657     char name[4];		/* Name of the local variable starts here.
   658 				 * If the name is NULL, this will just be
   659 				 * '\0'. The actual size of this field will
   660 				 * be large enough to hold the name. MUST
   661 				 * BE THE LAST FIELD IN THE STRUCTURE! */
   662 } CompiledLocal;
   663 
   664 /*
   665  * The structure below defines a command procedure, which consists of a
   666  * collection of Tcl commands plus information about arguments and other
   667  * local variables recognized at compile time.
   668  */
   669 
   670 typedef struct Proc {
   671     struct Interp *iPtr;	  /* Interpreter for which this command
   672 				   * is defined. */
   673     int refCount;		  /* Reference count: 1 if still present
   674 				   * in command table plus 1 for each call
   675 				   * to the procedure that is currently
   676 				   * active. This structure can be freed
   677 				   * when refCount becomes zero. */
   678     struct Command *cmdPtr;	  /* Points to the Command structure for
   679 				   * this procedure. This is used to get
   680 				   * the namespace in which to execute
   681 				   * the procedure. */
   682     Tcl_Obj *bodyPtr;		  /* Points to the ByteCode object for
   683 				   * procedure's body command. */
   684     int numArgs;		  /* Number of formal parameters. */
   685     int numCompiledLocals;	  /* Count of local variables recognized by
   686 				   * the compiler including arguments and
   687 				   * temporaries. */
   688     CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's
   689 				   * compiler-allocated local variables, or
   690 				   * NULL if none. The first numArgs entries
   691 				   * in this list describe the procedure's
   692 				   * formal arguments. */
   693     CompiledLocal *lastLocalPtr;  /* Pointer to the last allocated local
   694 				   * variable or NULL if none. This has
   695 				   * frame index (numCompiledLocals-1). */
   696 } Proc;
   697 
   698 /*
   699  * The structure below defines a command trace.	 This is used to allow Tcl
   700  * clients to find out whenever a command is about to be executed.
   701  */
   702 
   703 typedef struct Trace {
   704     int level;			/* Only trace commands at nesting level
   705 				 * less than or equal to this. */
   706     Tcl_CmdObjTraceProc *proc;	/* Procedure to call to trace command. */
   707     ClientData clientData;	/* Arbitrary value to pass to proc. */
   708     struct Trace *nextPtr;	/* Next in list of traces for this interp. */
   709     int flags;			/* Flags governing the trace - see
   710 				 * Tcl_CreateObjTrace for details */
   711     Tcl_CmdObjTraceDeleteProc* delProc;
   712 				/* Procedure to call when trace is deleted */
   713 } Trace;
   714 
   715 /*
   716  * When an interpreter trace is active (i.e. its associated procedure
   717  * is executing), one of the following structures is linked into a list
   718  * associated with the interpreter.  The information in the structure
   719  * is needed in order for Tcl to behave reasonably if traces are
   720  * deleted while traces are active.
   721  */
   722 
   723 typedef struct ActiveInterpTrace {
   724     struct ActiveInterpTrace *nextPtr;
   725 				/* Next in list of all active command
   726 				 * traces for the interpreter, or NULL
   727 				 * if no more. */
   728     Trace *nextTracePtr;	/* Next trace to check after current
   729 				 * trace procedure returns;  if this
   730 				 * trace gets deleted, must update pointer
   731 				 * to avoid using free'd memory. */
   732     int reverseScan;		/* Boolean set true when the traces
   733 				 * are scanning in reverse order. */
   734 } ActiveInterpTrace;
   735 
   736 /*
   737  * The structure below defines an entry in the assocData hash table which
   738  * is associated with an interpreter. The entry contains a pointer to a
   739  * function to call when the interpreter is deleted, and a pointer to
   740  * a user-defined piece of data.
   741  */
   742 
   743 typedef struct AssocData {
   744     Tcl_InterpDeleteProc *proc;	/* Proc to call when deleting. */
   745     ClientData clientData;	/* Value to pass to proc. */
   746 } AssocData;	
   747 
   748 /*
   749  * The structure below defines a call frame. A call frame defines a naming
   750  * context for a procedure call: its local naming scope (for local
   751  * variables) and its global naming scope (a namespace, perhaps the global
   752  * :: namespace). A call frame can also define the naming context for a
   753  * namespace eval or namespace inscope command: the namespace in which the
   754  * command's code should execute. The Tcl_CallFrame structures exist only
   755  * while procedures or namespace eval/inscope's are being executed, and
   756  * provide a kind of Tcl call stack.
   757  * 
   758  * WARNING!! The structure definition must be kept consistent with the
   759  * Tcl_CallFrame structure in tcl.h. If you change one, change the other.
   760  */
   761 
   762 typedef struct CallFrame {
   763     Namespace *nsPtr;		/* Points to the namespace used to resolve
   764 				 * commands and global variables. */
   765     int isProcCallFrame;	/* If nonzero, the frame was pushed to
   766 				 * execute a Tcl procedure and may have
   767 				 * local vars. If 0, the frame was pushed
   768 				 * to execute a namespace command and var
   769 				 * references are treated as references to
   770 				 * namespace vars; varTablePtr and
   771 				 * compiledLocals are ignored. */
   772     int objc;			/* This and objv below describe the
   773 				 * arguments for this procedure call. */
   774     Tcl_Obj *CONST *objv;	/* Array of argument objects. */
   775     struct CallFrame *callerPtr;
   776 				/* Value of interp->framePtr when this
   777 				 * procedure was invoked (i.e. next higher
   778 				 * in stack of all active procedures). */
   779     struct CallFrame *callerVarPtr;
   780 				/* Value of interp->varFramePtr when this
   781 				 * procedure was invoked (i.e. determines
   782 				 * variable scoping within caller). Same
   783 				 * as callerPtr unless an "uplevel" command
   784 				 * or something equivalent was active in
   785 				 * the caller). */
   786     int level;			/* Level of this procedure, for "uplevel"
   787 				 * purposes (i.e. corresponds to nesting of
   788 				 * callerVarPtr's, not callerPtr's). 1 for
   789 				 * outermost procedure, 0 for top-level. */
   790     Proc *procPtr;		/* Points to the structure defining the
   791 				 * called procedure. Used to get information
   792 				 * such as the number of compiled local
   793 				 * variables (local variables assigned
   794 				 * entries ["slots"] in the compiledLocals
   795 				 * array below). */
   796     Tcl_HashTable *varTablePtr;	/* Hash table containing local variables not
   797 				 * recognized by the compiler, or created at
   798 				 * execution time through, e.g., upvar.
   799 				 * Initially NULL and created if needed. */
   800     int numCompiledLocals;	/* Count of local variables recognized by
   801 				 * the compiler including arguments. */
   802     Var* compiledLocals;	/* Points to the array of local variables
   803 				 * recognized by the compiler. The compiler
   804 				 * emits code that refers to these variables
   805 				 * using an index into this array. */
   806 } CallFrame;
   807 
   808 #ifdef TCL_TIP280
   809 /*
   810  * TIP #280
   811  * The structure below defines a command frame. A command frame
   812  * provides location information for all commands executing a tcl
   813  * script (source, eval, uplevel, procedure bodies, ...). The runtime
   814  * structure essentially contains the stack trace as it would be if
   815  * the currently executing command were to throw an error.
   816  *
   817  * For commands where it makes sense it refers to the associated
   818  * CallFrame as well.
   819  *
   820  * The structures are chained in a single list, with the top of the
   821  * stack anchored in the Interp structure.
   822  *
   823  * Instances can be allocated on the C stack, or the heap, the former
   824  * making cleanup a bit simpler.
   825  */
   826 
   827 typedef struct CmdFrame {
   828   /* General data. Always available. */
   829 
   830   int              type;     /* Values see below */
   831   int              level;    /* #Frames in stack, prevent O(n) scan of list */
   832   int*             line;     /* Lines the words of the command start on */
   833   int              nline;
   834 
   835   CallFrame*       framePtr; /* Procedure activation record, may be NULL */
   836   struct CmdFrame* nextPtr;  /* Link to calling frame */
   837 
   838   /* Data needed for Eval vs TEBC
   839    *
   840    * EXECUTION CONTEXTS and usage of CmdFrame
   841    *
   842    * Field      TEBC            EvalEx          EvalObjEx
   843    * =======    ====            ======          =========
   844    * level      yes             yes             yes
   845    * type       BC/PREBC        SRC/EVAL        EVAL_LIST
   846    * line0      yes             yes             yes
   847    * framePtr   yes             yes             yes
   848    * =======    ====            ======          =========
   849    *
   850    * =======    ====            ======          ========= union data
   851    * line1      -               yes             -
   852    * line3      -               yes             -
   853    * path       -               yes             -
   854    * -------    ----            ------          ---------
   855    * codePtr    yes             -               -
   856    * pc         yes             -               -
   857    * =======    ====            ======          =========
   858    *
   859    * =======    ====            ======          ========= | union cmd
   860    * listPtr    -               -               yes       |
   861    * -------    ----            ------          --------- |
   862    * cmd        yes             yes             -         |
   863    * cmdlen     yes             yes             -         |
   864    * -------    ----            ------          --------- |
   865    */
   866 
   867   union {
   868     struct {
   869       Tcl_Obj*     path;     /* Path of the sourced file the command
   870 			      * is in. */
   871     } eval;
   872     struct {
   873       CONST void*  codePtr;  /* Byte code currently executed */
   874       CONST char*  pc;       /* and instruction pointer.     */
   875     } tebc;
   876   } data;
   877 
   878   union {
   879     struct {
   880       CONST char*  cmd;      /* The executed command, if possible */
   881       int          len;      /* And its length */
   882     } str;
   883     Tcl_Obj*       listPtr;  /* Tcl_EvalObjEx, cmd list */
   884   } cmd;
   885 
   886 } CmdFrame;
   887 
   888 /* The following macros define the allowed values for the type field
   889  * of the CmdFrame structure above. Some of the values occur only in
   890  * the extended location data referenced via the 'baseLocPtr'.
   891  *
   892  * TCL_LOCATION_EVAL      : Frame is for a script evaluated by EvalEx.
   893  * TCL_LOCATION_EVAL_LIST : Frame is for a script evaluated by the list
   894  *                          optimization path of EvalObjEx.
   895  * TCL_LOCATION_BC        : Frame is for bytecode. 
   896  * TCL_LOCATION_PREBC     : Frame is for precompiled bytecode.
   897  * TCL_LOCATION_SOURCE    : Frame is for a script evaluated by EvalEx,
   898  *                          from a sourced file.
   899  * TCL_LOCATION_PROC      : Frame is for bytecode of a procedure.
   900  *
   901  * A TCL_LOCATION_BC type in a frame can be overridden by _SOURCE and
   902  * _PROC types, per the context of the byte code in execution.
   903  */
   904 
   905 #define TCL_LOCATION_EVAL      (0) /* Location in a dynamic eval script */
   906 #define TCL_LOCATION_EVAL_LIST (1) /* Location in a dynamic eval script, list-path */
   907 #define TCL_LOCATION_BC        (2) /* Location in byte code */
   908 #define TCL_LOCATION_PREBC     (3) /* Location in precompiled byte code, no location */
   909 #define TCL_LOCATION_SOURCE    (4) /* Location in a file */
   910 #define TCL_LOCATION_PROC      (5) /* Location in a dynamic proc */
   911 
   912 #define TCL_LOCATION_LAST      (6) /* Number of values in the enum */
   913 #endif
   914 
   915 /*
   916  *----------------------------------------------------------------
   917  * Data structures and procedures related to TclHandles, which
   918  * are a very lightweight method of preserving enough information
   919  * to determine if an arbitrary malloc'd block has been deleted.
   920  *----------------------------------------------------------------
   921  */
   922 
   923 typedef VOID **TclHandle;
   924 
   925 /*
   926  *----------------------------------------------------------------
   927  * Data structures related to expressions.  These are used only in
   928  * tclExpr.c.
   929  *----------------------------------------------------------------
   930  */
   931 
   932 /*
   933  * The data structure below defines a math function (e.g. sin or hypot)
   934  * for use in Tcl expressions.
   935  */
   936 
   937 #define MAX_MATH_ARGS 5
   938 typedef struct MathFunc {
   939     int builtinFuncIndex;	/* If this is a builtin math function, its
   940 				 * index in the array of builtin functions.
   941 				 * (tclCompilation.h lists these indices.)
   942 				 * The value is -1 if this is a new function
   943 				 * defined by Tcl_CreateMathFunc. The value
   944 				 * is also -1 if a builtin function is
   945 				 * replaced by a Tcl_CreateMathFunc call. */
   946     int numArgs;		/* Number of arguments for function. */
   947     Tcl_ValueType argTypes[MAX_MATH_ARGS];
   948 				/* Acceptable types for each argument. */
   949     Tcl_MathProc *proc;		/* Procedure that implements this function.
   950 				 * NULL if isBuiltinFunc is 1. */
   951     ClientData clientData;	/* Additional argument to pass to the
   952 				 * function when invoking it. NULL if
   953 				 * isBuiltinFunc is 1. */
   954 } MathFunc;
   955 
   956 /*
   957  * These are a thin layer over TclpThreadKeyDataGet and TclpThreadKeyDataSet
   958  * when threads are used, or an emulation if there are no threads.  These
   959  * are really internal and Tcl clients should use Tcl_GetThreadData.
   960  */
   961 
   962 EXTERN VOID *TclThreadDataKeyGet _ANSI_ARGS_((Tcl_ThreadDataKey *keyPtr));
   963 EXTERN void TclThreadDataKeySet _ANSI_ARGS_((Tcl_ThreadDataKey *keyPtr, VOID *data));
   964 
   965 /*
   966  * This is a convenience macro used to initialize a thread local storage ptr.
   967  */
   968 #define TCL_TSD_INIT(keyPtr)	(ThreadSpecificData *)Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData))
   969 
   970 
   971 /*
   972  *----------------------------------------------------------------
   973  * Data structures related to bytecode compilation and execution.
   974  * These are used primarily in tclCompile.c, tclExecute.c, and
   975  * tclBasic.c.
   976  *----------------------------------------------------------------
   977  */
   978 
   979 /*
   980  * Forward declaration to prevent errors when the forward references to
   981  * Tcl_Parse and CompileEnv are encountered in the procedure type
   982  * CompileProc declared below.
   983  */
   984 
   985 struct CompileEnv;
   986 
   987 /*
   988  * The type of procedures called by the Tcl bytecode compiler to compile
   989  * commands. Pointers to these procedures are kept in the Command structure
   990  * describing each command. When a CompileProc returns, the interpreter's
   991  * result is set to error information, if any. In addition, the CompileProc
   992  * returns an integer value, which is one of the following:
   993  *
   994  * TCL_OK		Compilation completed normally.
   995  * TCL_ERROR		Compilation failed because of an error;
   996  *			the interpreter's result describes what went wrong.
   997  * TCL_OUT_LINE_COMPILE	Compilation failed because, e.g., the command is
   998  *			too complex for effective inline compilation. The
   999  *			CompileProc believes the command is legal but 
  1000  *			should be compiled "out of line" by emitting code
  1001  *			to invoke its command procedure at runtime.
  1002  */
  1003 
  1004 #define TCL_OUT_LINE_COMPILE	(TCL_CONTINUE + 1)
  1005 
  1006 typedef int (CompileProc) _ANSI_ARGS_((Tcl_Interp *interp,
  1007 	Tcl_Parse *parsePtr, struct CompileEnv *compEnvPtr));
  1008 
  1009 /*
  1010  * The type of procedure called from the compilation hook point in
  1011  * SetByteCodeFromAny.
  1012  */
  1013 
  1014 typedef int (CompileHookProc) _ANSI_ARGS_((Tcl_Interp *interp,
  1015 	struct CompileEnv *compEnvPtr, ClientData clientData));
  1016 
  1017 /*
  1018  * The data structure defining the execution environment for ByteCode's.
  1019  * There is one ExecEnv structure per Tcl interpreter. It holds the
  1020  * evaluation stack that holds command operands and results. The stack grows
  1021  * towards increasing addresses. The "stackTop" member is cached by
  1022  * TclExecuteByteCode in a local variable: it must be set before calling
  1023  * TclExecuteByteCode and will be restored by TclExecuteByteCode before it
  1024  * returns.
  1025  */
  1026 
  1027 typedef struct ExecEnv {
  1028     Tcl_Obj **stackPtr;		/* Points to the first item in the
  1029 				 * evaluation stack on the heap. */
  1030     int stackTop;		/* Index of current top of stack; -1 when
  1031 				 * the stack is empty. */
  1032     int stackEnd;		/* Index of last usable item in stack. */
  1033     Tcl_Obj *errorInfo;
  1034     Tcl_Obj *errorCode;
  1035 } ExecEnv;
  1036 
  1037 /*
  1038  * The definitions for the LiteralTable and LiteralEntry structures. Each
  1039  * interpreter contains a LiteralTable. It is used to reduce the storage
  1040  * needed for all the Tcl objects that hold the literals of scripts compiled
  1041  * by the interpreter. A literal's object is shared by all the ByteCodes
  1042  * that refer to the literal. Each distinct literal has one LiteralEntry
  1043  * entry in the LiteralTable. A literal table is a specialized hash table
  1044  * that is indexed by the literal's string representation, which may contain
  1045  * null characters.
  1046  *
  1047  * Note that we reduce the space needed for literals by sharing literal
  1048  * objects both within a ByteCode (each ByteCode contains a local
  1049  * LiteralTable) and across all an interpreter's ByteCodes (with the
  1050  * interpreter's global LiteralTable).
  1051  */
  1052 
  1053 typedef struct LiteralEntry {
  1054     struct LiteralEntry *nextPtr;	/* Points to next entry in this
  1055 					 * hash bucket or NULL if end of
  1056 					 * chain. */
  1057     Tcl_Obj *objPtr;			/* Points to Tcl object that
  1058 					 * holds the literal's bytes and
  1059 					 * length. */
  1060     int refCount;			/* If in an interpreter's global
  1061 					 * literal table, the number of
  1062 					 * ByteCode structures that share
  1063 					 * the literal object; the literal
  1064 					 * entry can be freed when refCount
  1065 					 * drops to 0. If in a local literal
  1066 					 * table, -1. */
  1067 } LiteralEntry;
  1068 
  1069 typedef struct LiteralTable {
  1070     LiteralEntry **buckets;		/* Pointer to bucket array. Each
  1071 					 * element points to first entry in
  1072 					 * bucket's hash chain, or NULL. */
  1073     LiteralEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
  1074 					/* Bucket array used for small
  1075 					 * tables to avoid mallocs and
  1076 					 * frees. */
  1077     int numBuckets;			/* Total number of buckets allocated
  1078 					 * at **buckets. */
  1079     int numEntries;			/* Total number of entries present
  1080 					 * in table. */
  1081     int rebuildSize;			/* Enlarge table when numEntries
  1082 					 * gets to be this large. */
  1083     int mask;				/* Mask value used in hashing
  1084 					 * function. */
  1085 } LiteralTable;
  1086 
  1087 /*
  1088  * The following structure defines for each Tcl interpreter various
  1089  * statistics-related information about the bytecode compiler and
  1090  * interpreter's operation in that interpreter.
  1091  */
  1092 
  1093 #ifdef TCL_COMPILE_STATS
  1094 typedef struct ByteCodeStats {
  1095     long numExecutions;		  /* Number of ByteCodes executed. */
  1096     long numCompilations;	  /* Number of ByteCodes created. */
  1097     long numByteCodesFreed;	  /* Number of ByteCodes destroyed. */
  1098     long instructionCount[256];	  /* Number of times each instruction was
  1099 				   * executed. */
  1100 
  1101     double totalSrcBytes;	  /* Total source bytes ever compiled. */
  1102     double totalByteCodeBytes;	  /* Total bytes for all ByteCodes. */
  1103     double currentSrcBytes;	  /* Src bytes for all current ByteCodes. */
  1104     double currentByteCodeBytes;  /* Code bytes in all current ByteCodes. */
  1105 
  1106     long srcCount[32];		  /* Source size distribution: # of srcs of
  1107 				   * size [2**(n-1)..2**n), n in [0..32). */
  1108     long byteCodeCount[32];	  /* ByteCode size distribution. */
  1109     long lifetimeCount[32];	  /* ByteCode lifetime distribution (ms). */
  1110     
  1111     double currentInstBytes;	  /* Instruction bytes-current ByteCodes. */
  1112     double currentLitBytes;	  /* Current literal bytes. */
  1113     double currentExceptBytes;	  /* Current exception table bytes. */
  1114     double currentAuxBytes;	  /* Current auxiliary information bytes. */
  1115     double currentCmdMapBytes;	  /* Current src<->code map bytes. */
  1116     
  1117     long numLiteralsCreated;	  /* Total literal objects ever compiled. */
  1118     double totalLitStringBytes;	  /* Total string bytes in all literals. */
  1119     double currentLitStringBytes; /* String bytes in current literals. */
  1120     long literalCount[32];	  /* Distribution of literal string sizes. */
  1121 } ByteCodeStats;
  1122 #endif /* TCL_COMPILE_STATS */
  1123 
  1124 /*
  1125  *----------------------------------------------------------------
  1126  * Data structures related to commands.
  1127  *----------------------------------------------------------------
  1128  */
  1129 
  1130 /*
  1131  * An imported command is created in an namespace when it imports a "real"
  1132  * command from another namespace. An imported command has a Command
  1133  * structure that points (via its ClientData value) to the "real" Command
  1134  * structure in the source namespace's command table. The real command
  1135  * records all the imported commands that refer to it in a list of ImportRef
  1136  * structures so that they can be deleted when the real command is deleted.  */
  1137 
  1138 typedef struct ImportRef {
  1139     struct Command *importedCmdPtr;
  1140 				/* Points to the imported command created in
  1141 				 * an importing namespace; this command
  1142 				 * redirects its invocations to the "real"
  1143 				 * command. */
  1144     struct ImportRef *nextPtr;	/* Next element on the linked list of
  1145 				 * imported commands that refer to the
  1146 				 * "real" command. The real command deletes
  1147 				 * these imported commands on this list when
  1148 				 * it is deleted. */
  1149 } ImportRef;
  1150 
  1151 /*
  1152  * Data structure used as the ClientData of imported commands: commands
  1153  * created in an namespace when it imports a "real" command from another
  1154  * namespace.
  1155  */
  1156 
  1157 typedef struct ImportedCmdData {
  1158     struct Command *realCmdPtr;	/* "Real" command that this imported command
  1159 				 * refers to. */
  1160     struct Command *selfPtr;	/* Pointer to this imported command. Needed
  1161 				 * only when deleting it in order to remove
  1162 				 * it from the real command's linked list of
  1163 				 * imported commands that refer to it. */
  1164 } ImportedCmdData;
  1165 
  1166 /*
  1167  * A Command structure exists for each command in a namespace. The
  1168  * Tcl_Command opaque type actually refers to these structures.
  1169  */
  1170 
  1171 typedef struct Command {
  1172     Tcl_HashEntry *hPtr;	/* Pointer to the hash table entry that
  1173 				 * refers to this command. The hash table is
  1174 				 * either a namespace's command table or an
  1175 				 * interpreter's hidden command table. This
  1176 				 * pointer is used to get a command's name
  1177 				 * from its Tcl_Command handle. NULL means
  1178 				 * that the hash table entry has been
  1179 				 * removed already (this can happen if
  1180 				 * deleteProc causes the command to be
  1181 				 * deleted or recreated). */
  1182     Namespace *nsPtr;		/* Points to the namespace containing this
  1183 				 * command. */
  1184     int refCount;		/* 1 if in command hashtable plus 1 for each
  1185 				 * reference from a CmdName Tcl object
  1186 				 * representing a command's name in a
  1187 				 * ByteCode instruction sequence. This
  1188 				 * structure can be freed when refCount
  1189 				 * becomes zero. */
  1190     int cmdEpoch;		/* Incremented to invalidate any references
  1191 				 * that point to this command when it is
  1192 				 * renamed, deleted, hidden, or exposed. */
  1193     CompileProc *compileProc;	/* Procedure called to compile command. NULL
  1194 				 * if no compile proc exists for command. */
  1195     Tcl_ObjCmdProc *objProc;	/* Object-based command procedure. */
  1196     ClientData objClientData;	/* Arbitrary value passed to object proc. */
  1197     Tcl_CmdProc *proc;		/* String-based command procedure. */
  1198     ClientData clientData;	/* Arbitrary value passed to string proc. */
  1199     Tcl_CmdDeleteProc *deleteProc;
  1200 				/* Procedure invoked when deleting command
  1201 				 * to, e.g., free all client data. */
  1202     ClientData deleteData;	/* Arbitrary value passed to deleteProc. */
  1203     int flags;			/* Miscellaneous bits of information about
  1204 				 * command. See below for definitions. */
  1205     ImportRef *importRefPtr;	/* List of each imported Command created in
  1206 				 * another namespace when this command is
  1207 				 * imported. These imported commands
  1208 				 * redirect invocations back to this
  1209 				 * command. The list is used to remove all
  1210 				 * those imported commands when deleting
  1211 				 * this "real" command. */
  1212     CommandTrace *tracePtr;	/* First in list of all traces set for this
  1213 				 * command. */
  1214 } Command;
  1215 
  1216 /*
  1217  * Flag bits for commands. 
  1218  *
  1219  * CMD_IS_DELETED -		Means that the command is in the process
  1220  *                              of being deleted (its deleteProc is
  1221  *                              currently executing). Other attempts to
  1222  *                              delete the command should be ignored.
  1223  * CMD_TRACE_ACTIVE -		1 means that trace processing is currently
  1224  *				underway for a rename/delete change.
  1225  *				See the two flags below for which is
  1226  *				currently being processed.
  1227  * CMD_HAS_EXEC_TRACES -	1 means that this command has at least
  1228  *                              one execution trace (as opposed to simple
  1229  *                              delete/rename traces) in its tracePtr list.
  1230  * TCL_TRACE_RENAME -           A rename trace is in progress. Further
  1231  *                              recursive renames will not be traced.
  1232  * TCL_TRACE_DELETE -           A delete trace is in progress. Further 
  1233  *                              recursive deletes will not be traced.
  1234  * (these last two flags are defined in tcl.h)
  1235  */
  1236 #define CMD_IS_DELETED		0x1
  1237 #define CMD_TRACE_ACTIVE	0x2
  1238 #define CMD_HAS_EXEC_TRACES	0x4
  1239 
  1240 /*
  1241  *----------------------------------------------------------------
  1242  * Data structures related to name resolution procedures.
  1243  *----------------------------------------------------------------
  1244  */
  1245 
  1246 /*
  1247  * The interpreter keeps a linked list of name resolution schemes.
  1248  * The scheme for a namespace is consulted first, followed by the
  1249  * list of schemes in an interpreter, followed by the default
  1250  * name resolution in Tcl.  Schemes are added/removed from the
  1251  * interpreter's list by calling Tcl_AddInterpResolver and
  1252  * Tcl_RemoveInterpResolver.
  1253  */
  1254 
  1255 typedef struct ResolverScheme {
  1256     char *name;			/* Name identifying this scheme. */
  1257     Tcl_ResolveCmdProc *cmdResProc;
  1258 				/* Procedure handling command name
  1259 				 * resolution. */
  1260     Tcl_ResolveVarProc *varResProc;
  1261 				/* Procedure handling variable name
  1262 				 * resolution for variables that
  1263 				 * can only be handled at runtime. */
  1264     Tcl_ResolveCompiledVarProc *compiledVarResProc;
  1265 				/* Procedure handling variable name
  1266 				 * resolution at compile time. */
  1267 
  1268     struct ResolverScheme *nextPtr;
  1269 				/* Pointer to next record in linked list. */
  1270 } ResolverScheme;
  1271 
  1272 #ifdef TCL_TIP268
  1273 /*
  1274  * TIP #268.
  1275  * Values for the selection mode, i.e the package require preferences.
  1276  */
  1277 
  1278 enum PkgPreferOptions {
  1279     PKG_PREFER_LATEST, PKG_PREFER_STABLE
  1280 };
  1281 #endif
  1282 
  1283 /*
  1284  *----------------------------------------------------------------
  1285  * This structure defines an interpreter, which is a collection of
  1286  * commands plus other state information related to interpreting
  1287  * commands, such as variable storage. Primary responsibility for
  1288  * this data structure is in tclBasic.c, but almost every Tcl
  1289  * source file uses something in here.
  1290  *----------------------------------------------------------------
  1291  */
  1292 
  1293 typedef struct Interp {
  1294 
  1295     /*
  1296      * Note:  the first three fields must match exactly the fields in
  1297      * a Tcl_Interp struct (see tcl.h).	 If you change one, be sure to
  1298      * change the other.
  1299      *
  1300      * The interpreter's result is held in both the string and the
  1301      * objResultPtr fields. These fields hold, respectively, the result's
  1302      * string or object value. The interpreter's result is always in the
  1303      * result field if that is non-empty, otherwise it is in objResultPtr.
  1304      * The two fields are kept consistent unless some C code sets
  1305      * interp->result directly. Programs should not access result and
  1306      * objResultPtr directly; instead, they should always get and set the
  1307      * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult,
  1308      * and Tcl_GetStringResult. See the SetResult man page for details.
  1309      */
  1310 
  1311     char *result;		/* If the last command returned a string
  1312 				 * result, this points to it. Should not be
  1313 				 * accessed directly; see comment above. */
  1314     Tcl_FreeProc *freeProc;	/* Zero means a string result is statically
  1315 				 * allocated. TCL_DYNAMIC means string
  1316 				 * result was allocated with ckalloc and
  1317 				 * should be freed with ckfree. Other values
  1318 				 * give address of procedure to invoke to
  1319 				 * free the string result. Tcl_Eval must
  1320 				 * free it before executing next command. */
  1321     int errorLine;		/* When TCL_ERROR is returned, this gives
  1322 				 * the line number in the command where the
  1323 				 * error occurred (1 means first line). */
  1324     struct TclStubs *stubTable;
  1325 				/* Pointer to the exported Tcl stub table.
  1326 				 * On previous versions of Tcl this is a
  1327 				 * pointer to the objResultPtr or a pointer
  1328 				 * to a buckets array in a hash table. We
  1329 				 * therefore have to do some careful checking
  1330 				 * before we can use this. */
  1331 
  1332     TclHandle handle;		/* Handle used to keep track of when this
  1333 				 * interp is deleted. */
  1334 
  1335     Namespace *globalNsPtr;	/* The interpreter's global namespace. */
  1336     Tcl_HashTable *hiddenCmdTablePtr;
  1337 				/* Hash table used by tclBasic.c to keep
  1338 				 * track of hidden commands on a per-interp
  1339 				 * basis. */
  1340     ClientData interpInfo;	/* Information used by tclInterp.c to keep
  1341 				 * track of master/slave interps on
  1342 				 * a per-interp basis. */
  1343     Tcl_HashTable mathFuncTable;/* Contains all the math functions currently
  1344 				 * defined for the interpreter.	 Indexed by
  1345 				 * strings (function names); values have
  1346 				 * type (MathFunc *). */
  1347 
  1348 
  1349 
  1350     /*
  1351      * Information related to procedures and variables. See tclProc.c
  1352      * and tclVar.c for usage.
  1353      */
  1354 
  1355     int numLevels;		/* Keeps track of how many nested calls to
  1356 				 * Tcl_Eval are in progress for this
  1357 				 * interpreter.	 It's used to delay deletion
  1358 				 * of the table until all Tcl_Eval
  1359 				 * invocations are completed. */
  1360     int maxNestingDepth;	/* If numLevels exceeds this value then Tcl
  1361 				 * assumes that infinite recursion has
  1362 				 * occurred and it generates an error. */
  1363     CallFrame *framePtr;	/* Points to top-most in stack of all nested
  1364 				 * procedure invocations.  NULL means there
  1365 				 * are no active procedures. */
  1366     CallFrame *varFramePtr;	/* Points to the call frame whose variables
  1367 				 * are currently in use (same as framePtr
  1368 				 * unless an "uplevel" command is
  1369 				 * executing). NULL means no procedure is
  1370 				 * active or "uplevel 0" is executing. */
  1371     ActiveVarTrace *activeVarTracePtr;
  1372 				/* First in list of active traces for
  1373 				 * interp, or NULL if no active traces. */
  1374     int returnCode;		/* Completion code to return if current
  1375 				 * procedure exits with TCL_RETURN code. */
  1376     char *errorInfo;		/* Value to store in errorInfo if returnCode
  1377 				 * is TCL_ERROR.  Malloc'ed, may be NULL */
  1378     char *errorCode;		/* Value to store in errorCode if returnCode
  1379 				 * is TCL_ERROR.  Malloc'ed, may be NULL */
  1380 
  1381     /*
  1382      * Information used by Tcl_AppendResult to keep track of partial
  1383      * results.	 See Tcl_AppendResult code for details.
  1384      */
  1385 
  1386     char *appendResult;		/* Storage space for results generated
  1387 				 * by Tcl_AppendResult.	 Malloc-ed.  NULL
  1388 				 * means not yet allocated. */
  1389     int appendAvl;		/* Total amount of space available at
  1390 				 * partialResult. */
  1391     int appendUsed;		/* Number of non-null bytes currently
  1392 				 * stored at partialResult. */
  1393 
  1394     /*
  1395      * Information about packages.  Used only in tclPkg.c.
  1396      */
  1397 
  1398     Tcl_HashTable packageTable;	/* Describes all of the packages loaded
  1399 				 * in or available to this interpreter.
  1400 				 * Keys are package names, values are
  1401 				 * (Package *) pointers. */
  1402     char *packageUnknown;	/* Command to invoke during "package
  1403 				 * require" commands for packages that
  1404 				 * aren't described in packageTable. 
  1405 				 * Malloc'ed, may be NULL. */
  1406 
  1407     /*
  1408      * Miscellaneous information:
  1409      */
  1410 
  1411     int cmdCount;		/* Total number of times a command procedure
  1412 				 * has been called for this interpreter. */
  1413     int evalFlags;		/* Flags to control next call to Tcl_Eval.
  1414 				 * Normally zero, but may be set before
  1415 				 * calling Tcl_Eval.  See below for valid
  1416 				 * values. */
  1417     int termOffset;		/* Offset of character just after last one
  1418 				 * compiled or executed by Tcl_EvalObj. */
  1419     LiteralTable literalTable;	/* Contains LiteralEntry's describing all
  1420 				 * Tcl objects holding literals of scripts
  1421 				 * compiled by the interpreter. Indexed by
  1422 				 * the string representations of literals.
  1423 				 * Used to avoid creating duplicate
  1424 				 * objects. */
  1425     int compileEpoch;		/* Holds the current "compilation epoch"
  1426 				 * for this interpreter. This is
  1427 				 * incremented to invalidate existing
  1428 				 * ByteCodes when, e.g., a command with a
  1429 				 * compile procedure is redefined. */
  1430     Proc *compiledProcPtr;	/* If a procedure is being compiled, a
  1431 				 * pointer to its Proc structure; otherwise,
  1432 				 * this is NULL. Set by ObjInterpProc in
  1433 				 * tclProc.c and used by tclCompile.c to
  1434 				 * process local variables appropriately. */
  1435     ResolverScheme *resolverPtr;
  1436 				/* Linked list of name resolution schemes
  1437 				 * added to this interpreter.  Schemes
  1438 				 * are added/removed by calling
  1439 				 * Tcl_AddInterpResolvers and
  1440 				 * Tcl_RemoveInterpResolver. */
  1441     Tcl_Obj *scriptFile;	/* NULL means there is no nested source
  1442 				 * command active;  otherwise this points to
  1443 				 * pathPtr of the file being sourced. */
  1444     int flags;			/* Various flag bits.  See below. */
  1445     long randSeed;		/* Seed used for rand() function. */
  1446     Trace *tracePtr;		/* List of traces for this interpreter. */
  1447     Tcl_HashTable *assocData;	/* Hash table for associating data with
  1448 				 * this interpreter. Cleaned up when
  1449 				 * this interpreter is deleted. */
  1450     struct ExecEnv *execEnvPtr;	/* Execution environment for Tcl bytecode
  1451 				 * execution. Contains a pointer to the
  1452 				 * Tcl evaluation stack. */
  1453     Tcl_Obj *emptyObjPtr;	/* Points to an object holding an empty
  1454 				 * string. Returned by Tcl_ObjSetVar2 when
  1455 				 * variable traces change a variable in a
  1456 				 * gross way. */
  1457     char resultSpace[TCL_RESULT_SIZE+1];
  1458 				/* Static space holding small results. */
  1459     Tcl_Obj *objResultPtr;	/* If the last command returned an object
  1460 				 * result, this points to it. Should not be
  1461 				 * accessed directly; see comment above. */
  1462     Tcl_ThreadId threadId;	/* ID of thread that owns the interpreter */
  1463 
  1464     ActiveCommandTrace *activeCmdTracePtr;
  1465 				/* First in list of active command traces for
  1466 				 * interp, or NULL if no active traces. */
  1467     ActiveInterpTrace *activeInterpTracePtr;
  1468 				/* First in list of active traces for
  1469 				 * interp, or NULL if no active traces. */
  1470 
  1471     int tracesForbiddingInline; /* Count of traces (in the list headed by
  1472 				 * tracePtr) that forbid inline bytecode
  1473 				 * compilation */
  1474 #ifdef TCL_TIP280
  1475     /* TIP #280 */
  1476     CmdFrame* cmdFramePtr;      /* Points to the command frame containing
  1477 				 * the location information for the current
  1478 				 * command. */
  1479     CONST CmdFrame* invokeCmdFramePtr; /* Points to the command frame which is the
  1480 				  * invoking context of the bytecode compiler.
  1481 				  * NULL when the byte code compiler is not
  1482 				  * active */
  1483     int invokeWord;             /* Index of the word in the command which
  1484 				 * is getting compiled. */
  1485     Tcl_HashTable* linePBodyPtr;
  1486                                 /* This table remembers for each
  1487 				 * statically defined procedure the
  1488 				 * location information for its
  1489 				 * body. It is keyed by the address of
  1490 				 * the Proc structure for a procedure.
  1491 				 */
  1492     Tcl_HashTable* lineBCPtr;
  1493                                 /* This table remembers for each
  1494 				 * ByteCode object the location
  1495 				 * information for its body. It is
  1496 				 * keyed by the address of the Proc
  1497 				 * structure for a procedure.
  1498 				 */
  1499 #endif
  1500 #ifdef TCL_TIP268
  1501     /*
  1502      * TIP #268.
  1503      * The currently active selection mode,
  1504      * i.e the package require preferences.
  1505      */
  1506 
  1507     int packagePrefer;          /* Current package selection mode. */
  1508 #endif
  1509     /*
  1510      * Statistical information about the bytecode compiler and interpreter's
  1511      * operation.
  1512      */
  1513 
  1514 #ifdef TCL_COMPILE_STATS
  1515     ByteCodeStats stats;	/* Holds compilation and execution
  1516 				 * statistics for this interpreter. */
  1517 #endif /* TCL_COMPILE_STATS */	  
  1518 } Interp;
  1519 
  1520 /*
  1521  * EvalFlag bits for Interp structures:
  1522  *
  1523  * TCL_BRACKET_TERM	1 means that the current script is terminated by
  1524  *			a close bracket rather than the end of the string.
  1525  * TCL_ALLOW_EXCEPTIONS	1 means it's OK for the script to terminate with
  1526  *			a code other than TCL_OK or TCL_ERROR;	0 means
  1527  *			codes other than these should be turned into errors.
  1528  */
  1529 
  1530 #define TCL_BRACKET_TERM	  1
  1531 #define TCL_ALLOW_EXCEPTIONS	  4
  1532 #ifdef TCL_TIP280
  1533 #define TCL_EVAL_FILE             2
  1534 #define TCL_EVAL_CTX              8
  1535 #endif
  1536 
  1537 /*
  1538  * Flag bits for Interp structures:
  1539  *
  1540  * DELETED:		Non-zero means the interpreter has been deleted:
  1541  *			don't process any more commands for it, and destroy
  1542  *			the structure as soon as all nested invocations of
  1543  *			Tcl_Eval are done.
  1544  * ERR_IN_PROGRESS:	Non-zero means an error unwind is already in
  1545  *			progress. Zero means a command proc has been
  1546  *			invoked since last error occured.
  1547  * ERR_ALREADY_LOGGED:	Non-zero means information has already been logged
  1548  *			in $errorInfo for the current Tcl_Eval instance,
  1549  *			so Tcl_Eval needn't log it (used to implement the
  1550  *			"error message log" command).
  1551  * ERROR_CODE_SET:	Non-zero means that Tcl_SetErrorCode has been
  1552  *			called to record information for the current
  1553  *			error.	Zero means Tcl_Eval must clear the
  1554  *			errorCode variable if an error is returned.
  1555  * EXPR_INITIALIZED:	Non-zero means initialization specific to
  1556  *			expressions has	been carried out.
  1557  * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler
  1558  *			should not compile any commands into an inline
  1559  *			sequence of instructions. This is set 1, for
  1560  *			example, when command traces are requested.
  1561  * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the
  1562  *			interp has not be initialized.	This is set 1
  1563  *			when we first use the rand() or srand() functions.
  1564  * SAFE_INTERP:		Non zero means that the current interp is a
  1565  *			safe interp (ie it has only the safe commands
  1566  *			installed, less priviledge than a regular interp).
  1567  * USE_EVAL_DIRECT:	Non-zero means don't use the compiler or byte-code
  1568  *			interpreter; instead, have Tcl_EvalObj call
  1569  *			Tcl_EvalEx. Used primarily for testing the
  1570  *			new parser.
  1571  * INTERP_TRACE_IN_PROGRESS: Non-zero means that an interp trace is currently
  1572  *			active; so no further trace callbacks should be
  1573  *			invoked.
  1574  */
  1575 
  1576 #define DELETED				    1
  1577 #define ERR_IN_PROGRESS			    2
  1578 #define ERR_ALREADY_LOGGED		    4
  1579 #define ERROR_CODE_SET			    8
  1580 #define EXPR_INITIALIZED		 0x10
  1581 #define DONT_COMPILE_CMDS_INLINE	 0x20
  1582 #define RAND_SEED_INITIALIZED		 0x40
  1583 #define SAFE_INTERP			 0x80
  1584 #define USE_EVAL_DIRECT			0x100
  1585 #define INTERP_TRACE_IN_PROGRESS	0x200
  1586 
  1587 /*
  1588  * Maximum number of levels of nesting permitted in Tcl commands (used
  1589  * to catch infinite recursion).
  1590  */
  1591 
  1592 #define MAX_NESTING_DEPTH	1000
  1593 
  1594 /*
  1595  * The macro below is used to modify a "char" value (e.g. by casting
  1596  * it to an unsigned character) so that it can be used safely with
  1597  * macros such as isspace.
  1598  */
  1599 
  1600 #define UCHAR(c) ((unsigned char) (c))
  1601 
  1602 /*
  1603  * This macro is used to determine the offset needed to safely allocate any
  1604  * data structure in memory. Given a starting offset or size, it "rounds up"
  1605  * or "aligns" the offset to the next 8-byte boundary so that any data
  1606  * structure can be placed at the resulting offset without fear of an
  1607  * alignment error.
  1608  *
  1609  * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce
  1610  * the wrong result on platforms that allocate addresses that are divisible
  1611  * by 4 or 2. Only use it for offsets or sizes.
  1612  */
  1613 
  1614 #define TCL_ALIGN(x) (((int)(x) + 7) & ~7)
  1615 
  1616 /*
  1617  * The following enum values are used to specify the runtime platform
  1618  * setting of the tclPlatform variable.
  1619  */
  1620 
  1621 typedef enum {
  1622     TCL_PLATFORM_UNIX,		/* Any Unix-like OS. */
  1623     TCL_PLATFORM_MAC,		/* MacOS. */
  1624     TCL_PLATFORM_WINDOWS	/* Any Microsoft Windows OS. */
  1625 } TclPlatformType;
  1626 
  1627 /*
  1628  *  The following enum values are used to indicate the translation
  1629  *  of a Tcl channel.  Declared here so that each platform can define
  1630  *  TCL_PLATFORM_TRANSLATION to the native translation on that platform
  1631  */
  1632 
  1633 typedef enum TclEolTranslation {
  1634     TCL_TRANSLATE_AUTO,                 /* Eol == \r, \n and \r\n. */
  1635     TCL_TRANSLATE_CR,                   /* Eol == \r. */
  1636     TCL_TRANSLATE_LF,                   /* Eol == \n. */
  1637     TCL_TRANSLATE_CRLF                  /* Eol == \r\n. */
  1638 } TclEolTranslation;
  1639 
  1640 /*
  1641  * Flags for TclInvoke:
  1642  *
  1643  * TCL_INVOKE_HIDDEN		Invoke a hidden command; if not set,
  1644  *				invokes an exposed command.
  1645  * TCL_INVOKE_NO_UNKNOWN	If set, "unknown" is not invoked if
  1646  *				the command to be invoked is not found.
  1647  *				Only has an effect if invoking an exposed
  1648  *				command, i.e. if TCL_INVOKE_HIDDEN is not
  1649  *				also set.
  1650  * TCL_INVOKE_NO_TRACEBACK	Does not record traceback information if
  1651  *				the invoked command returns an error.  Used
  1652  *				if the caller plans on recording its own
  1653  *				traceback information.
  1654  */
  1655 
  1656 #define	TCL_INVOKE_HIDDEN	(1<<0)
  1657 #define TCL_INVOKE_NO_UNKNOWN	(1<<1)
  1658 #define TCL_INVOKE_NO_TRACEBACK	(1<<2)
  1659 
  1660 /*
  1661  * The structure used as the internal representation of Tcl list
  1662  * objects. This is an array of pointers to the element objects. This array
  1663  * is grown (reallocated and copied) as necessary to hold all the list's
  1664  * element pointers. The array might contain more slots than currently used
  1665  * to hold all element pointers. This is done to make append operations
  1666  * faster.
  1667  */
  1668 
  1669 typedef struct List {
  1670     int maxElemCount;		/* Total number of element array slots. */
  1671     int elemCount;		/* Current number of list elements. */
  1672     Tcl_Obj **elements;		/* Array of pointers to element objects. */
  1673 } List;
  1674 
  1675 
  1676 /*
  1677  * The following types are used for getting and storing platform-specific
  1678  * file attributes in tclFCmd.c and the various platform-versions of
  1679  * that file. This is done to have as much common code as possible
  1680  * in the file attributes code. For more information about the callbacks,
  1681  * see TclFileAttrsCmd in tclFCmd.c.
  1682  */
  1683 
  1684 typedef int (TclGetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
  1685 	int objIndex, Tcl_Obj *fileName, Tcl_Obj **attrObjPtrPtr));
  1686 typedef int (TclSetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
  1687 	int objIndex, Tcl_Obj *fileName, Tcl_Obj *attrObjPtr));
  1688 
  1689 typedef struct TclFileAttrProcs {
  1690     TclGetFileAttrProc *getProc;	/* The procedure for getting attrs. */
  1691     TclSetFileAttrProc *setProc;	/* The procedure for setting attrs. */
  1692 } TclFileAttrProcs;
  1693 
  1694 /*
  1695  * Opaque handle used in pipeline routines to encapsulate platform-dependent
  1696  * state. 
  1697  */
  1698 
  1699 typedef struct TclFile_ *TclFile;
  1700     
  1701 /*
  1702  * Opaque names for platform specific types.
  1703  */
  1704 
  1705 typedef struct TclpTime_t_    *TclpTime_t;
  1706 typedef struct TclpTime_t_    *CONST TclpTime_t_CONST;
  1707 
  1708 /*
  1709  * The "globParameters" argument of the function TclGlob is an
  1710  * or'ed combination of the following values:
  1711  */
  1712 
  1713 #define TCL_GLOBMODE_NO_COMPLAIN      1
  1714 #define TCL_GLOBMODE_JOIN             2
  1715 #define TCL_GLOBMODE_DIR              4
  1716 #define TCL_GLOBMODE_TAILS            8
  1717 
  1718 /*
  1719  *----------------------------------------------------------------
  1720  * Data structures related to obsolete filesystem hooks
  1721  *----------------------------------------------------------------
  1722  */
  1723 
  1724 typedef int (TclStatProc_) _ANSI_ARGS_((CONST char *path, struct stat *buf));
  1725 typedef int (TclAccessProc_) _ANSI_ARGS_((CONST char *path, int mode));
  1726 typedef Tcl_Channel (TclOpenFileChannelProc_) _ANSI_ARGS_((Tcl_Interp *interp,
  1727 	CONST char *fileName, CONST char *modeString,
  1728 	int permissions));
  1729 
  1730 
  1731 /*
  1732  *----------------------------------------------------------------
  1733  * Data structures related to procedures
  1734  *----------------------------------------------------------------
  1735  */
  1736 
  1737 typedef Tcl_CmdProc *TclCmdProcType;
  1738 typedef Tcl_ObjCmdProc *TclObjCmdProcType;
  1739 
  1740 /*
  1741  *----------------------------------------------------------------
  1742  * Variables shared among Tcl modules but not used by the outside world.
  1743  *----------------------------------------------------------------
  1744  */
  1745 
  1746 extern Tcl_Time			tclBlockTime;
  1747 extern int			tclBlockTimeSet;
  1748 extern char *			tclExecutableName;
  1749 extern char *			tclNativeExecutableName;
  1750 extern char *			tclDefaultEncodingDir;
  1751 extern Tcl_ChannelType		tclFileChannelType;
  1752 extern char *			tclMemDumpFileName;
  1753 extern TclPlatformType		tclPlatform;
  1754 extern Tcl_NotifierProcs	tclOriginalNotifier;
  1755 
  1756 /*
  1757  * Variables denoting the Tcl object types defined in the core.
  1758  */
  1759 
  1760 extern Tcl_ObjType	tclBooleanType;
  1761 extern Tcl_ObjType	tclByteArrayType;
  1762 extern Tcl_ObjType	tclByteCodeType;
  1763 extern Tcl_ObjType	tclDoubleType;
  1764 extern Tcl_ObjType	tclEndOffsetType;
  1765 extern Tcl_ObjType	tclIntType;
  1766 extern Tcl_ObjType	tclListType;
  1767 extern Tcl_ObjType	tclProcBodyType;
  1768 extern Tcl_ObjType	tclStringType;
  1769 extern Tcl_ObjType	tclArraySearchType;
  1770 extern Tcl_ObjType	tclIndexType;
  1771 extern Tcl_ObjType	tclNsNameType;
  1772 extern Tcl_ObjType	tclWideIntType;
  1773 
  1774 /*
  1775  * Variables denoting the hash key types defined in the core.
  1776  */
  1777 
  1778 extern Tcl_HashKeyType tclArrayHashKeyType;
  1779 extern Tcl_HashKeyType tclOneWordHashKeyType;
  1780 extern Tcl_HashKeyType tclStringHashKeyType;
  1781 extern Tcl_HashKeyType tclObjHashKeyType;
  1782 
  1783 /*
  1784  * The head of the list of free Tcl objects, and the total number of Tcl
  1785  * objects ever allocated and freed.
  1786  */
  1787 
  1788 extern Tcl_Obj *	tclFreeObjList;
  1789 
  1790 #ifdef TCL_COMPILE_STATS
  1791 extern long		tclObjsAlloced;
  1792 extern long		tclObjsFreed;
  1793 #define TCL_MAX_SHARED_OBJ_STATS 5
  1794 extern long		tclObjsShared[TCL_MAX_SHARED_OBJ_STATS];
  1795 #endif /* TCL_COMPILE_STATS */
  1796 
  1797 /*
  1798  * Pointer to a heap-allocated string of length zero that the Tcl core uses
  1799  * as the value of an empty string representation for an object. This value
  1800  * is shared by all new objects allocated by Tcl_NewObj.
  1801  */
  1802 
  1803 extern char *		tclEmptyStringRep;
  1804 extern char		tclEmptyString;
  1805 
  1806 /*
  1807  *----------------------------------------------------------------
  1808  * Procedures shared among Tcl modules but not used by the outside
  1809  * world:
  1810  *----------------------------------------------------------------
  1811  */
  1812 
  1813 #ifdef TCL_TIP280
  1814 EXTERN void             TclAdvanceLines _ANSI_ARGS_((int* line, CONST char* start,
  1815 						     CONST char* end));
  1816 #endif
  1817 EXTERN int		TclArraySet _ANSI_ARGS_((Tcl_Interp *interp,
  1818 			    Tcl_Obj *arrayNameObj, Tcl_Obj *arrayElemObj));
  1819 EXTERN int		TclCheckBadOctal _ANSI_ARGS_((Tcl_Interp *interp,
  1820 			    CONST char *value));
  1821 EXTERN void		TclDeleteNamespaceVars _ANSI_ARGS_((Namespace *nsPtr));
  1822 
  1823 #ifdef TCL_TIP280
  1824 EXTERN int              TclEvalObjEx _ANSI_ARGS_((Tcl_Interp *interp,
  1825 						  register Tcl_Obj *objPtr,
  1826 						  int flags,
  1827 						  CONST CmdFrame* invoker,
  1828 						  int word));
  1829 #endif
  1830 
  1831 EXTERN void		TclExpandTokenArray _ANSI_ARGS_((
  1832 			    Tcl_Parse *parsePtr));
  1833 EXTERN int		TclFileAttrsCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1834 			    int objc, Tcl_Obj *CONST objv[]));
  1835 EXTERN int		TclFileCopyCmd _ANSI_ARGS_((Tcl_Interp *interp, 
  1836 			    int objc, Tcl_Obj *CONST objv[])) ;
  1837 EXTERN int		TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1838 			    int objc, Tcl_Obj *CONST objv[]));
  1839 EXTERN int		TclFileMakeDirsCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1840 			    int objc, Tcl_Obj *CONST objv[])) ;
  1841 EXTERN int		TclFileRenameCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1842 			    int objc, Tcl_Obj *CONST objv[])) ;
  1843 EXTERN void		TclFinalizeAllocSubsystem _ANSI_ARGS_((void));
  1844 EXTERN void		TclFinalizeAsync _ANSI_ARGS_((void));
  1845 EXTERN void		TclFinalizeCompilation _ANSI_ARGS_((void));
  1846 EXTERN void		TclFinalizeEncodingSubsystem _ANSI_ARGS_((void));
  1847 EXTERN void		TclFinalizeEnvironment _ANSI_ARGS_((void));
  1848 EXTERN void		TclFinalizeExecution _ANSI_ARGS_((void));
  1849 EXTERN void		TclFinalizeIOSubsystem _ANSI_ARGS_((void));
  1850 EXTERN void		TclFinalizeFilesystem _ANSI_ARGS_((void));
  1851 EXTERN void		TclResetFilesystem _ANSI_ARGS_((void));
  1852 EXTERN void		TclFinalizeLoad _ANSI_ARGS_((void));
  1853 EXTERN void		TclFinalizeLock _ANSI_ARGS_((void));
  1854 EXTERN void		TclFinalizeMemorySubsystem _ANSI_ARGS_((void));
  1855 EXTERN void		TclFinalizeNotifier _ANSI_ARGS_((void));
  1856 EXTERN void		TclFinalizeObjects _ANSI_ARGS_((void));
  1857 EXTERN void		TclFinalizePreserve _ANSI_ARGS_((void));
  1858 EXTERN void		TclFinalizeSynchronization _ANSI_ARGS_((void));
  1859 EXTERN void		TclFinalizeThreadAlloc _ANSI_ARGS_((void));
  1860 EXTERN void		TclFinalizeThreadData _ANSI_ARGS_((void));
  1861 EXTERN int		TclGetEncodingFromObj _ANSI_ARGS_((Tcl_Interp *interp,
  1862 			    Tcl_Obj *objPtr, Tcl_Encoding *encodingPtr));
  1863 #ifdef TCL_TIP280
  1864 EXTERN void             TclGetSrcInfoForPc _ANSI_ARGS_((CmdFrame* cfPtr));
  1865 #endif
  1866 EXTERN int		TclGlob _ANSI_ARGS_((Tcl_Interp *interp,
  1867 			    char *pattern, Tcl_Obj *unquotedPrefix, 
  1868 			    int globFlags, Tcl_GlobTypeData* types));
  1869 EXTERN void		TclInitAlloc _ANSI_ARGS_((void));
  1870 EXTERN void		TclInitDbCkalloc _ANSI_ARGS_((void));
  1871 EXTERN void		TclInitEncodingSubsystem _ANSI_ARGS_((void));
  1872 EXTERN void		TclInitIOSubsystem _ANSI_ARGS_((void));
  1873 EXTERN void		TclInitNamespaceSubsystem _ANSI_ARGS_((void));
  1874 EXTERN void		TclInitNotifier _ANSI_ARGS_((void));
  1875 EXTERN void		TclInitObjSubsystem _ANSI_ARGS_((void));
  1876 EXTERN void		TclInitSubsystems _ANSI_ARGS_((CONST char *argv0));
  1877 EXTERN int		TclIsLocalScalar _ANSI_ARGS_((CONST char *src,
  1878 			    int len));
  1879 EXTERN int              TclJoinThread _ANSI_ARGS_((Tcl_ThreadId id,
  1880 			    int* result));
  1881 EXTERN Tcl_Obj *	TclLindexList _ANSI_ARGS_((Tcl_Interp* interp,
  1882 						   Tcl_Obj* listPtr,
  1883 						   Tcl_Obj* argPtr ));
  1884 EXTERN Tcl_Obj *	TclLindexFlat _ANSI_ARGS_((Tcl_Interp* interp,
  1885 						   Tcl_Obj* listPtr,
  1886 						   int indexCount,
  1887 						   Tcl_Obj *CONST indexArray[]
  1888 						   ));
  1889 EXTERN Tcl_Obj *	TclLsetList _ANSI_ARGS_((Tcl_Interp* interp,
  1890 						 Tcl_Obj* listPtr,
  1891 						 Tcl_Obj* indexPtr,
  1892 						 Tcl_Obj* valuePtr  
  1893 						 ));
  1894 EXTERN Tcl_Obj *	TclLsetFlat _ANSI_ARGS_((Tcl_Interp* interp,
  1895 						 Tcl_Obj* listPtr,
  1896 						 int indexCount,
  1897 						 Tcl_Obj *CONST indexArray[],
  1898 						 Tcl_Obj* valuePtr
  1899 						 ));
  1900 EXTERN int              TclParseBackslash _ANSI_ARGS_((CONST char *src,
  1901                             int numBytes, int *readPtr, char *dst));
  1902 EXTERN int		TclParseHex _ANSI_ARGS_((CONST char *src, int numBytes,
  1903                             Tcl_UniChar *resultPtr));
  1904 EXTERN int		TclParseInteger _ANSI_ARGS_((CONST char *string,
  1905 			    int numBytes));
  1906 EXTERN int		TclParseWhiteSpace _ANSI_ARGS_((CONST char *src,
  1907 			    int numBytes, Tcl_Parse *parsePtr, char *typePtr));
  1908 #ifdef TCL_TIP280
  1909 EXTERN int              TclWordKnownAtCompileTime _ANSI_ARGS_((Tcl_Token* token));
  1910 #endif
  1911 EXTERN int		TclpObjAccess _ANSI_ARGS_((Tcl_Obj *filename,
  1912 			    int mode));
  1913 EXTERN int              TclpObjLstat _ANSI_ARGS_((Tcl_Obj *pathPtr, 
  1914 			    Tcl_StatBuf *buf));
  1915 EXTERN int		TclpCheckStackSpace _ANSI_ARGS_((void));
  1916 EXTERN Tcl_Obj*         TclpTempFileName _ANSI_ARGS_((void));
  1917 EXTERN Tcl_Obj*         TclNewFSPathObj _ANSI_ARGS_((Tcl_Obj *dirPtr, 
  1918 			    CONST char *addStrRep, int len));
  1919 EXTERN int              TclpDeleteFile _ANSI_ARGS_((CONST char *path));
  1920 EXTERN void		TclpFinalizeCondition _ANSI_ARGS_((
  1921 			    Tcl_Condition *condPtr));
  1922 EXTERN void		TclpFinalizeMutex _ANSI_ARGS_((Tcl_Mutex *mutexPtr));
  1923 EXTERN void		TclpFinalizePipes _ANSI_ARGS_((void));
  1924 EXTERN void		TclpFinalizeSockets _ANSI_ARGS_((void));
  1925 EXTERN void		TclpFinalizeThreadData _ANSI_ARGS_((
  1926 			    Tcl_ThreadDataKey *keyPtr));
  1927 EXTERN void		TclpFinalizeThreadDataKey _ANSI_ARGS_((
  1928 			    Tcl_ThreadDataKey *keyPtr));
  1929 EXTERN char *		TclpFindExecutable _ANSI_ARGS_((
  1930 			    CONST char *argv0));
  1931 EXTERN int		TclpFindVariable _ANSI_ARGS_((CONST char *name,
  1932 			    int *lengthPtr));
  1933 EXTERN int		TclpInitLibraryPath _ANSI_ARGS_((CONST char *argv0));
  1934 EXTERN void		TclpInitLock _ANSI_ARGS_((void));
  1935 EXTERN void		TclpInitPlatform _ANSI_ARGS_((void));
  1936 EXTERN void		TclpInitUnlock _ANSI_ARGS_((void));
  1937 EXTERN int              TclpLoadFile _ANSI_ARGS_((Tcl_Interp *interp, 
  1938 				Tcl_Obj *pathPtr,
  1939 				CONST char *sym1, CONST char *sym2, 
  1940 				Tcl_PackageInitProc **proc1Ptr,
  1941 				Tcl_PackageInitProc **proc2Ptr, 
  1942 				ClientData *clientDataPtr,
  1943 				Tcl_FSUnloadFileProc **unloadProcPtr));
  1944 EXTERN Tcl_Obj*		TclpObjListVolumes _ANSI_ARGS_((void));
  1945 EXTERN void		TclpMasterLock _ANSI_ARGS_((void));
  1946 EXTERN void		TclpMasterUnlock _ANSI_ARGS_((void));
  1947 EXTERN int		TclpMatchFiles _ANSI_ARGS_((Tcl_Interp *interp,
  1948 			    char *separators, Tcl_DString *dirPtr,
  1949 			    char *pattern, char *tail));
  1950 EXTERN int              TclpObjNormalizePath _ANSI_ARGS_((Tcl_Interp *interp, 
  1951 			    Tcl_Obj *pathPtr, int nextCheckpoint));
  1952 EXTERN int		TclpObjCreateDirectory _ANSI_ARGS_((Tcl_Obj *pathPtr));
  1953 EXTERN void             TclpNativeJoinPath _ANSI_ARGS_((Tcl_Obj *prefix, 
  1954 							char *joining));
  1955 EXTERN Tcl_Obj*         TclpNativeSplitPath _ANSI_ARGS_((Tcl_Obj *pathPtr, 
  1956 							 int *lenPtr));
  1957 EXTERN Tcl_PathType     TclpGetNativePathType _ANSI_ARGS_((Tcl_Obj *pathObjPtr,
  1958 			    int *driveNameLengthPtr, Tcl_Obj **driveNameRef));
  1959 EXTERN int 		TclCrossFilesystemCopy _ANSI_ARGS_((Tcl_Interp *interp, 
  1960 			    Tcl_Obj *source, Tcl_Obj *target));
  1961 EXTERN int		TclpObjDeleteFile _ANSI_ARGS_((Tcl_Obj *pathPtr));
  1962 EXTERN int		TclpObjCopyDirectory _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 
  1963 				Tcl_Obj *destPathPtr, Tcl_Obj **errorPtr));
  1964 EXTERN int		TclpObjCopyFile _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 
  1965 				Tcl_Obj *destPathPtr));
  1966 EXTERN int		TclpObjRemoveDirectory _ANSI_ARGS_((Tcl_Obj *pathPtr, 
  1967 				int recursive, Tcl_Obj **errorPtr));
  1968 EXTERN int		TclpObjRenameFile _ANSI_ARGS_((Tcl_Obj *srcPathPtr, 
  1969 				Tcl_Obj *destPathPtr));
  1970 EXTERN int		TclpMatchInDirectory _ANSI_ARGS_((Tcl_Interp *interp, 
  1971 			        Tcl_Obj *resultPtr, Tcl_Obj *pathPtr, 
  1972 				CONST char *pattern, Tcl_GlobTypeData *types));
  1973 EXTERN Tcl_Obj*		TclpObjGetCwd _ANSI_ARGS_((Tcl_Interp *interp));
  1974 EXTERN Tcl_FSDupInternalRepProc TclNativeDupInternalRep;
  1975 EXTERN Tcl_Obj*		TclpObjLink _ANSI_ARGS_((Tcl_Obj *pathPtr, 
  1976 				Tcl_Obj *toPtr, int linkType));
  1977 EXTERN int		TclpObjChdir _ANSI_ARGS_((Tcl_Obj *pathPtr));
  1978 EXTERN Tcl_Obj*         TclFileDirname _ANSI_ARGS_((Tcl_Interp *interp, 
  1979 						    Tcl_Obj*pathPtr));
  1980 EXTERN int		TclpObjStat _ANSI_ARGS_((Tcl_Obj *pathPtr, Tcl_StatBuf *buf));
  1981 EXTERN Tcl_Channel	TclpOpenFileChannel _ANSI_ARGS_((Tcl_Interp *interp,
  1982 			    Tcl_Obj *pathPtr, int mode,
  1983 			    int permissions));
  1984 EXTERN void		TclpPanic _ANSI_ARGS_(TCL_VARARGS(CONST char *,
  1985 			    format));
  1986 EXTERN char *		TclpReadlink _ANSI_ARGS_((CONST char *fileName,
  1987 			    Tcl_DString *linkPtr));
  1988 EXTERN void		TclpReleaseFile _ANSI_ARGS_((TclFile file));
  1989 EXTERN void		TclpSetVariables _ANSI_ARGS_((Tcl_Interp *interp));
  1990 EXTERN void		TclpUnloadFile _ANSI_ARGS_((Tcl_LoadHandle loadHandle));
  1991 EXTERN VOID *		TclpThreadDataKeyGet _ANSI_ARGS_((
  1992 			    Tcl_ThreadDataKey *keyPtr));
  1993 EXTERN void		TclpThreadDataKeyInit _ANSI_ARGS_((
  1994 			    Tcl_ThreadDataKey *keyPtr));
  1995 EXTERN void		TclpThreadDataKeySet _ANSI_ARGS_((
  1996 			    Tcl_ThreadDataKey *keyPtr, VOID *data));
  1997 EXTERN int		TclpThreadCreate _ANSI_ARGS_((
  1998 			    Tcl_ThreadId *idPtr,
  1999 			    Tcl_ThreadCreateProc proc,
  2000 			    ClientData clientData,
  2001 			    int stackSize, int flags));
  2002 EXTERN void		TclpThreadExit _ANSI_ARGS_((int status));
  2003 EXTERN void		TclRememberCondition _ANSI_ARGS_((Tcl_Condition *mutex));
  2004 EXTERN void		TclRememberDataKey _ANSI_ARGS_((Tcl_ThreadDataKey *mutex));
  2005 EXTERN VOID             TclRememberJoinableThread _ANSI_ARGS_((Tcl_ThreadId id));
  2006 EXTERN void		TclRememberMutex _ANSI_ARGS_((Tcl_Mutex *mutex));
  2007 EXTERN VOID             TclSignalExitThread _ANSI_ARGS_((Tcl_ThreadId id,
  2008 			     int result));
  2009 EXTERN void		TclTransferResult _ANSI_ARGS_((Tcl_Interp *sourceInterp,
  2010 			    int result, Tcl_Interp *targetInterp));
  2011 EXTERN Tcl_Obj*         TclpNativeToNormalized 
  2012                             _ANSI_ARGS_((ClientData clientData));
  2013 EXTERN Tcl_Obj*	        TclpFilesystemPathType
  2014 					_ANSI_ARGS_((Tcl_Obj* pathObjPtr));
  2015 EXTERN Tcl_PackageInitProc* TclpFindSymbol _ANSI_ARGS_((Tcl_Interp *interp,
  2016 			    Tcl_LoadHandle loadHandle, CONST char *symbol));
  2017 EXTERN int              TclpDlopen _ANSI_ARGS_((Tcl_Interp *interp, 
  2018 			    Tcl_Obj *pathPtr, 
  2019 	                    Tcl_LoadHandle *loadHandle, 
  2020 		            Tcl_FSUnloadFileProc **unloadProcPtr));
  2021 EXTERN int              TclpUtime _ANSI_ARGS_((Tcl_Obj *pathPtr,
  2022 					       struct utimbuf *tval));
  2023 
  2024 #ifdef TCL_LOAD_FROM_MEMORY
  2025 EXTERN void*	        TclpLoadMemoryGetBuffer _ANSI_ARGS_((
  2026 			    Tcl_Interp *interp, int size));
  2027 EXTERN int	        TclpLoadMemory _ANSI_ARGS_((Tcl_Interp *interp, 
  2028 			    void *buffer, int size, int codeSize, 
  2029 			    Tcl_LoadHandle *loadHandle, 
  2030 			    Tcl_FSUnloadFileProc **unloadProcPtr));
  2031 #endif
  2032 
  2033 #ifdef __SYMBIAN32__
  2034 EXTERN int	SetupStdFile _ANSI_ARGS_((TclFile file, int type));
  2035 #endif
  2036 /*
  2037  *----------------------------------------------------------------
  2038  * Command procedures in the generic core:
  2039  *----------------------------------------------------------------
  2040  */
  2041 
  2042 EXTERN int	Tcl_AfterObjCmd _ANSI_ARGS_((ClientData clientData,
  2043 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2044 EXTERN int	Tcl_AppendObjCmd _ANSI_ARGS_((ClientData clientData,
  2045 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2046 EXTERN int	Tcl_ArrayObjCmd _ANSI_ARGS_((ClientData clientData,
  2047 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2048 EXTERN int	Tcl_BinaryObjCmd _ANSI_ARGS_((ClientData clientData,
  2049 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2050 EXTERN int	Tcl_BreakObjCmd _ANSI_ARGS_((ClientData clientData,
  2051 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2052 EXTERN int	Tcl_CaseObjCmd _ANSI_ARGS_((ClientData clientData,
  2053 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2054 EXTERN int	Tcl_CatchObjCmd _ANSI_ARGS_((ClientData clientData,
  2055 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2056 EXTERN int	Tcl_CdObjCmd _ANSI_ARGS_((ClientData clientData,
  2057 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2058 EXTERN int	Tcl_ClockObjCmd _ANSI_ARGS_((ClientData clientData,
  2059 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2060 EXTERN int	Tcl_CloseObjCmd _ANSI_ARGS_((ClientData clientData,
  2061 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2062 EXTERN int	Tcl_ConcatObjCmd _ANSI_ARGS_((ClientData clientData,
  2063 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2064 EXTERN int	Tcl_ContinueObjCmd _ANSI_ARGS_((ClientData clientData,
  2065 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2066 EXTERN int	Tcl_EncodingObjCmd _ANSI_ARGS_((ClientData clientData,
  2067 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2068 EXTERN int	Tcl_EofObjCmd _ANSI_ARGS_((ClientData clientData,
  2069 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2070 EXTERN int	Tcl_ErrorObjCmd _ANSI_ARGS_((ClientData clientData,
  2071 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2072 EXTERN int	Tcl_EvalObjCmd _ANSI_ARGS_((ClientData clientData,
  2073 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2074 EXTERN int	Tcl_ExecObjCmd _ANSI_ARGS_((ClientData clientData,
  2075 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2076 EXTERN int	Tcl_ExitObjCmd _ANSI_ARGS_((ClientData clientData,
  2077 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2078 EXTERN int	Tcl_ExprObjCmd _ANSI_ARGS_((ClientData clientData,
  2079 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2080 EXTERN int	Tcl_FblockedObjCmd _ANSI_ARGS_((ClientData clientData,
  2081 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2082 EXTERN int	Tcl_FconfigureObjCmd _ANSI_ARGS_((ClientData clientData,
  2083 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2084 EXTERN int	Tcl_FcopyObjCmd _ANSI_ARGS_((ClientData dummy,
  2085 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2086 EXTERN int	Tcl_FileObjCmd _ANSI_ARGS_((ClientData dummy,
  2087 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2088 EXTERN int	Tcl_FileEventObjCmd _ANSI_ARGS_((ClientData clientData,
  2089 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2090 EXTERN int	Tcl_FlushObjCmd _ANSI_ARGS_((ClientData clientData,
  2091 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2092 EXTERN int	Tcl_ForObjCmd _ANSI_ARGS_((ClientData clientData,
  2093 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2094 EXTERN int	Tcl_ForeachObjCmd _ANSI_ARGS_((ClientData clientData,
  2095 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2096 EXTERN int	Tcl_FormatObjCmd _ANSI_ARGS_((ClientData dummy,
  2097 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2098 EXTERN int	Tcl_GetsObjCmd _ANSI_ARGS_((ClientData clientData,
  2099 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2100 EXTERN int	Tcl_GlobalObjCmd _ANSI_ARGS_((ClientData clientData,
  2101 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2102 EXTERN int	Tcl_GlobObjCmd _ANSI_ARGS_((ClientData clientData,
  2103 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2104 EXTERN int	Tcl_IfObjCmd _ANSI_ARGS_((ClientData clientData,
  2105 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2106 EXTERN int	Tcl_IncrObjCmd _ANSI_ARGS_((ClientData clientData,
  2107 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2108 EXTERN int	Tcl_InfoObjCmd _ANSI_ARGS_((ClientData clientData,
  2109 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2110 EXTERN int	Tcl_InterpObjCmd _ANSI_ARGS_((ClientData clientData,
  2111 		    Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[]));
  2112 EXTERN int	Tcl_JoinObjCmd _ANSI_ARGS_((ClientData clientData,
  2113 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2114 EXTERN int	Tcl_LappendObjCmd _ANSI_ARGS_((ClientData clientData,
  2115 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2116 EXTERN int	Tcl_LindexObjCmd _ANSI_ARGS_((ClientData clientData,
  2117 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2118 EXTERN int	Tcl_LinsertObjCmd _ANSI_ARGS_((ClientData clientData,
  2119 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2120 EXTERN int	Tcl_LlengthObjCmd _ANSI_ARGS_((ClientData clientData,
  2121 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2122 EXTERN int	Tcl_ListObjCmd _ANSI_ARGS_((ClientData clientData,
  2123 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2124 EXTERN int	Tcl_LoadObjCmd _ANSI_ARGS_((ClientData clientData,
  2125 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2126 EXTERN int	Tcl_LrangeObjCmd _ANSI_ARGS_((ClientData clientData,
  2127 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2128 EXTERN int	Tcl_LreplaceObjCmd _ANSI_ARGS_((ClientData clientData,
  2129 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2130 EXTERN int	Tcl_LsearchObjCmd _ANSI_ARGS_((ClientData clientData,
  2131 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2132 EXTERN int	Tcl_LsetObjCmd _ANSI_ARGS_((ClientData clientData,
  2133                     Tcl_Interp* interp, int objc, Tcl_Obj *CONST objv[]));
  2134 EXTERN int	Tcl_LsortObjCmd _ANSI_ARGS_((ClientData clientData,
  2135 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2136 EXTERN int	Tcl_NamespaceObjCmd _ANSI_ARGS_((ClientData clientData,
  2137 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2138 EXTERN int	Tcl_OpenObjCmd _ANSI_ARGS_((ClientData clientData,
  2139 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2140 EXTERN int	Tcl_PackageObjCmd _ANSI_ARGS_((ClientData clientData,
  2141 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2142 EXTERN int	Tcl_PidObjCmd _ANSI_ARGS_((ClientData clientData,
  2143 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2144 EXTERN int	Tcl_PutsObjCmd _ANSI_ARGS_((ClientData clientData,
  2145 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2146 EXTERN int	Tcl_PwdObjCmd _ANSI_ARGS_((ClientData clientData,
  2147 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2148 EXTERN int	Tcl_ReadObjCmd _ANSI_ARGS_((ClientData clientData,
  2149 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2150 EXTERN int	Tcl_RegexpObjCmd _ANSI_ARGS_((ClientData clientData,
  2151 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2152 EXTERN int	Tcl_RegsubObjCmd _ANSI_ARGS_((ClientData clientData,
  2153 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2154 EXTERN int	Tcl_RenameObjCmd _ANSI_ARGS_((ClientData clientData,
  2155 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2156 EXTERN int	Tcl_ReturnObjCmd _ANSI_ARGS_((ClientData clientData,
  2157 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2158 EXTERN int	Tcl_ScanObjCmd _ANSI_ARGS_((ClientData clientData,
  2159 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2160 EXTERN int	Tcl_SeekObjCmd _ANSI_ARGS_((ClientData clientData,
  2161 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2162 EXTERN int	Tcl_SetObjCmd _ANSI_ARGS_((ClientData clientData,
  2163 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2164 EXTERN int	Tcl_SplitObjCmd _ANSI_ARGS_((ClientData clientData,
  2165 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2166 EXTERN int	Tcl_SocketObjCmd _ANSI_ARGS_((ClientData clientData,
  2167 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2168 EXTERN int	Tcl_SourceObjCmd _ANSI_ARGS_((ClientData clientData,
  2169 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2170 EXTERN int	Tcl_StringObjCmd _ANSI_ARGS_((ClientData clientData,
  2171 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2172 EXTERN int	Tcl_SubstObjCmd _ANSI_ARGS_((ClientData clientData,
  2173 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2174 EXTERN int	Tcl_SwitchObjCmd _ANSI_ARGS_((ClientData clientData,
  2175 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2176 EXTERN int	Tcl_TellObjCmd _ANSI_ARGS_((ClientData clientData,
  2177 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2178 EXTERN int	Tcl_TimeObjCmd _ANSI_ARGS_((ClientData clientData,
  2179 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2180 EXTERN int	Tcl_TraceObjCmd _ANSI_ARGS_((ClientData clientData,
  2181 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2182 EXTERN int	Tcl_UnsetObjCmd _ANSI_ARGS_((ClientData clientData,
  2183 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2184 EXTERN int	Tcl_UpdateObjCmd _ANSI_ARGS_((ClientData clientData,
  2185 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2186 EXTERN int	Tcl_UplevelObjCmd _ANSI_ARGS_((ClientData clientData,
  2187 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2188 EXTERN int	Tcl_UpvarObjCmd _ANSI_ARGS_((ClientData clientData,
  2189 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2190 EXTERN int	Tcl_VariableObjCmd _ANSI_ARGS_((ClientData clientData,
  2191 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2192 EXTERN int	Tcl_VwaitObjCmd _ANSI_ARGS_((ClientData clientData,
  2193 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2194 EXTERN int	Tcl_WhileObjCmd _ANSI_ARGS_((ClientData clientData,
  2195 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2196 
  2197 /*
  2198  *----------------------------------------------------------------
  2199  * Command procedures found only in the Mac version of the core:
  2200  *----------------------------------------------------------------
  2201  */
  2202 
  2203 #ifdef MAC_TCL
  2204 EXTERN int	Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData,
  2205 		    Tcl_Interp *interp, int argc, CONST84 char **argv));
  2206 EXTERN int	Tcl_LsObjCmd _ANSI_ARGS_((ClientData clientData,
  2207 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2208 EXTERN int	Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData,
  2209 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2210 EXTERN int	Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData,
  2211 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2212 EXTERN int	Tcl_ResourceObjCmd _ANSI_ARGS_((ClientData clientData,
  2213 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  2214 #endif
  2215 
  2216 /*
  2217  *----------------------------------------------------------------
  2218  * Compilation procedures for commands in the generic core:
  2219  *----------------------------------------------------------------
  2220  */
  2221 
  2222 EXTERN int	TclCompileAppendCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2223 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2224 EXTERN int	TclCompileBreakCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2225 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2226 EXTERN int	TclCompileCatchCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2227 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2228 EXTERN int	TclCompileContinueCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2229 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2230 EXTERN int	TclCompileExprCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2231 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2232 EXTERN int	TclCompileForCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2233 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2234 EXTERN int	TclCompileForeachCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2235 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2236 EXTERN int	TclCompileIfCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2237 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2238 EXTERN int	TclCompileIncrCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2239 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2240 EXTERN int	TclCompileLappendCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2241 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2242 EXTERN int	TclCompileLindexCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2243 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2244 EXTERN int	TclCompileListCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2245 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2246 EXTERN int	TclCompileLlengthCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2247 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2248 EXTERN int	TclCompileLsetCmd _ANSI_ARGS_((Tcl_Interp* interp,
  2249 		    Tcl_Parse* parsePtr, struct CompileEnv* envPtr));
  2250 EXTERN int	TclCompileRegexpCmd _ANSI_ARGS_((Tcl_Interp* interp,
  2251 		    Tcl_Parse* parsePtr, struct CompileEnv* envPtr));
  2252 EXTERN int	TclCompileReturnCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2253 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2254 EXTERN int	TclCompileSetCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2255 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2256 EXTERN int	TclCompileStringCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2257 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2258 EXTERN int	TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp,
  2259 		    Tcl_Parse *parsePtr, struct CompileEnv *envPtr));
  2260 
  2261 /*
  2262  * Functions defined in generic/tclVar.c and currenttly exported only 
  2263  * for use by the bytecode compiler and engine. Some of these could later 
  2264  * be placed in the public interface.
  2265  */
  2266 
  2267 EXTERN Var *	TclLookupArrayElement _ANSI_ARGS_((Tcl_Interp *interp,
  2268 		    CONST char *arrayName, CONST char *elName, CONST int flags,
  2269 		    CONST char *msg, CONST int createPart1,
  2270 		    CONST int createPart2, Var *arrayPtr));	
  2271 EXTERN Var *    TclObjLookupVar _ANSI_ARGS_((Tcl_Interp *interp,
  2272 		    Tcl_Obj *part1Ptr, CONST char *part2, int flags,
  2273 		    CONST char *msg, CONST int createPart1,
  2274 		    CONST int createPart2, Var **arrayPtrPtr));
  2275 EXTERN Tcl_Obj *TclPtrGetVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr,
  2276 		    Var *arrayPtr, CONST char *part1, CONST char *part2,
  2277 		    CONST int flags));
  2278 EXTERN Tcl_Obj *TclPtrSetVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr,
  2279 		    Var *arrayPtr, CONST char *part1, CONST char *part2,
  2280 		    Tcl_Obj *newValuePtr, CONST int flags));
  2281 EXTERN Tcl_Obj *TclPtrIncrVar _ANSI_ARGS_((Tcl_Interp *interp, Var *varPtr,
  2282 		    Var *arrayPtr, CONST char *part1, CONST char *part2,
  2283 		    CONST long i, CONST int flags));
  2284 
  2285 /*
  2286  *----------------------------------------------------------------
  2287  * Macros used by the Tcl core to create and release Tcl objects.
  2288  * TclNewObj(objPtr) creates a new object denoting an empty string.
  2289  * TclDecrRefCount(objPtr) decrements the object's reference count,
  2290  * and frees the object if its reference count is zero.
  2291  * These macros are inline versions of Tcl_NewObj() and
  2292  * Tcl_DecrRefCount(). Notice that the names differ in not having
  2293  * a "_" after the "Tcl". Notice also that these macros reference
  2294  * their argument more than once, so you should avoid calling them
  2295  * with an expression that is expensive to compute or has
  2296  * side effects. The ANSI C "prototypes" for these macros are:
  2297  *
  2298  * EXTERN void	TclNewObj _ANSI_ARGS_((Tcl_Obj *objPtr));
  2299  * EXTERN void	TclDecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
  2300  *
  2301  * These macros are defined in terms of two macros that depend on 
  2302  * memory allocator in use: TclAllocObjStorage, TclFreeObjStorage.
  2303  * They are defined below.
  2304  *----------------------------------------------------------------
  2305  */
  2306 
  2307 #ifdef TCL_COMPILE_STATS
  2308 #  define TclIncrObjsAllocated() \
  2309     tclObjsAlloced++
  2310 #  define TclIncrObjsFreed() \
  2311     tclObjsFreed++
  2312 #else
  2313 #  define TclIncrObjsAllocated()
  2314 #  define TclIncrObjsFreed()
  2315 #endif /* TCL_COMPILE_STATS */
  2316 
  2317 #define TclNewObj(objPtr) \
  2318     TclAllocObjStorage(objPtr); \
  2319     TclIncrObjsAllocated(); \
  2320     (objPtr)->refCount = 0; \
  2321     (objPtr)->bytes    = tclEmptyStringRep; \
  2322     (objPtr)->length   = 0; \
  2323     (objPtr)->typePtr  = NULL
  2324 
  2325 
  2326 #ifdef TCL_MEM_DEBUG
  2327 #   define TclDecrRefCount(objPtr) \
  2328 	Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
  2329 #else
  2330 #   define TclDecrRefCount(objPtr) \
  2331     if (--(objPtr)->refCount <= 0) { \
  2332 	if (((objPtr)->typePtr != NULL) \
  2333 		&& ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
  2334 	    (objPtr)->typePtr->freeIntRepProc(objPtr); \
  2335 	} \
  2336 	if (((objPtr)->bytes != NULL) \
  2337 		&& ((objPtr)->bytes != tclEmptyStringRep)) { \
  2338 	    ckfree((char *) (objPtr)->bytes); \
  2339 	} \
  2340         TclFreeObjStorage(objPtr); \
  2341 	TclIncrObjsFreed(); \
  2342     }
  2343 #endif
  2344 
  2345 #ifdef TCL_MEM_DEBUG
  2346 #  define TclAllocObjStorage(objPtr) \
  2347        (objPtr) = (Tcl_Obj *) \
  2348            Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__)
  2349 
  2350 #  define TclFreeObjStorage(objPtr) \
  2351        if ((objPtr)->refCount < -1) { \
  2352            panic("Reference count for %lx was negative: %s line %d", \
  2353 	           (objPtr), __FILE__, __LINE__); \
  2354        } \
  2355        ckfree((char *) (objPtr))
  2356      
  2357 #  define TclDbNewObj(objPtr, file, line) \
  2358        (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
  2359        (objPtr)->refCount = 0; \
  2360        (objPtr)->bytes    = tclEmptyStringRep; \
  2361        (objPtr)->length   = 0; \
  2362        (objPtr)->typePtr  = NULL; \
  2363        TclIncrObjsAllocated()
  2364      
  2365 #elif defined(PURIFY)
  2366 
  2367 /*
  2368  * The PURIFY mode is like the regular mode, but instead of doing block
  2369  * Tcl_Obj allocation and keeping a freed list for efficiency, it always
  2370  * allocates and frees a single Tcl_Obj so that tools like Purify can
  2371  * better track memory leaks
  2372  */
  2373 
  2374 #  define TclAllocObjStorage(objPtr) \
  2375        (objPtr) = (Tcl_Obj *) Tcl_Ckalloc(sizeof(Tcl_Obj))
  2376 
  2377 #  define TclFreeObjStorage(objPtr) \
  2378        ckfree((char *) (objPtr))
  2379 
  2380 #elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
  2381 
  2382 /*
  2383  * The TCL_THREADS mode is like the regular mode but allocates Tcl_Obj's
  2384  * from per-thread caches.
  2385  */
  2386 
  2387 EXTERN Tcl_Obj *TclThreadAllocObj _ANSI_ARGS_((void));
  2388 EXTERN void TclThreadFreeObj _ANSI_ARGS_((Tcl_Obj *));
  2389 EXTERN void TclFreeAllocCache _ANSI_ARGS_((void *));
  2390 EXTERN void TclpFreeAllocMutex _ANSI_ARGS_((Tcl_Mutex* mutex));
  2391 EXTERN void TclpFreeAllocCache _ANSI_ARGS_((void *));
  2392 
  2393 
  2394 #  define TclAllocObjStorage(objPtr) \
  2395        (objPtr) = TclThreadAllocObj()
  2396 
  2397 #  define TclFreeObjStorage(objPtr) \
  2398        TclThreadFreeObj((objPtr))
  2399 
  2400 #else /* not TCL_MEM_DEBUG */
  2401 
  2402 #ifdef TCL_THREADS
  2403 /* declared in tclObj.c */
  2404 extern Tcl_Mutex tclObjMutex;
  2405 #endif
  2406 
  2407 #  define TclAllocObjStorage(objPtr) \
  2408        Tcl_MutexLock(&tclObjMutex); \
  2409        if (tclFreeObjList == NULL) { \
  2410 	   TclAllocateFreeObjects(); \
  2411        } \
  2412        (objPtr) = tclFreeObjList; \
  2413        tclFreeObjList = (Tcl_Obj *) \
  2414 	   tclFreeObjList->internalRep.otherValuePtr; \
  2415        Tcl_MutexUnlock(&tclObjMutex)
  2416 
  2417 #  define TclFreeObjStorage(objPtr) \
  2418        Tcl_MutexLock(&tclObjMutex); \
  2419        (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
  2420        tclFreeObjList = (objPtr); \
  2421        Tcl_MutexUnlock(&tclObjMutex)
  2422 
  2423 #endif /* TCL_MEM_DEBUG */
  2424 
  2425 /*
  2426  *----------------------------------------------------------------
  2427  * Macro used by the Tcl core to set a Tcl_Obj's string representation
  2428  * to a copy of the "len" bytes starting at "bytePtr". This code
  2429  * works even if the byte array contains NULLs as long as the length
  2430  * is correct. Because "len" is referenced multiple times, it should
  2431  * be as simple an expression as possible. The ANSI C "prototype" for
  2432  * this macro is:
  2433  *
  2434  * EXTERN void	TclInitStringRep _ANSI_ARGS_((Tcl_Obj *objPtr,
  2435  *		    char *bytePtr, int len));
  2436  *----------------------------------------------------------------
  2437  */
  2438 
  2439 #define TclInitStringRep(objPtr, bytePtr, len) \
  2440     if ((len) == 0) { \
  2441 	(objPtr)->bytes	 = tclEmptyStringRep; \
  2442 	(objPtr)->length = 0; \
  2443     } else { \
  2444 	(objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \
  2445 	memcpy((VOID *) (objPtr)->bytes, (VOID *) (bytePtr), \
  2446 		(unsigned) (len)); \
  2447 	(objPtr)->bytes[len] = '\0'; \
  2448 	(objPtr)->length = (len); \
  2449     }
  2450 
  2451 /*
  2452  *----------------------------------------------------------------
  2453  * Macro used by the Tcl core to get the string representation's
  2454  * byte array pointer from a Tcl_Obj. This is an inline version
  2455  * of Tcl_GetString(). The macro's expression result is the string
  2456  * rep's byte pointer which might be NULL. The bytes referenced by 
  2457  * this pointer must not be modified by the caller.
  2458  * The ANSI C "prototype" for this macro is:
  2459  *
  2460  * EXTERN char *  TclGetString _ANSI_ARGS_((Tcl_Obj *objPtr));
  2461  *----------------------------------------------------------------
  2462  */
  2463 
  2464 #define TclGetString(objPtr) \
  2465     ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr)))
  2466 
  2467 /*
  2468  *----------------------------------------------------------------
  2469  * Macro used by the Tcl core to get a Tcl_WideInt value out of
  2470  * a Tcl_Obj of the "wideInt" type.  Different implementation on
  2471  * different platforms depending whether TCL_WIDE_INT_IS_LONG.
  2472  *----------------------------------------------------------------
  2473  */
  2474 
  2475 #ifdef TCL_WIDE_INT_IS_LONG
  2476 #    define TclGetWide(resultVar, objPtr) \
  2477 	(resultVar) = (objPtr)->internalRep.longValue
  2478 #    define TclGetLongFromWide(resultVar, objPtr) \
  2479 	(resultVar) = (objPtr)->internalRep.longValue
  2480 #else
  2481 #    define TclGetWide(resultVar, objPtr) \
  2482 	(resultVar) = (objPtr)->internalRep.wideValue
  2483 #    define TclGetLongFromWide(resultVar, objPtr) \
  2484 	(resultVar) = Tcl_WideAsLong((objPtr)->internalRep.wideValue)
  2485 #endif
  2486 
  2487 /*
  2488  *----------------------------------------------------------------
  2489  * Macro used by the Tcl core get a unicode char from a utf string.
  2490  * It checks to see if we have a one-byte utf char before calling
  2491  * the real Tcl_UtfToUniChar, as this will save a lot of time for
  2492  * primarily ascii string handling. The macro's expression result
  2493  * is 1 for the 1-byte case or the result of Tcl_UtfToUniChar.
  2494  * The ANSI C "prototype" for this macro is:
  2495  *
  2496  * EXTERN int TclUtfToUniChar _ANSI_ARGS_((CONST char *string,
  2497  *					   Tcl_UniChar *ch));
  2498  *----------------------------------------------------------------
  2499  */
  2500 
  2501 #define TclUtfToUniChar(str, chPtr) \
  2502 	((((unsigned char) *(str)) < 0xC0) ? \
  2503 	    ((*(chPtr) = (Tcl_UniChar) *(str)), 1) \
  2504 	    : Tcl_UtfToUniChar(str, chPtr))
  2505 
  2506 /*
  2507  *----------------------------------------------------------------
  2508  * Macro used by the Tcl core to compare Unicode strings.  On
  2509  * big-endian systems we can use the more efficient memcmp, but
  2510  * this would not be lexically correct on little-endian systems.
  2511  * The ANSI C "prototype" for this macro is:
  2512  *
  2513  * EXTERN int TclUniCharNcmp _ANSI_ARGS_((CONST Tcl_UniChar *cs,
  2514  *         CONST Tcl_UniChar *ct, unsigned long n));
  2515  *----------------------------------------------------------------
  2516  */
  2517 #ifdef WORDS_BIGENDIAN
  2518 #   define TclUniCharNcmp(cs,ct,n) memcmp((cs),(ct),(n)*sizeof(Tcl_UniChar))
  2519 #else /* !WORDS_BIGENDIAN */
  2520 #   define TclUniCharNcmp Tcl_UniCharNcmp
  2521 #endif /* WORDS_BIGENDIAN */
  2522 
  2523 #ifdef __SYMBIAN32__  
  2524 /*
  2525  * Struct to keep records of synchronization objects (used in tclThread.c)
  2526  */
  2527 typedef struct SyncObjRecord {
  2528 	int num;		/* Number of objects remembered */
  2529 	int max;		/* Max size of the array */
  2530 	char **list;	/* List of pointers */
  2531 } SyncObjRecord;
  2532 #endif
  2533 
  2534 #include "tclIntDecls.h"
  2535 
  2536 # undef TCL_STORAGE_CLASS
  2537 # define TCL_STORAGE_CLASS DLLIMPORT
  2538 
  2539 #endif /* _TCLINT */
  2540