annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tclInt.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * tclInt.h --
jpayne@69 3 *
jpayne@69 4 * Declarations of things used internally by the Tcl interpreter.
jpayne@69 5 *
jpayne@69 6 * Copyright (c) 1987-1993 The Regents of the University of California.
jpayne@69 7 * Copyright (c) 1993-1997 Lucent Technologies.
jpayne@69 8 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
jpayne@69 9 * Copyright (c) 1998-1999 by Scriptics Corporation.
jpayne@69 10 * Copyright (c) 2001, 2002 by Kevin B. Kenny. All rights reserved.
jpayne@69 11 * Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
jpayne@69 12 * Copyright (c) 2006-2008 by Joe Mistachkin. All rights reserved.
jpayne@69 13 * Copyright (c) 2008 by Miguel Sofer. All rights reserved.
jpayne@69 14 *
jpayne@69 15 * See the file "license.terms" for information on usage and redistribution of
jpayne@69 16 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
jpayne@69 17 */
jpayne@69 18
jpayne@69 19 #ifndef _TCLINT
jpayne@69 20 #define _TCLINT
jpayne@69 21
jpayne@69 22 /*
jpayne@69 23 * Some numerics configuration options.
jpayne@69 24 */
jpayne@69 25
jpayne@69 26 #undef ACCEPT_NAN
jpayne@69 27
jpayne@69 28 /*
jpayne@69 29 * Common include files needed by most of the Tcl source files are included
jpayne@69 30 * here, so that system-dependent personalizations for the include files only
jpayne@69 31 * have to be made in once place. This results in a few extra includes, but
jpayne@69 32 * greater modularity. The order of the three groups of #includes is
jpayne@69 33 * important. For example, stdio.h is needed by tcl.h.
jpayne@69 34 */
jpayne@69 35
jpayne@69 36 #include "tclPort.h"
jpayne@69 37
jpayne@69 38 #include <stdio.h>
jpayne@69 39
jpayne@69 40 #include <ctype.h>
jpayne@69 41 #ifdef NO_STDLIB_H
jpayne@69 42 # include "../compat/stdlib.h"
jpayne@69 43 #else
jpayne@69 44 # include <stdlib.h>
jpayne@69 45 #endif
jpayne@69 46 #ifdef NO_STRING_H
jpayne@69 47 #include "../compat/string.h"
jpayne@69 48 #else
jpayne@69 49 #include <string.h>
jpayne@69 50 #endif
jpayne@69 51 #if defined(STDC_HEADERS) || defined(__STDC__) || defined(__C99__FUNC__) \
jpayne@69 52 || defined(__cplusplus) || defined(_MSC_VER) || defined(__ICC)
jpayne@69 53 #include <stddef.h>
jpayne@69 54 #else
jpayne@69 55 typedef int ptrdiff_t;
jpayne@69 56 #endif
jpayne@69 57
jpayne@69 58 /*
jpayne@69 59 * Ensure WORDS_BIGENDIAN is defined correctly:
jpayne@69 60 * Needs to happen here in addition to configure to work with fat compiles on
jpayne@69 61 * Darwin (where configure runs only once for multiple architectures).
jpayne@69 62 */
jpayne@69 63
jpayne@69 64 #ifdef HAVE_SYS_TYPES_H
jpayne@69 65 # include <sys/types.h>
jpayne@69 66 #endif
jpayne@69 67 #ifdef HAVE_SYS_PARAM_H
jpayne@69 68 # include <sys/param.h>
jpayne@69 69 #endif
jpayne@69 70 #ifdef BYTE_ORDER
jpayne@69 71 # ifdef BIG_ENDIAN
jpayne@69 72 # if BYTE_ORDER == BIG_ENDIAN
jpayne@69 73 # undef WORDS_BIGENDIAN
jpayne@69 74 # define WORDS_BIGENDIAN 1
jpayne@69 75 # endif
jpayne@69 76 # endif
jpayne@69 77 # ifdef LITTLE_ENDIAN
jpayne@69 78 # if BYTE_ORDER == LITTLE_ENDIAN
jpayne@69 79 # undef WORDS_BIGENDIAN
jpayne@69 80 # endif
jpayne@69 81 # endif
jpayne@69 82 #endif
jpayne@69 83
jpayne@69 84 /*
jpayne@69 85 * Used to tag functions that are only to be visible within the module being
jpayne@69 86 * built and not outside it (where this is supported by the linker).
jpayne@69 87 */
jpayne@69 88
jpayne@69 89 #ifndef MODULE_SCOPE
jpayne@69 90 # ifdef __cplusplus
jpayne@69 91 # define MODULE_SCOPE extern "C"
jpayne@69 92 # else
jpayne@69 93 # define MODULE_SCOPE extern
jpayne@69 94 # endif
jpayne@69 95 #endif
jpayne@69 96
jpayne@69 97 /*
jpayne@69 98 * Macros used to cast between pointers and integers (e.g. when storing an int
jpayne@69 99 * in ClientData), on 64-bit architectures they avoid gcc warning about "cast
jpayne@69 100 * to/from pointer from/to integer of different size".
jpayne@69 101 */
jpayne@69 102
jpayne@69 103 #if !defined(INT2PTR) && !defined(PTR2INT)
jpayne@69 104 # if defined(HAVE_INTPTR_T) || defined(intptr_t)
jpayne@69 105 # define INT2PTR(p) ((void *)(intptr_t)(p))
jpayne@69 106 # define PTR2INT(p) ((int)(intptr_t)(p))
jpayne@69 107 # else
jpayne@69 108 # define INT2PTR(p) ((void *)(p))
jpayne@69 109 # define PTR2INT(p) ((int)(p))
jpayne@69 110 # endif
jpayne@69 111 #endif
jpayne@69 112 #if !defined(UINT2PTR) && !defined(PTR2UINT)
jpayne@69 113 # if defined(HAVE_UINTPTR_T) || defined(uintptr_t)
jpayne@69 114 # define UINT2PTR(p) ((void *)(uintptr_t)(p))
jpayne@69 115 # define PTR2UINT(p) ((unsigned int)(uintptr_t)(p))
jpayne@69 116 # else
jpayne@69 117 # define UINT2PTR(p) ((void *)(p))
jpayne@69 118 # define PTR2UINT(p) ((unsigned int)(p))
jpayne@69 119 # endif
jpayne@69 120 #endif
jpayne@69 121
jpayne@69 122 #if defined(_WIN32) && defined(_MSC_VER)
jpayne@69 123 # define vsnprintf _vsnprintf
jpayne@69 124 #endif
jpayne@69 125
jpayne@69 126 /*
jpayne@69 127 * The following procedures allow namespaces to be customized to support
jpayne@69 128 * special name resolution rules for commands/variables.
jpayne@69 129 */
jpayne@69 130
jpayne@69 131 struct Tcl_ResolvedVarInfo;
jpayne@69 132
jpayne@69 133 typedef Tcl_Var (Tcl_ResolveRuntimeVarProc)(Tcl_Interp *interp,
jpayne@69 134 struct Tcl_ResolvedVarInfo *vinfoPtr);
jpayne@69 135
jpayne@69 136 typedef void (Tcl_ResolveVarDeleteProc)(struct Tcl_ResolvedVarInfo *vinfoPtr);
jpayne@69 137
jpayne@69 138 /*
jpayne@69 139 * The following structure encapsulates the routines needed to resolve a
jpayne@69 140 * variable reference at runtime. Any variable specific state will typically
jpayne@69 141 * be appended to this structure.
jpayne@69 142 */
jpayne@69 143
jpayne@69 144 typedef struct Tcl_ResolvedVarInfo {
jpayne@69 145 Tcl_ResolveRuntimeVarProc *fetchProc;
jpayne@69 146 Tcl_ResolveVarDeleteProc *deleteProc;
jpayne@69 147 } Tcl_ResolvedVarInfo;
jpayne@69 148
jpayne@69 149 typedef int (Tcl_ResolveCompiledVarProc)(Tcl_Interp *interp,
jpayne@69 150 CONST84 char *name, int length, Tcl_Namespace *context,
jpayne@69 151 Tcl_ResolvedVarInfo **rPtr);
jpayne@69 152
jpayne@69 153 typedef int (Tcl_ResolveVarProc)(Tcl_Interp *interp, CONST84 char *name,
jpayne@69 154 Tcl_Namespace *context, int flags, Tcl_Var *rPtr);
jpayne@69 155
jpayne@69 156 typedef int (Tcl_ResolveCmdProc)(Tcl_Interp *interp, CONST84 char *name,
jpayne@69 157 Tcl_Namespace *context, int flags, Tcl_Command *rPtr);
jpayne@69 158
jpayne@69 159 typedef struct Tcl_ResolverInfo {
jpayne@69 160 Tcl_ResolveCmdProc *cmdResProc;
jpayne@69 161 /* Procedure handling command name
jpayne@69 162 * resolution. */
jpayne@69 163 Tcl_ResolveVarProc *varResProc;
jpayne@69 164 /* Procedure handling variable name resolution
jpayne@69 165 * for variables that can only be handled at
jpayne@69 166 * runtime. */
jpayne@69 167 Tcl_ResolveCompiledVarProc *compiledVarResProc;
jpayne@69 168 /* Procedure handling variable name resolution
jpayne@69 169 * at compile time. */
jpayne@69 170 } Tcl_ResolverInfo;
jpayne@69 171
jpayne@69 172 /*
jpayne@69 173 * This flag bit should not interfere with TCL_GLOBAL_ONLY,
jpayne@69 174 * TCL_NAMESPACE_ONLY, or TCL_LEAVE_ERR_MSG; it signals that the variable
jpayne@69 175 * lookup is performed for upvar (or similar) purposes, with slightly
jpayne@69 176 * different rules:
jpayne@69 177 * - Bug #696893 - variable is either proc-local or in the current
jpayne@69 178 * namespace; never follow the second (global) resolution path
jpayne@69 179 * - Bug #631741 - do not use special namespace or interp resolvers
jpayne@69 180 *
jpayne@69 181 * It should also not collide with the (deprecated) TCL_PARSE_PART1 flag
jpayne@69 182 * (Bug #835020)
jpayne@69 183 */
jpayne@69 184
jpayne@69 185 #define TCL_AVOID_RESOLVERS 0x40000
jpayne@69 186
jpayne@69 187 /*
jpayne@69 188 *----------------------------------------------------------------
jpayne@69 189 * Data structures related to namespaces.
jpayne@69 190 *----------------------------------------------------------------
jpayne@69 191 */
jpayne@69 192
jpayne@69 193 typedef struct Tcl_Ensemble Tcl_Ensemble;
jpayne@69 194 typedef struct NamespacePathEntry NamespacePathEntry;
jpayne@69 195
jpayne@69 196 /*
jpayne@69 197 * Special hashtable for variables: this is just a Tcl_HashTable with an nsPtr
jpayne@69 198 * field added at the end: in this way variables can find their namespace
jpayne@69 199 * without having to copy a pointer in their struct: they can access it via
jpayne@69 200 * their hPtr->tablePtr.
jpayne@69 201 */
jpayne@69 202
jpayne@69 203 typedef struct TclVarHashTable {
jpayne@69 204 Tcl_HashTable table;
jpayne@69 205 struct Namespace *nsPtr;
jpayne@69 206 } TclVarHashTable;
jpayne@69 207
jpayne@69 208 /*
jpayne@69 209 * This is for itcl - it likes to search our varTables directly :(
jpayne@69 210 */
jpayne@69 211
jpayne@69 212 #define TclVarHashFindVar(tablePtr, key) \
jpayne@69 213 TclVarHashCreateVar((tablePtr), (key), NULL)
jpayne@69 214
jpayne@69 215 /*
jpayne@69 216 * Define this to reduce the amount of space that the average namespace
jpayne@69 217 * consumes by only allocating the table of child namespaces when necessary.
jpayne@69 218 * Defining it breaks compatibility for Tcl extensions (e.g., itcl) which
jpayne@69 219 * reach directly into the Namespace structure.
jpayne@69 220 */
jpayne@69 221
jpayne@69 222 #undef BREAK_NAMESPACE_COMPAT
jpayne@69 223
jpayne@69 224 /*
jpayne@69 225 * The structure below defines a namespace.
jpayne@69 226 * Note: the first five fields must match exactly the fields in a
jpayne@69 227 * Tcl_Namespace structure (see tcl.h). If you change one, be sure to change
jpayne@69 228 * the other.
jpayne@69 229 */
jpayne@69 230
jpayne@69 231 typedef struct Namespace {
jpayne@69 232 char *name; /* The namespace's simple (unqualified) name.
jpayne@69 233 * This contains no ::'s. The name of the
jpayne@69 234 * global namespace is "" although "::" is an
jpayne@69 235 * synonym. */
jpayne@69 236 char *fullName; /* The namespace's fully qualified name. This
jpayne@69 237 * starts with ::. */
jpayne@69 238 ClientData clientData; /* An arbitrary value associated with this
jpayne@69 239 * namespace. */
jpayne@69 240 Tcl_NamespaceDeleteProc *deleteProc;
jpayne@69 241 /* Procedure invoked when deleting the
jpayne@69 242 * namespace to, e.g., free clientData. */
jpayne@69 243 struct Namespace *parentPtr;/* Points to the namespace that contains this
jpayne@69 244 * one. NULL if this is the global
jpayne@69 245 * namespace. */
jpayne@69 246 #ifndef BREAK_NAMESPACE_COMPAT
jpayne@69 247 Tcl_HashTable childTable; /* Contains any child namespaces. Indexed by
jpayne@69 248 * strings; values have type (Namespace *). */
jpayne@69 249 #else
jpayne@69 250 Tcl_HashTable *childTablePtr;
jpayne@69 251 /* Contains any child namespaces. Indexed by
jpayne@69 252 * strings; values have type (Namespace *). If
jpayne@69 253 * NULL, there are no children. */
jpayne@69 254 #endif
jpayne@69 255 long nsId; /* Unique id for the namespace. */
jpayne@69 256 Tcl_Interp *interp; /* The interpreter containing this
jpayne@69 257 * namespace. */
jpayne@69 258 int flags; /* OR-ed combination of the namespace status
jpayne@69 259 * flags NS_DYING and NS_DEAD listed below. */
jpayne@69 260 int activationCount; /* Number of "activations" or active call
jpayne@69 261 * frames for this namespace that are on the
jpayne@69 262 * Tcl call stack. The namespace won't be
jpayne@69 263 * freed until activationCount becomes zero. */
jpayne@69 264 int refCount; /* Count of references by namespaceName
jpayne@69 265 * objects. The namespace can't be freed until
jpayne@69 266 * refCount becomes zero. */
jpayne@69 267 Tcl_HashTable cmdTable; /* Contains all the commands currently
jpayne@69 268 * registered in the namespace. Indexed by
jpayne@69 269 * strings; values have type (Command *).
jpayne@69 270 * Commands imported by Tcl_Import have
jpayne@69 271 * Command structures that point (via an
jpayne@69 272 * ImportedCmdRef structure) to the Command
jpayne@69 273 * structure in the source namespace's command
jpayne@69 274 * table. */
jpayne@69 275 TclVarHashTable varTable; /* Contains all the (global) variables
jpayne@69 276 * currently in this namespace. Indexed by
jpayne@69 277 * strings; values have type (Var *). */
jpayne@69 278 char **exportArrayPtr; /* Points to an array of string patterns
jpayne@69 279 * specifying which commands are exported. A
jpayne@69 280 * pattern may include "string match" style
jpayne@69 281 * wildcard characters to specify multiple
jpayne@69 282 * commands; however, no namespace qualifiers
jpayne@69 283 * are allowed. NULL if no export patterns are
jpayne@69 284 * registered. */
jpayne@69 285 int numExportPatterns; /* Number of export patterns currently
jpayne@69 286 * registered using "namespace export". */
jpayne@69 287 int maxExportPatterns; /* Mumber of export patterns for which space
jpayne@69 288 * is currently allocated. */
jpayne@69 289 int cmdRefEpoch; /* Incremented if a newly added command
jpayne@69 290 * shadows a command for which this namespace
jpayne@69 291 * has already cached a Command* pointer; this
jpayne@69 292 * causes all its cached Command* pointers to
jpayne@69 293 * be invalidated. */
jpayne@69 294 int resolverEpoch; /* Incremented whenever (a) the name
jpayne@69 295 * resolution rules change for this namespace
jpayne@69 296 * or (b) a newly added command shadows a
jpayne@69 297 * command that is compiled to bytecodes. This
jpayne@69 298 * invalidates all byte codes compiled in the
jpayne@69 299 * namespace, causing the code to be
jpayne@69 300 * recompiled under the new rules.*/
jpayne@69 301 Tcl_ResolveCmdProc *cmdResProc;
jpayne@69 302 /* If non-null, this procedure overrides the
jpayne@69 303 * usual command resolution mechanism in Tcl.
jpayne@69 304 * This procedure is invoked within
jpayne@69 305 * Tcl_FindCommand to resolve all command
jpayne@69 306 * references within the namespace. */
jpayne@69 307 Tcl_ResolveVarProc *varResProc;
jpayne@69 308 /* If non-null, this procedure overrides the
jpayne@69 309 * usual variable resolution mechanism in Tcl.
jpayne@69 310 * This procedure is invoked within
jpayne@69 311 * Tcl_FindNamespaceVar to resolve all
jpayne@69 312 * variable references within the namespace at
jpayne@69 313 * runtime. */
jpayne@69 314 Tcl_ResolveCompiledVarProc *compiledVarResProc;
jpayne@69 315 /* If non-null, this procedure overrides the
jpayne@69 316 * usual variable resolution mechanism in Tcl.
jpayne@69 317 * This procedure is invoked within
jpayne@69 318 * LookupCompiledLocal to resolve variable
jpayne@69 319 * references within the namespace at compile
jpayne@69 320 * time. */
jpayne@69 321 int exportLookupEpoch; /* Incremented whenever a command is added to
jpayne@69 322 * a namespace, removed from a namespace or
jpayne@69 323 * the exports of a namespace are changed.
jpayne@69 324 * Allows TIP#112-driven command lists to be
jpayne@69 325 * validated efficiently. */
jpayne@69 326 Tcl_Ensemble *ensembles; /* List of structures that contain the details
jpayne@69 327 * of the ensembles that are implemented on
jpayne@69 328 * top of this namespace. */
jpayne@69 329 Tcl_Obj *unknownHandlerPtr; /* A script fragment to be used when command
jpayne@69 330 * resolution in this namespace fails. TIP
jpayne@69 331 * 181. */
jpayne@69 332 int commandPathLength; /* The length of the explicit path. */
jpayne@69 333 NamespacePathEntry *commandPathArray;
jpayne@69 334 /* The explicit path of the namespace as an
jpayne@69 335 * array. */
jpayne@69 336 NamespacePathEntry *commandPathSourceList;
jpayne@69 337 /* Linked list of path entries that point to
jpayne@69 338 * this namespace. */
jpayne@69 339 Tcl_NamespaceDeleteProc *earlyDeleteProc;
jpayne@69 340 /* Just like the deleteProc field (and called
jpayne@69 341 * with the same clientData) but called at the
jpayne@69 342 * start of the deletion process, so there is
jpayne@69 343 * a chance for code to do stuff inside the
jpayne@69 344 * namespace before deletion completes. */
jpayne@69 345 } Namespace;
jpayne@69 346
jpayne@69 347 /*
jpayne@69 348 * An entry on a namespace's command resolution path.
jpayne@69 349 */
jpayne@69 350
jpayne@69 351 struct NamespacePathEntry {
jpayne@69 352 Namespace *nsPtr; /* What does this path entry point to? If it
jpayne@69 353 * is NULL, this path entry points is
jpayne@69 354 * redundant and should be skipped. */
jpayne@69 355 Namespace *creatorNsPtr; /* Where does this path entry point from? This
jpayne@69 356 * allows for efficient invalidation of
jpayne@69 357 * references when the path entry's target
jpayne@69 358 * updates its current list of defined
jpayne@69 359 * commands. */
jpayne@69 360 NamespacePathEntry *prevPtr, *nextPtr;
jpayne@69 361 /* Linked list pointers or NULL at either end
jpayne@69 362 * of the list that hangs off Namespace's
jpayne@69 363 * commandPathSourceList field. */
jpayne@69 364 };
jpayne@69 365
jpayne@69 366 /*
jpayne@69 367 * Flags used to represent the status of a namespace:
jpayne@69 368 *
jpayne@69 369 * NS_DYING - 1 means Tcl_DeleteNamespace has been called to delete the
jpayne@69 370 * namespace but there are still active call frames on the Tcl
jpayne@69 371 * stack that refer to the namespace. When the last call frame
jpayne@69 372 * referring to it has been popped, it's variables and command
jpayne@69 373 * will be destroyed and it will be marked "dead" (NS_DEAD). The
jpayne@69 374 * namespace can no longer be looked up by name.
jpayne@69 375 * NS_DEAD - 1 means Tcl_DeleteNamespace has been called to delete the
jpayne@69 376 * namespace and no call frames still refer to it. Its variables
jpayne@69 377 * and command have already been destroyed. This bit allows the
jpayne@69 378 * namespace resolution code to recognize that the namespace is
jpayne@69 379 * "deleted". When the last namespaceName object in any byte code
jpayne@69 380 * unit that refers to the namespace has been freed (i.e., when
jpayne@69 381 * the namespace's refCount is 0), the namespace's storage will
jpayne@69 382 * be freed.
jpayne@69 383 * NS_KILLED - 1 means that TclTeardownNamespace has already been called on
jpayne@69 384 * this namespace and it should not be called again [Bug 1355942]
jpayne@69 385 * NS_SUPPRESS_COMPILATION -
jpayne@69 386 * Marks the commands in this namespace for not being compiled,
jpayne@69 387 * forcing them to be looked up every time.
jpayne@69 388 */
jpayne@69 389
jpayne@69 390 #define NS_DYING 0x01
jpayne@69 391 #define NS_DEAD 0x02
jpayne@69 392 #define NS_KILLED 0x04
jpayne@69 393 #define NS_SUPPRESS_COMPILATION 0x08
jpayne@69 394
jpayne@69 395 /*
jpayne@69 396 * Flags passed to TclGetNamespaceForQualName:
jpayne@69 397 *
jpayne@69 398 * TCL_GLOBAL_ONLY - (see tcl.h) Look only in the global ns.
jpayne@69 399 * TCL_NAMESPACE_ONLY - (see tcl.h) Look only in the context ns.
jpayne@69 400 * TCL_CREATE_NS_IF_UNKNOWN - Create unknown namespaces.
jpayne@69 401 * TCL_FIND_ONLY_NS - The name sought is a namespace name.
jpayne@69 402 */
jpayne@69 403
jpayne@69 404 #define TCL_CREATE_NS_IF_UNKNOWN 0x800
jpayne@69 405 #define TCL_FIND_ONLY_NS 0x1000
jpayne@69 406
jpayne@69 407 /*
jpayne@69 408 * The client data for an ensemble command. This consists of the table of
jpayne@69 409 * commands that are actually exported by the namespace, and an epoch counter
jpayne@69 410 * that, combined with the exportLookupEpoch field of the namespace structure,
jpayne@69 411 * defines whether the table contains valid data or will need to be recomputed
jpayne@69 412 * next time the ensemble command is called.
jpayne@69 413 */
jpayne@69 414
jpayne@69 415 typedef struct EnsembleConfig {
jpayne@69 416 Namespace *nsPtr; /* The namespace backing this ensemble up. */
jpayne@69 417 Tcl_Command token; /* The token for the command that provides
jpayne@69 418 * ensemble support for the namespace, or NULL
jpayne@69 419 * if the command has been deleted (or never
jpayne@69 420 * existed; the global namespace never has an
jpayne@69 421 * ensemble command.) */
jpayne@69 422 int epoch; /* The epoch at which this ensemble's table of
jpayne@69 423 * exported commands is valid. */
jpayne@69 424 char **subcommandArrayPtr; /* Array of ensemble subcommand names. At all
jpayne@69 425 * consistent points, this will have the same
jpayne@69 426 * number of entries as there are entries in
jpayne@69 427 * the subcommandTable hash. */
jpayne@69 428 Tcl_HashTable subcommandTable;
jpayne@69 429 /* Hash table of ensemble subcommand names,
jpayne@69 430 * which are its keys so this also provides
jpayne@69 431 * the storage management for those subcommand
jpayne@69 432 * names. The contents of the entry values are
jpayne@69 433 * object version the prefix lists to use when
jpayne@69 434 * substituting for the command/subcommand to
jpayne@69 435 * build the ensemble implementation command.
jpayne@69 436 * Has to be stored here as well as in
jpayne@69 437 * subcommandDict because that field is NULL
jpayne@69 438 * when we are deriving the ensemble from the
jpayne@69 439 * namespace exports list. FUTURE WORK: use
jpayne@69 440 * object hash table here. */
jpayne@69 441 struct EnsembleConfig *next;/* The next ensemble in the linked list of
jpayne@69 442 * ensembles associated with a namespace. If
jpayne@69 443 * this field points to this ensemble, the
jpayne@69 444 * structure has already been unlinked from
jpayne@69 445 * all lists, and cannot be found by scanning
jpayne@69 446 * the list from the namespace's ensemble
jpayne@69 447 * field. */
jpayne@69 448 int flags; /* ORed combo of TCL_ENSEMBLE_PREFIX,
jpayne@69 449 * ENSEMBLE_DEAD and ENSEMBLE_COMPILE. */
jpayne@69 450
jpayne@69 451 /* OBJECT FIELDS FOR ENSEMBLE CONFIGURATION */
jpayne@69 452
jpayne@69 453 Tcl_Obj *subcommandDict; /* Dictionary providing mapping from
jpayne@69 454 * subcommands to their implementing command
jpayne@69 455 * prefixes, or NULL if we are to build the
jpayne@69 456 * map automatically from the namespace
jpayne@69 457 * exports. */
jpayne@69 458 Tcl_Obj *subcmdList; /* List of commands that this ensemble
jpayne@69 459 * actually provides, and whose implementation
jpayne@69 460 * will be built using the subcommandDict (if
jpayne@69 461 * present and defined) and by simple mapping
jpayne@69 462 * to the namespace otherwise. If NULL,
jpayne@69 463 * indicates that we are using the (dynamic)
jpayne@69 464 * list of currently exported commands. */
jpayne@69 465 Tcl_Obj *unknownHandler; /* Script prefix used to handle the case when
jpayne@69 466 * no match is found (according to the rule
jpayne@69 467 * defined by flag bit TCL_ENSEMBLE_PREFIX) or
jpayne@69 468 * NULL to use the default error-generating
jpayne@69 469 * behaviour. The script execution gets all
jpayne@69 470 * the arguments to the ensemble command
jpayne@69 471 * (including objv[0]) and will have the
jpayne@69 472 * results passed directly back to the caller
jpayne@69 473 * (including the error code) unless the code
jpayne@69 474 * is TCL_CONTINUE in which case the
jpayne@69 475 * subcommand will be reparsed by the ensemble
jpayne@69 476 * core, presumably because the ensemble
jpayne@69 477 * itself has been updated. */
jpayne@69 478 Tcl_Obj *parameterList; /* List of ensemble parameter names. */
jpayne@69 479 int numParameters; /* Cached number of parameters. This is either
jpayne@69 480 * 0 (if the parameterList field is NULL) or
jpayne@69 481 * the length of the list in the parameterList
jpayne@69 482 * field. */
jpayne@69 483 } EnsembleConfig;
jpayne@69 484
jpayne@69 485 /*
jpayne@69 486 * Various bits for the EnsembleConfig.flags field.
jpayne@69 487 */
jpayne@69 488
jpayne@69 489 #define ENSEMBLE_DEAD 0x1 /* Flag value to say that the ensemble is dead
jpayne@69 490 * and on its way out. */
jpayne@69 491 #define ENSEMBLE_COMPILE 0x4 /* Flag to enable bytecode compilation of an
jpayne@69 492 * ensemble. */
jpayne@69 493
jpayne@69 494 /*
jpayne@69 495 *----------------------------------------------------------------
jpayne@69 496 * Data structures related to variables. These are used primarily in tclVar.c
jpayne@69 497 *----------------------------------------------------------------
jpayne@69 498 */
jpayne@69 499
jpayne@69 500 /*
jpayne@69 501 * The following structure defines a variable trace, which is used to invoke a
jpayne@69 502 * specific C procedure whenever certain operations are performed on a
jpayne@69 503 * variable.
jpayne@69 504 */
jpayne@69 505
jpayne@69 506 typedef struct VarTrace {
jpayne@69 507 Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given by
jpayne@69 508 * flags are performed on variable. */
jpayne@69 509 ClientData clientData; /* Argument to pass to proc. */
jpayne@69 510 int flags; /* What events the trace procedure is
jpayne@69 511 * interested in: OR-ed combination of
jpayne@69 512 * TCL_TRACE_READS, TCL_TRACE_WRITES,
jpayne@69 513 * TCL_TRACE_UNSETS and TCL_TRACE_ARRAY. */
jpayne@69 514 struct VarTrace *nextPtr; /* Next in list of traces associated with a
jpayne@69 515 * particular variable. */
jpayne@69 516 } VarTrace;
jpayne@69 517
jpayne@69 518 /*
jpayne@69 519 * The following structure defines a command trace, which is used to invoke a
jpayne@69 520 * specific C procedure whenever certain operations are performed on a
jpayne@69 521 * command.
jpayne@69 522 */
jpayne@69 523
jpayne@69 524 typedef struct CommandTrace {
jpayne@69 525 Tcl_CommandTraceProc *traceProc;
jpayne@69 526 /* Procedure to call when operations given by
jpayne@69 527 * flags are performed on command. */
jpayne@69 528 ClientData clientData; /* Argument to pass to proc. */
jpayne@69 529 int flags; /* What events the trace procedure is
jpayne@69 530 * interested in: OR-ed combination of
jpayne@69 531 * TCL_TRACE_RENAME, TCL_TRACE_DELETE. */
jpayne@69 532 struct CommandTrace *nextPtr;
jpayne@69 533 /* Next in list of traces associated with a
jpayne@69 534 * particular command. */
jpayne@69 535 int refCount; /* Used to ensure this structure is not
jpayne@69 536 * deleted too early. Keeps track of how many
jpayne@69 537 * pieces of code have a pointer to this
jpayne@69 538 * structure. */
jpayne@69 539 } CommandTrace;
jpayne@69 540
jpayne@69 541 /*
jpayne@69 542 * When a command trace is active (i.e. its associated procedure is executing)
jpayne@69 543 * one of the following structures is linked into a list associated with the
jpayne@69 544 * command's interpreter. The information in the structure is needed in order
jpayne@69 545 * for Tcl to behave reasonably if traces are deleted while traces are active.
jpayne@69 546 */
jpayne@69 547
jpayne@69 548 typedef struct ActiveCommandTrace {
jpayne@69 549 struct Command *cmdPtr; /* Command that's being traced. */
jpayne@69 550 struct ActiveCommandTrace *nextPtr;
jpayne@69 551 /* Next in list of all active command traces
jpayne@69 552 * for the interpreter, or NULL if no more. */
jpayne@69 553 CommandTrace *nextTracePtr; /* Next trace to check after current trace
jpayne@69 554 * procedure returns; if this trace gets
jpayne@69 555 * deleted, must update pointer to avoid using
jpayne@69 556 * free'd memory. */
jpayne@69 557 int reverseScan; /* Boolean set true when traces are scanning
jpayne@69 558 * in reverse order. */
jpayne@69 559 } ActiveCommandTrace;
jpayne@69 560
jpayne@69 561 /*
jpayne@69 562 * When a variable trace is active (i.e. its associated procedure is
jpayne@69 563 * executing) one of the following structures is linked into a list associated
jpayne@69 564 * with the variable's interpreter. The information in the structure is needed
jpayne@69 565 * in order for Tcl to behave reasonably if traces are deleted while traces
jpayne@69 566 * are active.
jpayne@69 567 */
jpayne@69 568
jpayne@69 569 typedef struct ActiveVarTrace {
jpayne@69 570 struct Var *varPtr; /* Variable that's being traced. */
jpayne@69 571 struct ActiveVarTrace *nextPtr;
jpayne@69 572 /* Next in list of all active variable traces
jpayne@69 573 * for the interpreter, or NULL if no more. */
jpayne@69 574 VarTrace *nextTracePtr; /* Next trace to check after current trace
jpayne@69 575 * procedure returns; if this trace gets
jpayne@69 576 * deleted, must update pointer to avoid using
jpayne@69 577 * free'd memory. */
jpayne@69 578 } ActiveVarTrace;
jpayne@69 579
jpayne@69 580 /*
jpayne@69 581 * The structure below defines a variable, which associates a string name with
jpayne@69 582 * a Tcl_Obj value. These structures are kept in procedure call frames (for
jpayne@69 583 * local variables recognized by the compiler) or in the heap (for global
jpayne@69 584 * variables and any variable not known to the compiler). For each Var
jpayne@69 585 * structure in the heap, a hash table entry holds the variable name and a
jpayne@69 586 * pointer to the Var structure.
jpayne@69 587 */
jpayne@69 588
jpayne@69 589 typedef struct Var {
jpayne@69 590 int flags; /* Miscellaneous bits of information about
jpayne@69 591 * variable. See below for definitions. */
jpayne@69 592 union {
jpayne@69 593 Tcl_Obj *objPtr; /* The variable's object value. Used for
jpayne@69 594 * scalar variables and array elements. */
jpayne@69 595 TclVarHashTable *tablePtr;/* For array variables, this points to
jpayne@69 596 * information about the hash table used to
jpayne@69 597 * implement the associative array. Points to
jpayne@69 598 * ckalloc-ed data. */
jpayne@69 599 struct Var *linkPtr; /* If this is a global variable being referred
jpayne@69 600 * to in a procedure, or a variable created by
jpayne@69 601 * "upvar", this field points to the
jpayne@69 602 * referenced variable's Var struct. */
jpayne@69 603 } value;
jpayne@69 604 } Var;
jpayne@69 605
jpayne@69 606 typedef struct VarInHash {
jpayne@69 607 Var var;
jpayne@69 608 int refCount; /* Counts number of active uses of this
jpayne@69 609 * variable: 1 for the entry in the hash
jpayne@69 610 * table, 1 for each additional variable whose
jpayne@69 611 * linkPtr points here, 1 for each nested
jpayne@69 612 * trace active on variable, and 1 if the
jpayne@69 613 * variable is a namespace variable. This
jpayne@69 614 * record can't be deleted until refCount
jpayne@69 615 * becomes 0. */
jpayne@69 616 Tcl_HashEntry entry; /* The hash table entry that refers to this
jpayne@69 617 * variable. This is used to find the name of
jpayne@69 618 * the variable and to delete it from its
jpayne@69 619 * hashtable if it is no longer needed. It
jpayne@69 620 * also holds the variable's name. */
jpayne@69 621 } VarInHash;
jpayne@69 622
jpayne@69 623 /*
jpayne@69 624 * Flag bits for variables. The first two (VAR_ARRAY and VAR_LINK) are
jpayne@69 625 * mutually exclusive and give the "type" of the variable. If none is set,
jpayne@69 626 * this is a scalar variable.
jpayne@69 627 *
jpayne@69 628 * VAR_ARRAY - 1 means this is an array variable rather than
jpayne@69 629 * a scalar variable or link. The "tablePtr"
jpayne@69 630 * field points to the array's hashtable for its
jpayne@69 631 * elements.
jpayne@69 632 * VAR_LINK - 1 means this Var structure contains a pointer
jpayne@69 633 * to another Var structure that either has the
jpayne@69 634 * real value or is itself another VAR_LINK
jpayne@69 635 * pointer. Variables like this come about
jpayne@69 636 * through "upvar" and "global" commands, or
jpayne@69 637 * through references to variables in enclosing
jpayne@69 638 * namespaces.
jpayne@69 639 *
jpayne@69 640 * Flags that indicate the type and status of storage; none is set for
jpayne@69 641 * compiled local variables (Var structs).
jpayne@69 642 *
jpayne@69 643 * VAR_IN_HASHTABLE - 1 means this variable is in a hashtable and
jpayne@69 644 * the Var structure is malloced. 0 if it is a
jpayne@69 645 * local variable that was assigned a slot in a
jpayne@69 646 * procedure frame by the compiler so the Var
jpayne@69 647 * storage is part of the call frame.
jpayne@69 648 * VAR_DEAD_HASH 1 means that this var's entry in the hashtable
jpayne@69 649 * has already been deleted.
jpayne@69 650 * VAR_ARRAY_ELEMENT - 1 means that this variable is an array
jpayne@69 651 * element, so it is not legal for it to be an
jpayne@69 652 * array itself (the VAR_ARRAY flag had better
jpayne@69 653 * not be set).
jpayne@69 654 * VAR_NAMESPACE_VAR - 1 means that this variable was declared as a
jpayne@69 655 * namespace variable. This flag ensures it
jpayne@69 656 * persists until its namespace is destroyed or
jpayne@69 657 * until the variable is unset; it will persist
jpayne@69 658 * even if it has not been initialized and is
jpayne@69 659 * marked undefined. The variable's refCount is
jpayne@69 660 * incremented to reflect the "reference" from
jpayne@69 661 * its namespace.
jpayne@69 662 *
jpayne@69 663 * Flag values relating to the variable's trace and search status.
jpayne@69 664 *
jpayne@69 665 * VAR_TRACED_READ
jpayne@69 666 * VAR_TRACED_WRITE
jpayne@69 667 * VAR_TRACED_UNSET
jpayne@69 668 * VAR_TRACED_ARRAY
jpayne@69 669 * VAR_TRACE_ACTIVE - 1 means that trace processing is currently
jpayne@69 670 * underway for a read or write access, so new
jpayne@69 671 * read or write accesses should not cause trace
jpayne@69 672 * procedures to be called and the variable can't
jpayne@69 673 * be deleted.
jpayne@69 674 * VAR_SEARCH_ACTIVE
jpayne@69 675 *
jpayne@69 676 * The following additional flags are used with the CompiledLocal type defined
jpayne@69 677 * below:
jpayne@69 678 *
jpayne@69 679 * VAR_ARGUMENT - 1 means that this variable holds a procedure
jpayne@69 680 * argument.
jpayne@69 681 * VAR_TEMPORARY - 1 if the local variable is an anonymous
jpayne@69 682 * temporary variable. Temporaries have a NULL
jpayne@69 683 * name.
jpayne@69 684 * VAR_RESOLVED - 1 if name resolution has been done for this
jpayne@69 685 * variable.
jpayne@69 686 * VAR_IS_ARGS 1 if this variable is the last argument and is
jpayne@69 687 * named "args".
jpayne@69 688 */
jpayne@69 689
jpayne@69 690 /*
jpayne@69 691 * FLAGS RENUMBERED: everything breaks already, make things simpler.
jpayne@69 692 *
jpayne@69 693 * IMPORTANT: skip the values 0x10, 0x20, 0x40, 0x800 corresponding to
jpayne@69 694 * TCL_TRACE_(READS/WRITES/UNSETS/ARRAY): makes code simpler in tclTrace.c
jpayne@69 695 *
jpayne@69 696 * Keep the flag values for VAR_ARGUMENT and VAR_TEMPORARY so that old values
jpayne@69 697 * in precompiled scripts keep working.
jpayne@69 698 */
jpayne@69 699
jpayne@69 700 /* Type of value (0 is scalar) */
jpayne@69 701 #define VAR_ARRAY 0x1
jpayne@69 702 #define VAR_LINK 0x2
jpayne@69 703
jpayne@69 704 /* Type of storage (0 is compiled local) */
jpayne@69 705 #define VAR_IN_HASHTABLE 0x4
jpayne@69 706 #define VAR_DEAD_HASH 0x8
jpayne@69 707 #define VAR_ARRAY_ELEMENT 0x1000
jpayne@69 708 #define VAR_NAMESPACE_VAR 0x80 /* KEEP OLD VALUE for Itcl */
jpayne@69 709
jpayne@69 710 #define VAR_ALL_HASH \
jpayne@69 711 (VAR_IN_HASHTABLE|VAR_DEAD_HASH|VAR_NAMESPACE_VAR|VAR_ARRAY_ELEMENT)
jpayne@69 712
jpayne@69 713 /* Trace and search state. */
jpayne@69 714
jpayne@69 715 #define VAR_TRACED_READ 0x10 /* TCL_TRACE_READS */
jpayne@69 716 #define VAR_TRACED_WRITE 0x20 /* TCL_TRACE_WRITES */
jpayne@69 717 #define VAR_TRACED_UNSET 0x40 /* TCL_TRACE_UNSETS */
jpayne@69 718 #define VAR_TRACED_ARRAY 0x800 /* TCL_TRACE_ARRAY */
jpayne@69 719 #define VAR_TRACE_ACTIVE 0x2000
jpayne@69 720 #define VAR_SEARCH_ACTIVE 0x4000
jpayne@69 721 #define VAR_ALL_TRACES \
jpayne@69 722 (VAR_TRACED_READ|VAR_TRACED_WRITE|VAR_TRACED_ARRAY|VAR_TRACED_UNSET)
jpayne@69 723
jpayne@69 724 /* Special handling on initialisation (only CompiledLocal). */
jpayne@69 725 #define VAR_ARGUMENT 0x100 /* KEEP OLD VALUE! See tclProc.c */
jpayne@69 726 #define VAR_TEMPORARY 0x200 /* KEEP OLD VALUE! See tclProc.c */
jpayne@69 727 #define VAR_IS_ARGS 0x400
jpayne@69 728 #define VAR_RESOLVED 0x8000
jpayne@69 729
jpayne@69 730 /*
jpayne@69 731 * Macros to ensure that various flag bits are set properly for variables.
jpayne@69 732 * The ANSI C "prototypes" for these macros are:
jpayne@69 733 *
jpayne@69 734 * MODULE_SCOPE void TclSetVarScalar(Var *varPtr);
jpayne@69 735 * MODULE_SCOPE void TclSetVarArray(Var *varPtr);
jpayne@69 736 * MODULE_SCOPE void TclSetVarLink(Var *varPtr);
jpayne@69 737 * MODULE_SCOPE void TclSetVarArrayElement(Var *varPtr);
jpayne@69 738 * MODULE_SCOPE void TclSetVarUndefined(Var *varPtr);
jpayne@69 739 * MODULE_SCOPE void TclClearVarUndefined(Var *varPtr);
jpayne@69 740 */
jpayne@69 741
jpayne@69 742 #define TclSetVarScalar(varPtr) \
jpayne@69 743 (varPtr)->flags &= ~(VAR_ARRAY|VAR_LINK)
jpayne@69 744
jpayne@69 745 #define TclSetVarArray(varPtr) \
jpayne@69 746 (varPtr)->flags = ((varPtr)->flags & ~VAR_LINK) | VAR_ARRAY
jpayne@69 747
jpayne@69 748 #define TclSetVarLink(varPtr) \
jpayne@69 749 (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_LINK
jpayne@69 750
jpayne@69 751 #define TclSetVarArrayElement(varPtr) \
jpayne@69 752 (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
jpayne@69 753
jpayne@69 754 #define TclSetVarUndefined(varPtr) \
jpayne@69 755 (varPtr)->flags &= ~(VAR_ARRAY|VAR_LINK);\
jpayne@69 756 (varPtr)->value.objPtr = NULL
jpayne@69 757
jpayne@69 758 #define TclClearVarUndefined(varPtr)
jpayne@69 759
jpayne@69 760 #define TclSetVarTraceActive(varPtr) \
jpayne@69 761 (varPtr)->flags |= VAR_TRACE_ACTIVE
jpayne@69 762
jpayne@69 763 #define TclClearVarTraceActive(varPtr) \
jpayne@69 764 (varPtr)->flags &= ~VAR_TRACE_ACTIVE
jpayne@69 765
jpayne@69 766 #define TclSetVarNamespaceVar(varPtr) \
jpayne@69 767 if (!TclIsVarNamespaceVar(varPtr)) {\
jpayne@69 768 (varPtr)->flags |= VAR_NAMESPACE_VAR;\
jpayne@69 769 if (TclIsVarInHash(varPtr)) {\
jpayne@69 770 ((VarInHash *)(varPtr))->refCount++;\
jpayne@69 771 }\
jpayne@69 772 }
jpayne@69 773
jpayne@69 774 #define TclClearVarNamespaceVar(varPtr) \
jpayne@69 775 if (TclIsVarNamespaceVar(varPtr)) {\
jpayne@69 776 (varPtr)->flags &= ~VAR_NAMESPACE_VAR;\
jpayne@69 777 if (TclIsVarInHash(varPtr)) {\
jpayne@69 778 ((VarInHash *)(varPtr))->refCount--;\
jpayne@69 779 }\
jpayne@69 780 }
jpayne@69 781
jpayne@69 782 /*
jpayne@69 783 * Macros to read various flag bits of variables.
jpayne@69 784 * The ANSI C "prototypes" for these macros are:
jpayne@69 785 *
jpayne@69 786 * MODULE_SCOPE int TclIsVarScalar(Var *varPtr);
jpayne@69 787 * MODULE_SCOPE int TclIsVarLink(Var *varPtr);
jpayne@69 788 * MODULE_SCOPE int TclIsVarArray(Var *varPtr);
jpayne@69 789 * MODULE_SCOPE int TclIsVarUndefined(Var *varPtr);
jpayne@69 790 * MODULE_SCOPE int TclIsVarArrayElement(Var *varPtr);
jpayne@69 791 * MODULE_SCOPE int TclIsVarTemporary(Var *varPtr);
jpayne@69 792 * MODULE_SCOPE int TclIsVarArgument(Var *varPtr);
jpayne@69 793 * MODULE_SCOPE int TclIsVarResolved(Var *varPtr);
jpayne@69 794 */
jpayne@69 795
jpayne@69 796 #define TclIsVarScalar(varPtr) \
jpayne@69 797 !((varPtr)->flags & (VAR_ARRAY|VAR_LINK))
jpayne@69 798
jpayne@69 799 #define TclIsVarLink(varPtr) \
jpayne@69 800 ((varPtr)->flags & VAR_LINK)
jpayne@69 801
jpayne@69 802 #define TclIsVarArray(varPtr) \
jpayne@69 803 ((varPtr)->flags & VAR_ARRAY)
jpayne@69 804
jpayne@69 805 #define TclIsVarUndefined(varPtr) \
jpayne@69 806 ((varPtr)->value.objPtr == NULL)
jpayne@69 807
jpayne@69 808 #define TclIsVarArrayElement(varPtr) \
jpayne@69 809 ((varPtr)->flags & VAR_ARRAY_ELEMENT)
jpayne@69 810
jpayne@69 811 #define TclIsVarNamespaceVar(varPtr) \
jpayne@69 812 ((varPtr)->flags & VAR_NAMESPACE_VAR)
jpayne@69 813
jpayne@69 814 #define TclIsVarTemporary(varPtr) \
jpayne@69 815 ((varPtr)->flags & VAR_TEMPORARY)
jpayne@69 816
jpayne@69 817 #define TclIsVarArgument(varPtr) \
jpayne@69 818 ((varPtr)->flags & VAR_ARGUMENT)
jpayne@69 819
jpayne@69 820 #define TclIsVarResolved(varPtr) \
jpayne@69 821 ((varPtr)->flags & VAR_RESOLVED)
jpayne@69 822
jpayne@69 823 #define TclIsVarTraceActive(varPtr) \
jpayne@69 824 ((varPtr)->flags & VAR_TRACE_ACTIVE)
jpayne@69 825
jpayne@69 826 #define TclIsVarTraced(varPtr) \
jpayne@69 827 ((varPtr)->flags & VAR_ALL_TRACES)
jpayne@69 828
jpayne@69 829 #define TclIsVarInHash(varPtr) \
jpayne@69 830 ((varPtr)->flags & VAR_IN_HASHTABLE)
jpayne@69 831
jpayne@69 832 #define TclIsVarDeadHash(varPtr) \
jpayne@69 833 ((varPtr)->flags & VAR_DEAD_HASH)
jpayne@69 834
jpayne@69 835 #define TclGetVarNsPtr(varPtr) \
jpayne@69 836 (TclIsVarInHash(varPtr) \
jpayne@69 837 ? ((TclVarHashTable *) ((((VarInHash *) (varPtr))->entry.tablePtr)))->nsPtr \
jpayne@69 838 : NULL)
jpayne@69 839
jpayne@69 840 #define VarHashRefCount(varPtr) \
jpayne@69 841 ((VarInHash *) (varPtr))->refCount
jpayne@69 842
jpayne@69 843 /*
jpayne@69 844 * Macros for direct variable access by TEBC.
jpayne@69 845 */
jpayne@69 846
jpayne@69 847 #define TclIsVarDirectReadable(varPtr) \
jpayne@69 848 ( !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_READ)) \
jpayne@69 849 && (varPtr)->value.objPtr)
jpayne@69 850
jpayne@69 851 #define TclIsVarDirectWritable(varPtr) \
jpayne@69 852 !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_WRITE|VAR_DEAD_HASH))
jpayne@69 853
jpayne@69 854 #define TclIsVarDirectUnsettable(varPtr) \
jpayne@69 855 !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_READ|VAR_TRACED_WRITE|VAR_TRACED_UNSET|VAR_DEAD_HASH))
jpayne@69 856
jpayne@69 857 #define TclIsVarDirectModifyable(varPtr) \
jpayne@69 858 ( !((varPtr)->flags & (VAR_ARRAY|VAR_LINK|VAR_TRACED_READ|VAR_TRACED_WRITE)) \
jpayne@69 859 && (varPtr)->value.objPtr)
jpayne@69 860
jpayne@69 861 #define TclIsVarDirectReadable2(varPtr, arrayPtr) \
jpayne@69 862 (TclIsVarDirectReadable(varPtr) &&\
jpayne@69 863 (!(arrayPtr) || !((arrayPtr)->flags & VAR_TRACED_READ)))
jpayne@69 864
jpayne@69 865 #define TclIsVarDirectWritable2(varPtr, arrayPtr) \
jpayne@69 866 (TclIsVarDirectWritable(varPtr) &&\
jpayne@69 867 (!(arrayPtr) || !((arrayPtr)->flags & VAR_TRACED_WRITE)))
jpayne@69 868
jpayne@69 869 #define TclIsVarDirectModifyable2(varPtr, arrayPtr) \
jpayne@69 870 (TclIsVarDirectModifyable(varPtr) &&\
jpayne@69 871 (!(arrayPtr) || !((arrayPtr)->flags & (VAR_TRACED_READ|VAR_TRACED_WRITE))))
jpayne@69 872
jpayne@69 873 /*
jpayne@69 874 *----------------------------------------------------------------
jpayne@69 875 * Data structures related to procedures. These are used primarily in
jpayne@69 876 * tclProc.c, tclCompile.c, and tclExecute.c.
jpayne@69 877 *----------------------------------------------------------------
jpayne@69 878 */
jpayne@69 879
jpayne@69 880 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
jpayne@69 881 # define TCLFLEXARRAY
jpayne@69 882 #elif defined(__GNUC__) && (__GNUC__ > 2)
jpayne@69 883 # define TCLFLEXARRAY 0
jpayne@69 884 #else
jpayne@69 885 # define TCLFLEXARRAY 1
jpayne@69 886 #endif
jpayne@69 887
jpayne@69 888 /*
jpayne@69 889 * Forward declaration to prevent an error when the forward reference to
jpayne@69 890 * Command is encountered in the Proc and ImportRef types declared below.
jpayne@69 891 */
jpayne@69 892
jpayne@69 893 struct Command;
jpayne@69 894
jpayne@69 895 /*
jpayne@69 896 * The variable-length structure below describes a local variable of a
jpayne@69 897 * procedure that was recognized by the compiler. These variables have a name,
jpayne@69 898 * an element in the array of compiler-assigned local variables in the
jpayne@69 899 * procedure's call frame, and various other items of information. If the
jpayne@69 900 * local variable is a formal argument, it may also have a default value. The
jpayne@69 901 * compiler can't recognize local variables whose names are expressions (these
jpayne@69 902 * names are only known at runtime when the expressions are evaluated) or
jpayne@69 903 * local variables that are created as a result of an "upvar" or "uplevel"
jpayne@69 904 * command. These other local variables are kept separately in a hash table in
jpayne@69 905 * the call frame.
jpayne@69 906 */
jpayne@69 907
jpayne@69 908 typedef struct CompiledLocal {
jpayne@69 909 struct CompiledLocal *nextPtr;
jpayne@69 910 /* Next compiler-recognized local variable for
jpayne@69 911 * this procedure, or NULL if this is the last
jpayne@69 912 * local. */
jpayne@69 913 int nameLength; /* The number of bytes in local variable's name.
jpayne@69 914 * Among others used to speed up var lookups. */
jpayne@69 915 int frameIndex; /* Index in the array of compiler-assigned
jpayne@69 916 * variables in the procedure call frame. */
jpayne@69 917 int flags; /* Flag bits for the local variable. Same as
jpayne@69 918 * the flags for the Var structure above,
jpayne@69 919 * although only VAR_ARGUMENT, VAR_TEMPORARY,
jpayne@69 920 * and VAR_RESOLVED make sense. */
jpayne@69 921 Tcl_Obj *defValuePtr; /* Pointer to the default value of an
jpayne@69 922 * argument, if any. NULL if not an argument
jpayne@69 923 * or, if an argument, no default value. */
jpayne@69 924 Tcl_ResolvedVarInfo *resolveInfo;
jpayne@69 925 /* Customized variable resolution info
jpayne@69 926 * supplied by the Tcl_ResolveCompiledVarProc
jpayne@69 927 * associated with a namespace. Each variable
jpayne@69 928 * is marked by a unique ClientData tag during
jpayne@69 929 * compilation, and that same tag is used to
jpayne@69 930 * find the variable at runtime. */
jpayne@69 931 char name[TCLFLEXARRAY]; /* Name of the local variable starts here. If
jpayne@69 932 * the name is NULL, this will just be '\0'.
jpayne@69 933 * The actual size of this field will be large
jpayne@69 934 * enough to hold the name. MUST BE THE LAST
jpayne@69 935 * FIELD IN THE STRUCTURE! */
jpayne@69 936 } CompiledLocal;
jpayne@69 937
jpayne@69 938 /*
jpayne@69 939 * The structure below defines a command procedure, which consists of a
jpayne@69 940 * collection of Tcl commands plus information about arguments and other local
jpayne@69 941 * variables recognized at compile time.
jpayne@69 942 */
jpayne@69 943
jpayne@69 944 typedef struct Proc {
jpayne@69 945 struct Interp *iPtr; /* Interpreter for which this command is
jpayne@69 946 * defined. */
jpayne@69 947 int refCount; /* Reference count: 1 if still present in
jpayne@69 948 * command table plus 1 for each call to the
jpayne@69 949 * procedure that is currently active. This
jpayne@69 950 * structure can be freed when refCount
jpayne@69 951 * becomes zero. */
jpayne@69 952 struct Command *cmdPtr; /* Points to the Command structure for this
jpayne@69 953 * procedure. This is used to get the
jpayne@69 954 * namespace in which to execute the
jpayne@69 955 * procedure. */
jpayne@69 956 Tcl_Obj *bodyPtr; /* Points to the ByteCode object for
jpayne@69 957 * procedure's body command. */
jpayne@69 958 int numArgs; /* Number of formal parameters. */
jpayne@69 959 int numCompiledLocals; /* Count of local variables recognized by the
jpayne@69 960 * compiler including arguments and
jpayne@69 961 * temporaries. */
jpayne@69 962 CompiledLocal *firstLocalPtr;
jpayne@69 963 /* Pointer to first of the procedure's
jpayne@69 964 * compiler-allocated local variables, or NULL
jpayne@69 965 * if none. The first numArgs entries in this
jpayne@69 966 * list describe the procedure's formal
jpayne@69 967 * arguments. */
jpayne@69 968 CompiledLocal *lastLocalPtr;/* Pointer to the last allocated local
jpayne@69 969 * variable or NULL if none. This has frame
jpayne@69 970 * index (numCompiledLocals-1). */
jpayne@69 971 } Proc;
jpayne@69 972
jpayne@69 973 /*
jpayne@69 974 * The type of functions called to process errors found during the execution
jpayne@69 975 * of a procedure (or lambda term or ...).
jpayne@69 976 */
jpayne@69 977
jpayne@69 978 typedef void (ProcErrorProc)(Tcl_Interp *interp, Tcl_Obj *procNameObj);
jpayne@69 979
jpayne@69 980 /*
jpayne@69 981 * The structure below defines a command trace. This is used to allow Tcl
jpayne@69 982 * clients to find out whenever a command is about to be executed.
jpayne@69 983 */
jpayne@69 984
jpayne@69 985 typedef struct Trace {
jpayne@69 986 int level; /* Only trace commands at nesting level less
jpayne@69 987 * than or equal to this. */
jpayne@69 988 Tcl_CmdObjTraceProc *proc; /* Procedure to call to trace command. */
jpayne@69 989 ClientData clientData; /* Arbitrary value to pass to proc. */
jpayne@69 990 struct Trace *nextPtr; /* Next in list of traces for this interp. */
jpayne@69 991 int flags; /* Flags governing the trace - see
jpayne@69 992 * Tcl_CreateObjTrace for details. */
jpayne@69 993 Tcl_CmdObjTraceDeleteProc *delProc;
jpayne@69 994 /* Procedure to call when trace is deleted. */
jpayne@69 995 } Trace;
jpayne@69 996
jpayne@69 997 /*
jpayne@69 998 * When an interpreter trace is active (i.e. its associated procedure is
jpayne@69 999 * executing), one of the following structures is linked into a list
jpayne@69 1000 * associated with the interpreter. The information in the structure is needed
jpayne@69 1001 * in order for Tcl to behave reasonably if traces are deleted while traces
jpayne@69 1002 * are active.
jpayne@69 1003 */
jpayne@69 1004
jpayne@69 1005 typedef struct ActiveInterpTrace {
jpayne@69 1006 struct ActiveInterpTrace *nextPtr;
jpayne@69 1007 /* Next in list of all active command traces
jpayne@69 1008 * for the interpreter, or NULL if no more. */
jpayne@69 1009 Trace *nextTracePtr; /* Next trace to check after current trace
jpayne@69 1010 * procedure returns; if this trace gets
jpayne@69 1011 * deleted, must update pointer to avoid using
jpayne@69 1012 * free'd memory. */
jpayne@69 1013 int reverseScan; /* Boolean set true when traces are scanning
jpayne@69 1014 * in reverse order. */
jpayne@69 1015 } ActiveInterpTrace;
jpayne@69 1016
jpayne@69 1017 /*
jpayne@69 1018 * Flag values designating types of execution traces. See tclTrace.c for
jpayne@69 1019 * related flag values.
jpayne@69 1020 *
jpayne@69 1021 * TCL_TRACE_ENTER_EXEC - triggers enter/enterstep traces.
jpayne@69 1022 * - passed to Tcl_CreateObjTrace to set up
jpayne@69 1023 * "enterstep" traces.
jpayne@69 1024 * TCL_TRACE_LEAVE_EXEC - triggers leave/leavestep traces.
jpayne@69 1025 * - passed to Tcl_CreateObjTrace to set up
jpayne@69 1026 * "leavestep" traces.
jpayne@69 1027 */
jpayne@69 1028
jpayne@69 1029 #define TCL_TRACE_ENTER_EXEC 1
jpayne@69 1030 #define TCL_TRACE_LEAVE_EXEC 2
jpayne@69 1031
jpayne@69 1032 /*
jpayne@69 1033 * The structure below defines an entry in the assocData hash table which is
jpayne@69 1034 * associated with an interpreter. The entry contains a pointer to a function
jpayne@69 1035 * to call when the interpreter is deleted, and a pointer to a user-defined
jpayne@69 1036 * piece of data.
jpayne@69 1037 */
jpayne@69 1038
jpayne@69 1039 typedef struct AssocData {
jpayne@69 1040 Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */
jpayne@69 1041 ClientData clientData; /* Value to pass to proc. */
jpayne@69 1042 } AssocData;
jpayne@69 1043
jpayne@69 1044 /*
jpayne@69 1045 * The structure below defines a call frame. A call frame defines a naming
jpayne@69 1046 * context for a procedure call: its local naming scope (for local variables)
jpayne@69 1047 * and its global naming scope (a namespace, perhaps the global :: namespace).
jpayne@69 1048 * A call frame can also define the naming context for a namespace eval or
jpayne@69 1049 * namespace inscope command: the namespace in which the command's code should
jpayne@69 1050 * execute. The Tcl_CallFrame structures exist only while procedures or
jpayne@69 1051 * namespace eval/inscope's are being executed, and provide a kind of Tcl call
jpayne@69 1052 * stack.
jpayne@69 1053 *
jpayne@69 1054 * WARNING!! The structure definition must be kept consistent with the
jpayne@69 1055 * Tcl_CallFrame structure in tcl.h. If you change one, change the other.
jpayne@69 1056 */
jpayne@69 1057
jpayne@69 1058 /*
jpayne@69 1059 * Will be grown to contain: pointers to the varnames (allocated at the end),
jpayne@69 1060 * plus the init values for each variable (suitable to be memcopied on init)
jpayne@69 1061 */
jpayne@69 1062
jpayne@69 1063 typedef struct LocalCache {
jpayne@69 1064 int refCount;
jpayne@69 1065 int numVars;
jpayne@69 1066 Tcl_Obj *varName0;
jpayne@69 1067 } LocalCache;
jpayne@69 1068
jpayne@69 1069 #define localName(framePtr, i) \
jpayne@69 1070 ((&((framePtr)->localCachePtr->varName0))[(i)])
jpayne@69 1071
jpayne@69 1072 MODULE_SCOPE void TclFreeLocalCache(Tcl_Interp *interp,
jpayne@69 1073 LocalCache *localCachePtr);
jpayne@69 1074
jpayne@69 1075 typedef struct CallFrame {
jpayne@69 1076 Namespace *nsPtr; /* Points to the namespace used to resolve
jpayne@69 1077 * commands and global variables. */
jpayne@69 1078 int isProcCallFrame; /* If 0, the frame was pushed to execute a
jpayne@69 1079 * namespace command and var references are
jpayne@69 1080 * treated as references to namespace vars;
jpayne@69 1081 * varTablePtr and compiledLocals are ignored.
jpayne@69 1082 * If FRAME_IS_PROC is set, the frame was
jpayne@69 1083 * pushed to execute a Tcl procedure and may
jpayne@69 1084 * have local vars. */
jpayne@69 1085 int objc; /* This and objv below describe the arguments
jpayne@69 1086 * for this procedure call. */
jpayne@69 1087 Tcl_Obj *const *objv; /* Array of argument objects. */
jpayne@69 1088 struct CallFrame *callerPtr;
jpayne@69 1089 /* Value of interp->framePtr when this
jpayne@69 1090 * procedure was invoked (i.e. next higher in
jpayne@69 1091 * stack of all active procedures). */
jpayne@69 1092 struct CallFrame *callerVarPtr;
jpayne@69 1093 /* Value of interp->varFramePtr when this
jpayne@69 1094 * procedure was invoked (i.e. determines
jpayne@69 1095 * variable scoping within caller). Same as
jpayne@69 1096 * callerPtr unless an "uplevel" command or
jpayne@69 1097 * something equivalent was active in the
jpayne@69 1098 * caller). */
jpayne@69 1099 int level; /* Level of this procedure, for "uplevel"
jpayne@69 1100 * purposes (i.e. corresponds to nesting of
jpayne@69 1101 * callerVarPtr's, not callerPtr's). 1 for
jpayne@69 1102 * outermost procedure, 0 for top-level. */
jpayne@69 1103 Proc *procPtr; /* Points to the structure defining the called
jpayne@69 1104 * procedure. Used to get information such as
jpayne@69 1105 * the number of compiled local variables
jpayne@69 1106 * (local variables assigned entries ["slots"]
jpayne@69 1107 * in the compiledLocals array below). */
jpayne@69 1108 TclVarHashTable *varTablePtr;
jpayne@69 1109 /* Hash table containing local variables not
jpayne@69 1110 * recognized by the compiler, or created at
jpayne@69 1111 * execution time through, e.g., upvar.
jpayne@69 1112 * Initially NULL and created if needed. */
jpayne@69 1113 int numCompiledLocals; /* Count of local variables recognized by the
jpayne@69 1114 * compiler including arguments. */
jpayne@69 1115 Var *compiledLocals; /* Points to the array of local variables
jpayne@69 1116 * recognized by the compiler. The compiler
jpayne@69 1117 * emits code that refers to these variables
jpayne@69 1118 * using an index into this array. */
jpayne@69 1119 ClientData clientData; /* Pointer to some context that is used by
jpayne@69 1120 * object systems. The meaning of the contents
jpayne@69 1121 * of this field is defined by the code that
jpayne@69 1122 * sets it, and it should only ever be set by
jpayne@69 1123 * the code that is pushing the frame. In that
jpayne@69 1124 * case, the code that sets it should also
jpayne@69 1125 * have some means of discovering what the
jpayne@69 1126 * meaning of the value is, which we do not
jpayne@69 1127 * specify. */
jpayne@69 1128 LocalCache *localCachePtr;
jpayne@69 1129 Tcl_Obj *tailcallPtr;
jpayne@69 1130 /* NULL if no tailcall is scheduled */
jpayne@69 1131 } CallFrame;
jpayne@69 1132
jpayne@69 1133 #define FRAME_IS_PROC 0x1
jpayne@69 1134 #define FRAME_IS_LAMBDA 0x2
jpayne@69 1135 #define FRAME_IS_METHOD 0x4 /* The frame is a method body, and the frame's
jpayne@69 1136 * clientData field contains a CallContext
jpayne@69 1137 * reference. Part of TIP#257. */
jpayne@69 1138 #define FRAME_IS_OO_DEFINE 0x8 /* The frame is part of the inside workings of
jpayne@69 1139 * the [oo::define] command; the clientData
jpayne@69 1140 * field contains an Object reference that has
jpayne@69 1141 * been confirmed to refer to a class. Part of
jpayne@69 1142 * TIP#257. */
jpayne@69 1143
jpayne@69 1144 /*
jpayne@69 1145 * TIP #280
jpayne@69 1146 * The structure below defines a command frame. A command frame provides
jpayne@69 1147 * location information for all commands executing a tcl script (source, eval,
jpayne@69 1148 * uplevel, procedure bodies, ...). The runtime structure essentially contains
jpayne@69 1149 * the stack trace as it would be if the currently executing command were to
jpayne@69 1150 * throw an error.
jpayne@69 1151 *
jpayne@69 1152 * For commands where it makes sense it refers to the associated CallFrame as
jpayne@69 1153 * well.
jpayne@69 1154 *
jpayne@69 1155 * The structures are chained in a single list, with the top of the stack
jpayne@69 1156 * anchored in the Interp structure.
jpayne@69 1157 *
jpayne@69 1158 * Instances can be allocated on the C stack, or the heap, the former making
jpayne@69 1159 * cleanup a bit simpler.
jpayne@69 1160 */
jpayne@69 1161
jpayne@69 1162 typedef struct CmdFrame {
jpayne@69 1163 /*
jpayne@69 1164 * General data. Always available.
jpayne@69 1165 */
jpayne@69 1166
jpayne@69 1167 int type; /* Values see below. */
jpayne@69 1168 int level; /* Number of frames in stack, prevent O(n)
jpayne@69 1169 * scan of list. */
jpayne@69 1170 int *line; /* Lines the words of the command start on. */
jpayne@69 1171 int nline;
jpayne@69 1172 CallFrame *framePtr; /* Procedure activation record, may be
jpayne@69 1173 * NULL. */
jpayne@69 1174 struct CmdFrame *nextPtr; /* Link to calling frame. */
jpayne@69 1175 /*
jpayne@69 1176 * Data needed for Eval vs TEBC
jpayne@69 1177 *
jpayne@69 1178 * EXECUTION CONTEXTS and usage of CmdFrame
jpayne@69 1179 *
jpayne@69 1180 * Field TEBC EvalEx
jpayne@69 1181 * ======= ==== ======
jpayne@69 1182 * level yes yes
jpayne@69 1183 * type BC/PREBC SRC/EVAL
jpayne@69 1184 * line0 yes yes
jpayne@69 1185 * framePtr yes yes
jpayne@69 1186 * ======= ==== ======
jpayne@69 1187 *
jpayne@69 1188 * ======= ==== ========= union data
jpayne@69 1189 * line1 - yes
jpayne@69 1190 * line3 - yes
jpayne@69 1191 * path - yes
jpayne@69 1192 * ------- ---- ------
jpayne@69 1193 * codePtr yes -
jpayne@69 1194 * pc yes -
jpayne@69 1195 * ======= ==== ======
jpayne@69 1196 *
jpayne@69 1197 * ======= ==== ========= union cmd
jpayne@69 1198 * str.cmd yes yes
jpayne@69 1199 * str.len yes yes
jpayne@69 1200 * ------- ---- ------
jpayne@69 1201 */
jpayne@69 1202
jpayne@69 1203 union {
jpayne@69 1204 struct {
jpayne@69 1205 Tcl_Obj *path; /* Path of the sourced file the command is
jpayne@69 1206 * in. */
jpayne@69 1207 } eval;
jpayne@69 1208 struct {
jpayne@69 1209 const void *codePtr;/* Byte code currently executed... */
jpayne@69 1210 const char *pc; /* ... and instruction pointer. */
jpayne@69 1211 } tebc;
jpayne@69 1212 } data;
jpayne@69 1213 Tcl_Obj *cmdObj;
jpayne@69 1214 const char *cmd; /* The executed command, if possible... */
jpayne@69 1215 int len; /* ... and its length. */
jpayne@69 1216 const struct CFWordBC *litarg;
jpayne@69 1217 /* Link to set of literal arguments which have
jpayne@69 1218 * ben pushed on the lineLABCPtr stack by
jpayne@69 1219 * TclArgumentBCEnter(). These will be removed
jpayne@69 1220 * by TclArgumentBCRelease. */
jpayne@69 1221 } CmdFrame;
jpayne@69 1222
jpayne@69 1223 typedef struct CFWord {
jpayne@69 1224 CmdFrame *framePtr; /* CmdFrame to access. */
jpayne@69 1225 int word; /* Index of the word in the command. */
jpayne@69 1226 int refCount; /* Number of times the word is on the
jpayne@69 1227 * stack. */
jpayne@69 1228 } CFWord;
jpayne@69 1229
jpayne@69 1230 typedef struct CFWordBC {
jpayne@69 1231 CmdFrame *framePtr; /* CmdFrame to access. */
jpayne@69 1232 int pc; /* Instruction pointer of a command in
jpayne@69 1233 * ExtCmdLoc.loc[.] */
jpayne@69 1234 int word; /* Index of word in
jpayne@69 1235 * ExtCmdLoc.loc[cmd]->line[.] */
jpayne@69 1236 struct CFWordBC *prevPtr; /* Previous entry in stack for same Tcl_Obj. */
jpayne@69 1237 struct CFWordBC *nextPtr; /* Next entry for same command call. See
jpayne@69 1238 * CmdFrame litarg field for the list start. */
jpayne@69 1239 Tcl_Obj *obj; /* Back reference to hashtable key */
jpayne@69 1240 } CFWordBC;
jpayne@69 1241
jpayne@69 1242 /*
jpayne@69 1243 * Structure to record the locations of invisible continuation lines in
jpayne@69 1244 * literal scripts, as character offset from the beginning of the script. Both
jpayne@69 1245 * compiler and direct evaluator use this information to adjust their line
jpayne@69 1246 * counters when tracking through the script, because when it is invoked the
jpayne@69 1247 * continuation line marker as a whole has been removed already, meaning that
jpayne@69 1248 * the \n which was part of it is gone as well, breaking regular line
jpayne@69 1249 * tracking.
jpayne@69 1250 *
jpayne@69 1251 * These structures are allocated and filled by both the function
jpayne@69 1252 * TclSubstTokens() in the file "tclParse.c" and its caller TclEvalEx() in the
jpayne@69 1253 * file "tclBasic.c", and stored in the thread-global hashtable "lineCLPtr" in
jpayne@69 1254 * file "tclObj.c". They are used by the functions TclSetByteCodeFromAny() and
jpayne@69 1255 * TclCompileScript(), both found in the file "tclCompile.c". Their memory is
jpayne@69 1256 * released by the function TclFreeObj(), in the file "tclObj.c", and also by
jpayne@69 1257 * the function TclThreadFinalizeObjects(), in the same file.
jpayne@69 1258 */
jpayne@69 1259
jpayne@69 1260 #define CLL_END (-1)
jpayne@69 1261
jpayne@69 1262 typedef struct ContLineLoc {
jpayne@69 1263 int num; /* Number of entries in loc, not counting the
jpayne@69 1264 * final -1 marker entry. */
jpayne@69 1265 int loc[TCLFLEXARRAY];/* Table of locations, as character offsets.
jpayne@69 1266 * The table is allocated as part of the
jpayne@69 1267 * structure, extending behind the nominal end
jpayne@69 1268 * of the structure. An entry containing the
jpayne@69 1269 * value -1 is put after the last location, as
jpayne@69 1270 * end-marker/sentinel. */
jpayne@69 1271 } ContLineLoc;
jpayne@69 1272
jpayne@69 1273 /*
jpayne@69 1274 * The following macros define the allowed values for the type field of the
jpayne@69 1275 * CmdFrame structure above. Some of the values occur only in the extended
jpayne@69 1276 * location data referenced via the 'baseLocPtr'.
jpayne@69 1277 *
jpayne@69 1278 * TCL_LOCATION_EVAL : Frame is for a script evaluated by EvalEx.
jpayne@69 1279 * TCL_LOCATION_BC : Frame is for bytecode.
jpayne@69 1280 * TCL_LOCATION_PREBC : Frame is for precompiled bytecode.
jpayne@69 1281 * TCL_LOCATION_SOURCE : Frame is for a script evaluated by EvalEx, from a
jpayne@69 1282 * sourced file.
jpayne@69 1283 * TCL_LOCATION_PROC : Frame is for bytecode of a procedure.
jpayne@69 1284 *
jpayne@69 1285 * A TCL_LOCATION_BC type in a frame can be overridden by _SOURCE and _PROC
jpayne@69 1286 * types, per the context of the byte code in execution.
jpayne@69 1287 */
jpayne@69 1288
jpayne@69 1289 #define TCL_LOCATION_EVAL (0) /* Location in a dynamic eval script. */
jpayne@69 1290 #define TCL_LOCATION_BC (2) /* Location in byte code. */
jpayne@69 1291 #define TCL_LOCATION_PREBC (3) /* Location in precompiled byte code, no
jpayne@69 1292 * location. */
jpayne@69 1293 #define TCL_LOCATION_SOURCE (4) /* Location in a file. */
jpayne@69 1294 #define TCL_LOCATION_PROC (5) /* Location in a dynamic proc. */
jpayne@69 1295 #define TCL_LOCATION_LAST (6) /* Number of values in the enum. */
jpayne@69 1296
jpayne@69 1297 /*
jpayne@69 1298 * Structure passed to describe procedure-like "procedures" that are not
jpayne@69 1299 * procedures (e.g. a lambda) so that their details can be reported correctly
jpayne@69 1300 * by [info frame]. Contains a sub-structure for each extra field.
jpayne@69 1301 */
jpayne@69 1302
jpayne@69 1303 typedef Tcl_Obj * (GetFrameInfoValueProc)(ClientData clientData);
jpayne@69 1304 typedef struct {
jpayne@69 1305 const char *name; /* Name of this field. */
jpayne@69 1306 GetFrameInfoValueProc *proc; /* Function to generate a Tcl_Obj* from the
jpayne@69 1307 * clientData, or just use the clientData
jpayne@69 1308 * directly (after casting) if NULL. */
jpayne@69 1309 ClientData clientData; /* Context for above function, or Tcl_Obj* if
jpayne@69 1310 * proc field is NULL. */
jpayne@69 1311 } ExtraFrameInfoField;
jpayne@69 1312 typedef struct {
jpayne@69 1313 int length; /* Length of array. */
jpayne@69 1314 ExtraFrameInfoField fields[2];
jpayne@69 1315 /* Really as long as necessary, but this is
jpayne@69 1316 * long enough for nearly anything. */
jpayne@69 1317 } ExtraFrameInfo;
jpayne@69 1318
jpayne@69 1319 /*
jpayne@69 1320 *----------------------------------------------------------------
jpayne@69 1321 * Data structures and procedures related to TclHandles, which are a very
jpayne@69 1322 * lightweight method of preserving enough information to determine if an
jpayne@69 1323 * arbitrary malloc'd block has been deleted.
jpayne@69 1324 *----------------------------------------------------------------
jpayne@69 1325 */
jpayne@69 1326
jpayne@69 1327 typedef void **TclHandle;
jpayne@69 1328
jpayne@69 1329 /*
jpayne@69 1330 *----------------------------------------------------------------
jpayne@69 1331 * Experimental flag value passed to Tcl_GetRegExpFromObj. Intended for use
jpayne@69 1332 * only by Expect. It will probably go away in a later release.
jpayne@69 1333 *----------------------------------------------------------------
jpayne@69 1334 */
jpayne@69 1335
jpayne@69 1336 #define TCL_REG_BOSONLY 002000 /* Prepend \A to pattern so it only matches at
jpayne@69 1337 * the beginning of the string. */
jpayne@69 1338
jpayne@69 1339 /*
jpayne@69 1340 * These are a thin layer over TclpThreadKeyDataGet and TclpThreadKeyDataSet
jpayne@69 1341 * when threads are used, or an emulation if there are no threads. These are
jpayne@69 1342 * really internal and Tcl clients should use Tcl_GetThreadData.
jpayne@69 1343 */
jpayne@69 1344
jpayne@69 1345 MODULE_SCOPE void * TclThreadDataKeyGet(Tcl_ThreadDataKey *keyPtr);
jpayne@69 1346 MODULE_SCOPE void TclThreadDataKeySet(Tcl_ThreadDataKey *keyPtr,
jpayne@69 1347 void *data);
jpayne@69 1348
jpayne@69 1349 /*
jpayne@69 1350 * This is a convenience macro used to initialize a thread local storage ptr.
jpayne@69 1351 */
jpayne@69 1352
jpayne@69 1353 #define TCL_TSD_INIT(keyPtr) \
jpayne@69 1354 (ThreadSpecificData *)Tcl_GetThreadData((keyPtr), sizeof(ThreadSpecificData))
jpayne@69 1355
jpayne@69 1356 /*
jpayne@69 1357 *----------------------------------------------------------------
jpayne@69 1358 * Data structures related to bytecode compilation and execution. These are
jpayne@69 1359 * used primarily in tclCompile.c, tclExecute.c, and tclBasic.c.
jpayne@69 1360 *----------------------------------------------------------------
jpayne@69 1361 */
jpayne@69 1362
jpayne@69 1363 /*
jpayne@69 1364 * Forward declaration to prevent errors when the forward references to
jpayne@69 1365 * Tcl_Parse and CompileEnv are encountered in the procedure type CompileProc
jpayne@69 1366 * declared below.
jpayne@69 1367 */
jpayne@69 1368
jpayne@69 1369 struct CompileEnv;
jpayne@69 1370
jpayne@69 1371 /*
jpayne@69 1372 * The type of procedures called by the Tcl bytecode compiler to compile
jpayne@69 1373 * commands. Pointers to these procedures are kept in the Command structure
jpayne@69 1374 * describing each command. The integer value returned by a CompileProc must
jpayne@69 1375 * be one of the following:
jpayne@69 1376 *
jpayne@69 1377 * TCL_OK Compilation completed normally.
jpayne@69 1378 * TCL_ERROR Compilation could not be completed. This can be just a
jpayne@69 1379 * judgment by the CompileProc that the command is too
jpayne@69 1380 * complex to compile effectively, or it can indicate
jpayne@69 1381 * that in the current state of the interp, the command
jpayne@69 1382 * would raise an error. The bytecode compiler will not
jpayne@69 1383 * do any error reporting at compiler time. Error
jpayne@69 1384 * reporting is deferred until the actual runtime,
jpayne@69 1385 * because by then changes in the interp state may allow
jpayne@69 1386 * the command to be successfully evaluated.
jpayne@69 1387 * TCL_OUT_LINE_COMPILE A source-compatible alias for TCL_ERROR, kept for the
jpayne@69 1388 * sake of old code only.
jpayne@69 1389 */
jpayne@69 1390
jpayne@69 1391 #define TCL_OUT_LINE_COMPILE TCL_ERROR
jpayne@69 1392
jpayne@69 1393 typedef int (CompileProc)(Tcl_Interp *interp, Tcl_Parse *parsePtr,
jpayne@69 1394 struct Command *cmdPtr, struct CompileEnv *compEnvPtr);
jpayne@69 1395
jpayne@69 1396 /*
jpayne@69 1397 * The type of procedure called from the compilation hook point in
jpayne@69 1398 * SetByteCodeFromAny.
jpayne@69 1399 */
jpayne@69 1400
jpayne@69 1401 typedef int (CompileHookProc)(Tcl_Interp *interp,
jpayne@69 1402 struct CompileEnv *compEnvPtr, ClientData clientData);
jpayne@69 1403
jpayne@69 1404 /*
jpayne@69 1405 * The data structure for a (linked list of) execution stacks.
jpayne@69 1406 */
jpayne@69 1407
jpayne@69 1408 typedef struct ExecStack {
jpayne@69 1409 struct ExecStack *prevPtr;
jpayne@69 1410 struct ExecStack *nextPtr;
jpayne@69 1411 Tcl_Obj **markerPtr;
jpayne@69 1412 Tcl_Obj **endPtr;
jpayne@69 1413 Tcl_Obj **tosPtr;
jpayne@69 1414 Tcl_Obj *stackWords[TCLFLEXARRAY];
jpayne@69 1415 } ExecStack;
jpayne@69 1416
jpayne@69 1417 /*
jpayne@69 1418 * The data structure defining the execution environment for ByteCode's.
jpayne@69 1419 * There is one ExecEnv structure per Tcl interpreter. It holds the evaluation
jpayne@69 1420 * stack that holds command operands and results. The stack grows towards
jpayne@69 1421 * increasing addresses. The member stackPtr points to the stackItems of the
jpayne@69 1422 * currently active execution stack.
jpayne@69 1423 */
jpayne@69 1424
jpayne@69 1425 typedef struct CorContext {
jpayne@69 1426 struct CallFrame *framePtr;
jpayne@69 1427 struct CallFrame *varFramePtr;
jpayne@69 1428 struct CmdFrame *cmdFramePtr; /* See Interp.cmdFramePtr */
jpayne@69 1429 Tcl_HashTable *lineLABCPtr; /* See Interp.lineLABCPtr */
jpayne@69 1430 } CorContext;
jpayne@69 1431
jpayne@69 1432 typedef struct CoroutineData {
jpayne@69 1433 struct Command *cmdPtr; /* The command handle for the coroutine. */
jpayne@69 1434 struct ExecEnv *eePtr; /* The special execution environment (stacks,
jpayne@69 1435 * etc.) for the coroutine. */
jpayne@69 1436 struct ExecEnv *callerEEPtr;/* The execution environment for the caller of
jpayne@69 1437 * the coroutine, which might be the
jpayne@69 1438 * interpreter global environment or another
jpayne@69 1439 * coroutine. */
jpayne@69 1440 CorContext caller;
jpayne@69 1441 CorContext running;
jpayne@69 1442 Tcl_HashTable *lineLABCPtr; /* See Interp.lineLABCPtr */
jpayne@69 1443 void *stackLevel;
jpayne@69 1444 int auxNumLevels; /* While the coroutine is running the
jpayne@69 1445 * numLevels of the create/resume command is
jpayne@69 1446 * stored here; for suspended coroutines it
jpayne@69 1447 * holds the nesting numLevels at yield. */
jpayne@69 1448 int nargs; /* Number of args required for resuming this
jpayne@69 1449 * coroutine; -2 means "0 or 1" (default), -1
jpayne@69 1450 * means "any" */
jpayne@69 1451 } CoroutineData;
jpayne@69 1452
jpayne@69 1453 typedef struct ExecEnv {
jpayne@69 1454 ExecStack *execStackPtr; /* Points to the first item in the evaluation
jpayne@69 1455 * stack on the heap. */
jpayne@69 1456 Tcl_Obj *constants[2]; /* Pointers to constant "0" and "1" objs. */
jpayne@69 1457 struct Tcl_Interp *interp;
jpayne@69 1458 struct NRE_callback *callbackPtr;
jpayne@69 1459 /* Top callback in NRE's stack. */
jpayne@69 1460 struct CoroutineData *corPtr;
jpayne@69 1461 int rewind;
jpayne@69 1462 } ExecEnv;
jpayne@69 1463
jpayne@69 1464 #define COR_IS_SUSPENDED(corPtr) \
jpayne@69 1465 ((corPtr)->stackLevel == NULL)
jpayne@69 1466
jpayne@69 1467 /*
jpayne@69 1468 * The definitions for the LiteralTable and LiteralEntry structures. Each
jpayne@69 1469 * interpreter contains a LiteralTable. It is used to reduce the storage
jpayne@69 1470 * needed for all the Tcl objects that hold the literals of scripts compiled
jpayne@69 1471 * by the interpreter. A literal's object is shared by all the ByteCodes that
jpayne@69 1472 * refer to the literal. Each distinct literal has one LiteralEntry entry in
jpayne@69 1473 * the LiteralTable. A literal table is a specialized hash table that is
jpayne@69 1474 * indexed by the literal's string representation, which may contain null
jpayne@69 1475 * characters.
jpayne@69 1476 *
jpayne@69 1477 * Note that we reduce the space needed for literals by sharing literal
jpayne@69 1478 * objects both within a ByteCode (each ByteCode contains a local
jpayne@69 1479 * LiteralTable) and across all an interpreter's ByteCodes (with the
jpayne@69 1480 * interpreter's global LiteralTable).
jpayne@69 1481 */
jpayne@69 1482
jpayne@69 1483 typedef struct LiteralEntry {
jpayne@69 1484 struct LiteralEntry *nextPtr;
jpayne@69 1485 /* Points to next entry in this hash bucket or
jpayne@69 1486 * NULL if end of chain. */
jpayne@69 1487 Tcl_Obj *objPtr; /* Points to Tcl object that holds the
jpayne@69 1488 * literal's bytes and length. */
jpayne@69 1489 int refCount; /* If in an interpreter's global literal
jpayne@69 1490 * table, the number of ByteCode structures
jpayne@69 1491 * that share the literal object; the literal
jpayne@69 1492 * entry can be freed when refCount drops to
jpayne@69 1493 * 0. If in a local literal table, -1. */
jpayne@69 1494 Namespace *nsPtr; /* Namespace in which this literal is used. We
jpayne@69 1495 * try to avoid sharing literal non-FQ command
jpayne@69 1496 * names among different namespaces to reduce
jpayne@69 1497 * shimmering. */
jpayne@69 1498 } LiteralEntry;
jpayne@69 1499
jpayne@69 1500 typedef struct LiteralTable {
jpayne@69 1501 LiteralEntry **buckets; /* Pointer to bucket array. Each element
jpayne@69 1502 * points to first entry in bucket's hash
jpayne@69 1503 * chain, or NULL. */
jpayne@69 1504 LiteralEntry *staticBuckets[TCL_SMALL_HASH_TABLE];
jpayne@69 1505 /* Bucket array used for small tables to avoid
jpayne@69 1506 * mallocs and frees. */
jpayne@69 1507 int numBuckets; /* Total number of buckets allocated at
jpayne@69 1508 * **buckets. */
jpayne@69 1509 int numEntries; /* Total number of entries present in
jpayne@69 1510 * table. */
jpayne@69 1511 int rebuildSize; /* Enlarge table when numEntries gets to be
jpayne@69 1512 * this large. */
jpayne@69 1513 int mask; /* Mask value used in hashing function. */
jpayne@69 1514 } LiteralTable;
jpayne@69 1515
jpayne@69 1516 /*
jpayne@69 1517 * The following structure defines for each Tcl interpreter various
jpayne@69 1518 * statistics-related information about the bytecode compiler and
jpayne@69 1519 * interpreter's operation in that interpreter.
jpayne@69 1520 */
jpayne@69 1521
jpayne@69 1522 #ifdef TCL_COMPILE_STATS
jpayne@69 1523 typedef struct ByteCodeStats {
jpayne@69 1524 long numExecutions; /* Number of ByteCodes executed. */
jpayne@69 1525 long numCompilations; /* Number of ByteCodes created. */
jpayne@69 1526 long numByteCodesFreed; /* Number of ByteCodes destroyed. */
jpayne@69 1527 long instructionCount[256]; /* Number of times each instruction was
jpayne@69 1528 * executed. */
jpayne@69 1529
jpayne@69 1530 double totalSrcBytes; /* Total source bytes ever compiled. */
jpayne@69 1531 double totalByteCodeBytes; /* Total bytes for all ByteCodes. */
jpayne@69 1532 double currentSrcBytes; /* Src bytes for all current ByteCodes. */
jpayne@69 1533 double currentByteCodeBytes;/* Code bytes in all current ByteCodes. */
jpayne@69 1534
jpayne@69 1535 long srcCount[32]; /* Source size distribution: # of srcs of
jpayne@69 1536 * size [2**(n-1)..2**n), n in [0..32). */
jpayne@69 1537 long byteCodeCount[32]; /* ByteCode size distribution. */
jpayne@69 1538 long lifetimeCount[32]; /* ByteCode lifetime distribution (ms). */
jpayne@69 1539
jpayne@69 1540 double currentInstBytes; /* Instruction bytes-current ByteCodes. */
jpayne@69 1541 double currentLitBytes; /* Current literal bytes. */
jpayne@69 1542 double currentExceptBytes; /* Current exception table bytes. */
jpayne@69 1543 double currentAuxBytes; /* Current auxiliary information bytes. */
jpayne@69 1544 double currentCmdMapBytes; /* Current src<->code map bytes. */
jpayne@69 1545
jpayne@69 1546 long numLiteralsCreated; /* Total literal objects ever compiled. */
jpayne@69 1547 double totalLitStringBytes; /* Total string bytes in all literals. */
jpayne@69 1548 double currentLitStringBytes;
jpayne@69 1549 /* String bytes in current literals. */
jpayne@69 1550 long literalCount[32]; /* Distribution of literal string sizes. */
jpayne@69 1551 } ByteCodeStats;
jpayne@69 1552 #endif /* TCL_COMPILE_STATS */
jpayne@69 1553
jpayne@69 1554 /*
jpayne@69 1555 * Structure used in implementation of those core ensembles which are
jpayne@69 1556 * partially compiled. Used as an array of these, with a terminating field
jpayne@69 1557 * whose 'name' is NULL.
jpayne@69 1558 */
jpayne@69 1559
jpayne@69 1560 typedef struct {
jpayne@69 1561 const char *name; /* The name of the subcommand. */
jpayne@69 1562 Tcl_ObjCmdProc *proc; /* The implementation of the subcommand. */
jpayne@69 1563 CompileProc *compileProc; /* The compiler for the subcommand. */
jpayne@69 1564 Tcl_ObjCmdProc *nreProc; /* NRE implementation of this command. */
jpayne@69 1565 ClientData clientData; /* Any clientData to give the command. */
jpayne@69 1566 int unsafe; /* Whether this command is to be hidden by
jpayne@69 1567 * default in a safe interpreter. */
jpayne@69 1568 } EnsembleImplMap;
jpayne@69 1569
jpayne@69 1570 /*
jpayne@69 1571 *----------------------------------------------------------------
jpayne@69 1572 * Data structures related to commands.
jpayne@69 1573 *----------------------------------------------------------------
jpayne@69 1574 */
jpayne@69 1575
jpayne@69 1576 /*
jpayne@69 1577 * An imported command is created in an namespace when it imports a "real"
jpayne@69 1578 * command from another namespace. An imported command has a Command structure
jpayne@69 1579 * that points (via its ClientData value) to the "real" Command structure in
jpayne@69 1580 * the source namespace's command table. The real command records all the
jpayne@69 1581 * imported commands that refer to it in a list of ImportRef structures so
jpayne@69 1582 * that they can be deleted when the real command is deleted.
jpayne@69 1583 */
jpayne@69 1584
jpayne@69 1585 typedef struct ImportRef {
jpayne@69 1586 struct Command *importedCmdPtr;
jpayne@69 1587 /* Points to the imported command created in
jpayne@69 1588 * an importing namespace; this command
jpayne@69 1589 * redirects its invocations to the "real"
jpayne@69 1590 * command. */
jpayne@69 1591 struct ImportRef *nextPtr; /* Next element on the linked list of imported
jpayne@69 1592 * commands that refer to the "real" command.
jpayne@69 1593 * The real command deletes these imported
jpayne@69 1594 * commands on this list when it is
jpayne@69 1595 * deleted. */
jpayne@69 1596 } ImportRef;
jpayne@69 1597
jpayne@69 1598 /*
jpayne@69 1599 * Data structure used as the ClientData of imported commands: commands
jpayne@69 1600 * created in an namespace when it imports a "real" command from another
jpayne@69 1601 * namespace.
jpayne@69 1602 */
jpayne@69 1603
jpayne@69 1604 typedef struct ImportedCmdData {
jpayne@69 1605 struct Command *realCmdPtr; /* "Real" command that this imported command
jpayne@69 1606 * refers to. */
jpayne@69 1607 struct Command *selfPtr; /* Pointer to this imported command. Needed
jpayne@69 1608 * only when deleting it in order to remove it
jpayne@69 1609 * from the real command's linked list of
jpayne@69 1610 * imported commands that refer to it. */
jpayne@69 1611 } ImportedCmdData;
jpayne@69 1612
jpayne@69 1613 /*
jpayne@69 1614 * A Command structure exists for each command in a namespace. The Tcl_Command
jpayne@69 1615 * opaque type actually refers to these structures.
jpayne@69 1616 */
jpayne@69 1617
jpayne@69 1618 typedef struct Command {
jpayne@69 1619 Tcl_HashEntry *hPtr; /* Pointer to the hash table entry that refers
jpayne@69 1620 * to this command. The hash table is either a
jpayne@69 1621 * namespace's command table or an
jpayne@69 1622 * interpreter's hidden command table. This
jpayne@69 1623 * pointer is used to get a command's name
jpayne@69 1624 * from its Tcl_Command handle. NULL means
jpayne@69 1625 * that the hash table entry has been removed
jpayne@69 1626 * already (this can happen if deleteProc
jpayne@69 1627 * causes the command to be deleted or
jpayne@69 1628 * recreated). */
jpayne@69 1629 Namespace *nsPtr; /* Points to the namespace containing this
jpayne@69 1630 * command. */
jpayne@69 1631 int refCount; /* 1 if in command hashtable plus 1 for each
jpayne@69 1632 * reference from a CmdName Tcl object
jpayne@69 1633 * representing a command's name in a ByteCode
jpayne@69 1634 * instruction sequence. This structure can be
jpayne@69 1635 * freed when refCount becomes zero. */
jpayne@69 1636 int cmdEpoch; /* Incremented to invalidate any references
jpayne@69 1637 * that point to this command when it is
jpayne@69 1638 * renamed, deleted, hidden, or exposed. */
jpayne@69 1639 CompileProc *compileProc; /* Procedure called to compile command. NULL
jpayne@69 1640 * if no compile proc exists for command. */
jpayne@69 1641 Tcl_ObjCmdProc *objProc; /* Object-based command procedure. */
jpayne@69 1642 ClientData objClientData; /* Arbitrary value passed to object proc. */
jpayne@69 1643 Tcl_CmdProc *proc; /* String-based command procedure. */
jpayne@69 1644 ClientData clientData; /* Arbitrary value passed to string proc. */
jpayne@69 1645 Tcl_CmdDeleteProc *deleteProc;
jpayne@69 1646 /* Procedure invoked when deleting command to,
jpayne@69 1647 * e.g., free all client data. */
jpayne@69 1648 ClientData deleteData; /* Arbitrary value passed to deleteProc. */
jpayne@69 1649 int flags; /* Miscellaneous bits of information about
jpayne@69 1650 * command. See below for definitions. */
jpayne@69 1651 ImportRef *importRefPtr; /* List of each imported Command created in
jpayne@69 1652 * another namespace when this command is
jpayne@69 1653 * imported. These imported commands redirect
jpayne@69 1654 * invocations back to this command. The list
jpayne@69 1655 * is used to remove all those imported
jpayne@69 1656 * commands when deleting this "real"
jpayne@69 1657 * command. */
jpayne@69 1658 CommandTrace *tracePtr; /* First in list of all traces set for this
jpayne@69 1659 * command. */
jpayne@69 1660 Tcl_ObjCmdProc *nreProc; /* NRE implementation of this command. */
jpayne@69 1661 } Command;
jpayne@69 1662
jpayne@69 1663 /*
jpayne@69 1664 * Flag bits for commands.
jpayne@69 1665 *
jpayne@69 1666 * CMD_IS_DELETED - Means that the command is in the process of
jpayne@69 1667 * being deleted (its deleteProc is currently
jpayne@69 1668 * executing). Other attempts to delete the
jpayne@69 1669 * command should be ignored.
jpayne@69 1670 * CMD_TRACE_ACTIVE - 1 means that trace processing is currently
jpayne@69 1671 * underway for a rename/delete change. See the
jpayne@69 1672 * two flags below for which is currently being
jpayne@69 1673 * processed.
jpayne@69 1674 * CMD_HAS_EXEC_TRACES - 1 means that this command has at least one
jpayne@69 1675 * execution trace (as opposed to simple
jpayne@69 1676 * delete/rename traces) in its tracePtr list.
jpayne@69 1677 * CMD_COMPILES_EXPANDED - 1 means that this command has a compiler that
jpayne@69 1678 * can handle expansion (provided it is not the
jpayne@69 1679 * first word).
jpayne@69 1680 * TCL_TRACE_RENAME - A rename trace is in progress. Further
jpayne@69 1681 * recursive renames will not be traced.
jpayne@69 1682 * TCL_TRACE_DELETE - A delete trace is in progress. Further
jpayne@69 1683 * recursive deletes will not be traced.
jpayne@69 1684 * (these last two flags are defined in tcl.h)
jpayne@69 1685 */
jpayne@69 1686
jpayne@69 1687 #define CMD_IS_DELETED 0x01
jpayne@69 1688 #define CMD_TRACE_ACTIVE 0x02
jpayne@69 1689 #define CMD_HAS_EXEC_TRACES 0x04
jpayne@69 1690 #define CMD_COMPILES_EXPANDED 0x08
jpayne@69 1691 #define CMD_REDEF_IN_PROGRESS 0x10
jpayne@69 1692 #define CMD_VIA_RESOLVER 0x20
jpayne@69 1693 #define CMD_DEAD 0x40
jpayne@69 1694
jpayne@69 1695
jpayne@69 1696 /*
jpayne@69 1697 *----------------------------------------------------------------
jpayne@69 1698 * Data structures related to name resolution procedures.
jpayne@69 1699 *----------------------------------------------------------------
jpayne@69 1700 */
jpayne@69 1701
jpayne@69 1702 /*
jpayne@69 1703 * The interpreter keeps a linked list of name resolution schemes. The scheme
jpayne@69 1704 * for a namespace is consulted first, followed by the list of schemes in an
jpayne@69 1705 * interpreter, followed by the default name resolution in Tcl. Schemes are
jpayne@69 1706 * added/removed from the interpreter's list by calling Tcl_AddInterpResolver
jpayne@69 1707 * and Tcl_RemoveInterpResolver.
jpayne@69 1708 */
jpayne@69 1709
jpayne@69 1710 typedef struct ResolverScheme {
jpayne@69 1711 char *name; /* Name identifying this scheme. */
jpayne@69 1712 Tcl_ResolveCmdProc *cmdResProc;
jpayne@69 1713 /* Procedure handling command name
jpayne@69 1714 * resolution. */
jpayne@69 1715 Tcl_ResolveVarProc *varResProc;
jpayne@69 1716 /* Procedure handling variable name resolution
jpayne@69 1717 * for variables that can only be handled at
jpayne@69 1718 * runtime. */
jpayne@69 1719 Tcl_ResolveCompiledVarProc *compiledVarResProc;
jpayne@69 1720 /* Procedure handling variable name resolution
jpayne@69 1721 * at compile time. */
jpayne@69 1722
jpayne@69 1723 struct ResolverScheme *nextPtr;
jpayne@69 1724 /* Pointer to next record in linked list. */
jpayne@69 1725 } ResolverScheme;
jpayne@69 1726
jpayne@69 1727 /*
jpayne@69 1728 * Forward declaration of the TIP#143 limit handler structure.
jpayne@69 1729 */
jpayne@69 1730
jpayne@69 1731 typedef struct LimitHandler LimitHandler;
jpayne@69 1732
jpayne@69 1733 /*
jpayne@69 1734 * TIP #268.
jpayne@69 1735 * Values for the selection mode, i.e the package require preferences.
jpayne@69 1736 */
jpayne@69 1737
jpayne@69 1738 enum PkgPreferOptions {
jpayne@69 1739 PKG_PREFER_LATEST, PKG_PREFER_STABLE
jpayne@69 1740 };
jpayne@69 1741
jpayne@69 1742 /*
jpayne@69 1743 *----------------------------------------------------------------
jpayne@69 1744 * This structure shadows the first few fields of the memory cache for the
jpayne@69 1745 * allocator defined in tclThreadAlloc.c; it has to be kept in sync with the
jpayne@69 1746 * definition there.
jpayne@69 1747 * Some macros require knowledge of some fields in the struct in order to
jpayne@69 1748 * avoid hitting the TSD unnecessarily. In order to facilitate this, a pointer
jpayne@69 1749 * to the relevant fields is kept in the allocCache field in struct Interp.
jpayne@69 1750 *----------------------------------------------------------------
jpayne@69 1751 */
jpayne@69 1752
jpayne@69 1753 typedef struct AllocCache {
jpayne@69 1754 struct Cache *nextPtr; /* Linked list of cache entries. */
jpayne@69 1755 Tcl_ThreadId owner; /* Which thread's cache is this? */
jpayne@69 1756 Tcl_Obj *firstObjPtr; /* List of free objects for thread. */
jpayne@69 1757 int numObjects; /* Number of objects for thread. */
jpayne@69 1758 } AllocCache;
jpayne@69 1759
jpayne@69 1760 /*
jpayne@69 1761 *----------------------------------------------------------------
jpayne@69 1762 * This structure defines an interpreter, which is a collection of commands
jpayne@69 1763 * plus other state information related to interpreting commands, such as
jpayne@69 1764 * variable storage. Primary responsibility for this data structure is in
jpayne@69 1765 * tclBasic.c, but almost every Tcl source file uses something in here.
jpayne@69 1766 *----------------------------------------------------------------
jpayne@69 1767 */
jpayne@69 1768
jpayne@69 1769 typedef struct Interp {
jpayne@69 1770 /*
jpayne@69 1771 * Note: the first three fields must match exactly the fields in a
jpayne@69 1772 * Tcl_Interp struct (see tcl.h). If you change one, be sure to change the
jpayne@69 1773 * other.
jpayne@69 1774 *
jpayne@69 1775 * The interpreter's result is held in both the string and the
jpayne@69 1776 * objResultPtr fields. These fields hold, respectively, the result's
jpayne@69 1777 * string or object value. The interpreter's result is always in the
jpayne@69 1778 * result field if that is non-empty, otherwise it is in objResultPtr.
jpayne@69 1779 * The two fields are kept consistent unless some C code sets
jpayne@69 1780 * interp->result directly. Programs should not access result and
jpayne@69 1781 * objResultPtr directly; instead, they should always get and set the
jpayne@69 1782 * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult, and
jpayne@69 1783 * Tcl_GetStringResult. See the SetResult man page for details.
jpayne@69 1784 */
jpayne@69 1785
jpayne@69 1786 char *result; /* If the last command returned a string
jpayne@69 1787 * result, this points to it. Should not be
jpayne@69 1788 * accessed directly; see comment above. */
jpayne@69 1789 Tcl_FreeProc *freeProc; /* Zero means a string result is statically
jpayne@69 1790 * allocated. TCL_DYNAMIC means string result
jpayne@69 1791 * was allocated with ckalloc and should be
jpayne@69 1792 * freed with ckfree. Other values give
jpayne@69 1793 * address of procedure to invoke to free the
jpayne@69 1794 * string result. Tcl_Eval must free it before
jpayne@69 1795 * executing next command. */
jpayne@69 1796 int errorLine; /* When TCL_ERROR is returned, this gives the
jpayne@69 1797 * line number in the command where the error
jpayne@69 1798 * occurred (1 means first line). */
jpayne@69 1799 const struct TclStubs *stubTable;
jpayne@69 1800 /* Pointer to the exported Tcl stub table. On
jpayne@69 1801 * previous versions of Tcl this is a pointer
jpayne@69 1802 * to the objResultPtr or a pointer to a
jpayne@69 1803 * buckets array in a hash table. We therefore
jpayne@69 1804 * have to do some careful checking before we
jpayne@69 1805 * can use this. */
jpayne@69 1806
jpayne@69 1807 TclHandle handle; /* Handle used to keep track of when this
jpayne@69 1808 * interp is deleted. */
jpayne@69 1809
jpayne@69 1810 Namespace *globalNsPtr; /* The interpreter's global namespace. */
jpayne@69 1811 Tcl_HashTable *hiddenCmdTablePtr;
jpayne@69 1812 /* Hash table used by tclBasic.c to keep track
jpayne@69 1813 * of hidden commands on a per-interp
jpayne@69 1814 * basis. */
jpayne@69 1815 ClientData interpInfo; /* Information used by tclInterp.c to keep
jpayne@69 1816 * track of parent/child interps on a
jpayne@69 1817 * per-interp basis. */
jpayne@69 1818 union {
jpayne@69 1819 void (*optimizer)(void *envPtr);
jpayne@69 1820 Tcl_HashTable unused2; /* No longer used (was mathFuncTable). The
jpayne@69 1821 * unused space in interp was repurposed for
jpayne@69 1822 * pluggable bytecode optimizers. The core
jpayne@69 1823 * contains one optimizer, which can be
jpayne@69 1824 * selectively overridden by extensions. */
jpayne@69 1825 } extra;
jpayne@69 1826
jpayne@69 1827 /*
jpayne@69 1828 * Information related to procedures and variables. See tclProc.c and
jpayne@69 1829 * tclVar.c for usage.
jpayne@69 1830 */
jpayne@69 1831
jpayne@69 1832 int numLevels; /* Keeps track of how many nested calls to
jpayne@69 1833 * Tcl_Eval are in progress for this
jpayne@69 1834 * interpreter. It's used to delay deletion of
jpayne@69 1835 * the table until all Tcl_Eval invocations
jpayne@69 1836 * are completed. */
jpayne@69 1837 int maxNestingDepth; /* If numLevels exceeds this value then Tcl
jpayne@69 1838 * assumes that infinite recursion has
jpayne@69 1839 * occurred and it generates an error. */
jpayne@69 1840 CallFrame *framePtr; /* Points to top-most in stack of all nested
jpayne@69 1841 * procedure invocations. */
jpayne@69 1842 CallFrame *varFramePtr; /* Points to the call frame whose variables
jpayne@69 1843 * are currently in use (same as framePtr
jpayne@69 1844 * unless an "uplevel" command is
jpayne@69 1845 * executing). */
jpayne@69 1846 ActiveVarTrace *activeVarTracePtr;
jpayne@69 1847 /* First in list of active traces for interp,
jpayne@69 1848 * or NULL if no active traces. */
jpayne@69 1849 int returnCode; /* [return -code] parameter. */
jpayne@69 1850 CallFrame *rootFramePtr; /* Global frame pointer for this
jpayne@69 1851 * interpreter. */
jpayne@69 1852 Namespace *lookupNsPtr; /* Namespace to use ONLY on the next
jpayne@69 1853 * TCL_EVAL_INVOKE call to Tcl_EvalObjv. */
jpayne@69 1854
jpayne@69 1855 /*
jpayne@69 1856 * Information used by Tcl_AppendResult to keep track of partial results.
jpayne@69 1857 * See Tcl_AppendResult code for details.
jpayne@69 1858 */
jpayne@69 1859
jpayne@69 1860 char *appendResult; /* Storage space for results generated by
jpayne@69 1861 * Tcl_AppendResult. Ckalloc-ed. NULL means
jpayne@69 1862 * not yet allocated. */
jpayne@69 1863 int appendAvl; /* Total amount of space available at
jpayne@69 1864 * partialResult. */
jpayne@69 1865 int appendUsed; /* Number of non-null bytes currently stored
jpayne@69 1866 * at partialResult. */
jpayne@69 1867
jpayne@69 1868 /*
jpayne@69 1869 * Information about packages. Used only in tclPkg.c.
jpayne@69 1870 */
jpayne@69 1871
jpayne@69 1872 Tcl_HashTable packageTable; /* Describes all of the packages loaded in or
jpayne@69 1873 * available to this interpreter. Keys are
jpayne@69 1874 * package names, values are (Package *)
jpayne@69 1875 * pointers. */
jpayne@69 1876 char *packageUnknown; /* Command to invoke during "package require"
jpayne@69 1877 * commands for packages that aren't described
jpayne@69 1878 * in packageTable. Ckalloc'ed, may be
jpayne@69 1879 * NULL. */
jpayne@69 1880 /*
jpayne@69 1881 * Miscellaneous information:
jpayne@69 1882 */
jpayne@69 1883
jpayne@69 1884 int cmdCount; /* Total number of times a command procedure
jpayne@69 1885 * has been called for this interpreter. */
jpayne@69 1886 int evalFlags; /* Flags to control next call to Tcl_Eval.
jpayne@69 1887 * Normally zero, but may be set before
jpayne@69 1888 * calling Tcl_Eval. See below for valid
jpayne@69 1889 * values. */
jpayne@69 1890 int unused1; /* No longer used (was termOffset) */
jpayne@69 1891 LiteralTable literalTable; /* Contains LiteralEntry's describing all Tcl
jpayne@69 1892 * objects holding literals of scripts
jpayne@69 1893 * compiled by the interpreter. Indexed by the
jpayne@69 1894 * string representations of literals. Used to
jpayne@69 1895 * avoid creating duplicate objects. */
jpayne@69 1896 int compileEpoch; /* Holds the current "compilation epoch" for
jpayne@69 1897 * this interpreter. This is incremented to
jpayne@69 1898 * invalidate existing ByteCodes when, e.g., a
jpayne@69 1899 * command with a compile procedure is
jpayne@69 1900 * redefined. */
jpayne@69 1901 Proc *compiledProcPtr; /* If a procedure is being compiled, a pointer
jpayne@69 1902 * to its Proc structure; otherwise, this is
jpayne@69 1903 * NULL. Set by ObjInterpProc in tclProc.c and
jpayne@69 1904 * used by tclCompile.c to process local
jpayne@69 1905 * variables appropriately. */
jpayne@69 1906 ResolverScheme *resolverPtr;
jpayne@69 1907 /* Linked list of name resolution schemes
jpayne@69 1908 * added to this interpreter. Schemes are
jpayne@69 1909 * added and removed by calling
jpayne@69 1910 * Tcl_AddInterpResolvers and
jpayne@69 1911 * Tcl_RemoveInterpResolver respectively. */
jpayne@69 1912 Tcl_Obj *scriptFile; /* NULL means there is no nested source
jpayne@69 1913 * command active; otherwise this points to
jpayne@69 1914 * pathPtr of the file being sourced. */
jpayne@69 1915 int flags; /* Various flag bits. See below. */
jpayne@69 1916 long randSeed; /* Seed used for rand() function. */
jpayne@69 1917 Trace *tracePtr; /* List of traces for this interpreter. */
jpayne@69 1918 Tcl_HashTable *assocData; /* Hash table for associating data with this
jpayne@69 1919 * interpreter. Cleaned up when this
jpayne@69 1920 * interpreter is deleted. */
jpayne@69 1921 struct ExecEnv *execEnvPtr; /* Execution environment for Tcl bytecode
jpayne@69 1922 * execution. Contains a pointer to the Tcl
jpayne@69 1923 * evaluation stack. */
jpayne@69 1924 Tcl_Obj *emptyObjPtr; /* Points to an object holding an empty
jpayne@69 1925 * string. Returned by Tcl_ObjSetVar2 when
jpayne@69 1926 * variable traces change a variable in a
jpayne@69 1927 * gross way. */
jpayne@69 1928 char resultSpace[TCL_RESULT_SIZE+1];
jpayne@69 1929 /* Static space holding small results. */
jpayne@69 1930 Tcl_Obj *objResultPtr; /* If the last command returned an object
jpayne@69 1931 * result, this points to it. Should not be
jpayne@69 1932 * accessed directly; see comment above. */
jpayne@69 1933 Tcl_ThreadId threadId; /* ID of thread that owns the interpreter. */
jpayne@69 1934
jpayne@69 1935 ActiveCommandTrace *activeCmdTracePtr;
jpayne@69 1936 /* First in list of active command traces for
jpayne@69 1937 * interp, or NULL if no active traces. */
jpayne@69 1938 ActiveInterpTrace *activeInterpTracePtr;
jpayne@69 1939 /* First in list of active traces for interp,
jpayne@69 1940 * or NULL if no active traces. */
jpayne@69 1941
jpayne@69 1942 int tracesForbiddingInline; /* Count of traces (in the list headed by
jpayne@69 1943 * tracePtr) that forbid inline bytecode
jpayne@69 1944 * compilation. */
jpayne@69 1945
jpayne@69 1946 /*
jpayne@69 1947 * Fields used to manage extensible return options (TIP 90).
jpayne@69 1948 */
jpayne@69 1949
jpayne@69 1950 Tcl_Obj *returnOpts; /* A dictionary holding the options to the
jpayne@69 1951 * last [return] command. */
jpayne@69 1952
jpayne@69 1953 Tcl_Obj *errorInfo; /* errorInfo value (now as a Tcl_Obj). */
jpayne@69 1954 Tcl_Obj *eiVar; /* cached ref to ::errorInfo variable. */
jpayne@69 1955 Tcl_Obj *errorCode; /* errorCode value (now as a Tcl_Obj). */
jpayne@69 1956 Tcl_Obj *ecVar; /* cached ref to ::errorInfo variable. */
jpayne@69 1957 int returnLevel; /* [return -level] parameter. */
jpayne@69 1958
jpayne@69 1959 /*
jpayne@69 1960 * Resource limiting framework support (TIP#143).
jpayne@69 1961 */
jpayne@69 1962
jpayne@69 1963 struct {
jpayne@69 1964 int active; /* Flag values defining which limits have been
jpayne@69 1965 * set. */
jpayne@69 1966 int granularityTicker; /* Counter used to determine how often to
jpayne@69 1967 * check the limits. */
jpayne@69 1968 int exceeded; /* Which limits have been exceeded, described
jpayne@69 1969 * as flag values the same as the 'active'
jpayne@69 1970 * field. */
jpayne@69 1971
jpayne@69 1972 int cmdCount; /* Limit for how many commands to execute in
jpayne@69 1973 * the interpreter. */
jpayne@69 1974 LimitHandler *cmdHandlers;
jpayne@69 1975 /* Handlers to execute when the limit is
jpayne@69 1976 * reached. */
jpayne@69 1977 int cmdGranularity; /* Mod factor used to determine how often to
jpayne@69 1978 * evaluate the limit check. */
jpayne@69 1979
jpayne@69 1980 Tcl_Time time; /* Time limit for execution within the
jpayne@69 1981 * interpreter. */
jpayne@69 1982 LimitHandler *timeHandlers;
jpayne@69 1983 /* Handlers to execute when the limit is
jpayne@69 1984 * reached. */
jpayne@69 1985 int timeGranularity; /* Mod factor used to determine how often to
jpayne@69 1986 * evaluate the limit check. */
jpayne@69 1987 Tcl_TimerToken timeEvent;
jpayne@69 1988 /* Handle for a timer callback that will occur
jpayne@69 1989 * when the time-limit is exceeded. */
jpayne@69 1990
jpayne@69 1991 Tcl_HashTable callbacks;/* Mapping from (interp,type) pair to data
jpayne@69 1992 * used to install a limit handler callback to
jpayne@69 1993 * run in _this_ interp when the limit is
jpayne@69 1994 * exceeded. */
jpayne@69 1995 } limit;
jpayne@69 1996
jpayne@69 1997 /*
jpayne@69 1998 * Information for improved default error generation from ensembles
jpayne@69 1999 * (TIP#112).
jpayne@69 2000 */
jpayne@69 2001
jpayne@69 2002 struct {
jpayne@69 2003 Tcl_Obj *const *sourceObjs;
jpayne@69 2004 /* What arguments were actually input into the
jpayne@69 2005 * *root* ensemble command? (Nested ensembles
jpayne@69 2006 * don't rewrite this.) NULL if we're not
jpayne@69 2007 * processing an ensemble. */
jpayne@69 2008 int numRemovedObjs; /* How many arguments have been stripped off
jpayne@69 2009 * because of ensemble processing. */
jpayne@69 2010 int numInsertedObjs; /* How many of the current arguments were
jpayne@69 2011 * inserted by an ensemble. */
jpayne@69 2012 } ensembleRewrite;
jpayne@69 2013
jpayne@69 2014 /*
jpayne@69 2015 * TIP #219: Global info for the I/O system.
jpayne@69 2016 */
jpayne@69 2017
jpayne@69 2018 Tcl_Obj *chanMsg; /* Error message set by channel drivers, for
jpayne@69 2019 * the propagation of arbitrary Tcl errors.
jpayne@69 2020 * This information, if present (chanMsg not
jpayne@69 2021 * NULL), takes precedence over a POSIX error
jpayne@69 2022 * code returned by a channel operation. */
jpayne@69 2023
jpayne@69 2024 /*
jpayne@69 2025 * Source code origin information (TIP #280).
jpayne@69 2026 */
jpayne@69 2027
jpayne@69 2028 CmdFrame *cmdFramePtr; /* Points to the command frame containing the
jpayne@69 2029 * location information for the current
jpayne@69 2030 * command. */
jpayne@69 2031 const CmdFrame *invokeCmdFramePtr;
jpayne@69 2032 /* Points to the command frame which is the
jpayne@69 2033 * invoking context of the bytecode compiler.
jpayne@69 2034 * NULL when the byte code compiler is not
jpayne@69 2035 * active. */
jpayne@69 2036 int invokeWord; /* Index of the word in the command which
jpayne@69 2037 * is getting compiled. */
jpayne@69 2038 Tcl_HashTable *linePBodyPtr;/* This table remembers for each statically
jpayne@69 2039 * defined procedure the location information
jpayne@69 2040 * for its body. It is keyed by the address of
jpayne@69 2041 * the Proc structure for a procedure. The
jpayne@69 2042 * values are "struct CmdFrame*". */
jpayne@69 2043 Tcl_HashTable *lineBCPtr; /* This table remembers for each ByteCode
jpayne@69 2044 * object the location information for its
jpayne@69 2045 * body. It is keyed by the address of the
jpayne@69 2046 * Proc structure for a procedure. The values
jpayne@69 2047 * are "struct ExtCmdLoc*". (See
jpayne@69 2048 * tclCompile.h) */
jpayne@69 2049 Tcl_HashTable *lineLABCPtr;
jpayne@69 2050 Tcl_HashTable *lineLAPtr; /* This table remembers for each argument of a
jpayne@69 2051 * command on the execution stack the index of
jpayne@69 2052 * the argument in the command, and the
jpayne@69 2053 * location data of the command. It is keyed
jpayne@69 2054 * by the address of the Tcl_Obj containing
jpayne@69 2055 * the argument. The values are "struct
jpayne@69 2056 * CFWord*" (See tclBasic.c). This allows
jpayne@69 2057 * commands like uplevel, eval, etc. to find
jpayne@69 2058 * location information for their arguments,
jpayne@69 2059 * if they are a proper literal argument to an
jpayne@69 2060 * invoking command. Alt view: An index to the
jpayne@69 2061 * CmdFrame stack keyed by command argument
jpayne@69 2062 * holders. */
jpayne@69 2063 ContLineLoc *scriptCLLocPtr;/* This table points to the location data for
jpayne@69 2064 * invisible continuation lines in the script,
jpayne@69 2065 * if any. This pointer is set by the function
jpayne@69 2066 * TclEvalObjEx() in file "tclBasic.c", and
jpayne@69 2067 * used by function ...() in the same file.
jpayne@69 2068 * It does for the eval/direct path of script
jpayne@69 2069 * execution what CompileEnv.clLoc does for
jpayne@69 2070 * the bytecode compiler.
jpayne@69 2071 */
jpayne@69 2072 /*
jpayne@69 2073 * TIP #268. The currently active selection mode, i.e. the package require
jpayne@69 2074 * preferences.
jpayne@69 2075 */
jpayne@69 2076
jpayne@69 2077 int packagePrefer; /* Current package selection mode. */
jpayne@69 2078
jpayne@69 2079 /*
jpayne@69 2080 * Hashtables for variable traces and searches.
jpayne@69 2081 */
jpayne@69 2082
jpayne@69 2083 Tcl_HashTable varTraces; /* Hashtable holding the start of a variable's
jpayne@69 2084 * active trace list; varPtr is the key. */
jpayne@69 2085 Tcl_HashTable varSearches; /* Hashtable holding the start of a variable's
jpayne@69 2086 * active searches list; varPtr is the key. */
jpayne@69 2087 /*
jpayne@69 2088 * The thread-specific data ekeko: cache pointers or values that
jpayne@69 2089 * (a) do not change during the thread's lifetime
jpayne@69 2090 * (b) require access to TSD to determine at runtime
jpayne@69 2091 * (c) are accessed very often (e.g., at each command call)
jpayne@69 2092 *
jpayne@69 2093 * Note that these are the same for all interps in the same thread. They
jpayne@69 2094 * just have to be initialised for the thread's parent interp, children
jpayne@69 2095 * inherit the value.
jpayne@69 2096 *
jpayne@69 2097 * They are used by the macros defined below.
jpayne@69 2098 */
jpayne@69 2099
jpayne@69 2100 AllocCache *allocCache;
jpayne@69 2101 void *pendingObjDataPtr; /* Pointer to the Cache and PendingObjData
jpayne@69 2102 * structs for this interp's thread; see
jpayne@69 2103 * tclObj.c and tclThreadAlloc.c */
jpayne@69 2104 int *asyncReadyPtr; /* Pointer to the asyncReady indicator for
jpayne@69 2105 * this interp's thread; see tclAsync.c */
jpayne@69 2106 /*
jpayne@69 2107 * The pointer to the object system root ekeko. c.f. TIP #257.
jpayne@69 2108 */
jpayne@69 2109 void *objectFoundation; /* Pointer to the Foundation structure of the
jpayne@69 2110 * object system, which contains things like
jpayne@69 2111 * references to key namespaces. See
jpayne@69 2112 * tclOOInt.h and tclOO.c for real definition
jpayne@69 2113 * and setup. */
jpayne@69 2114
jpayne@69 2115 struct NRE_callback *deferredCallbacks;
jpayne@69 2116 /* Callbacks that are set previous to a call
jpayne@69 2117 * to some Eval function but that actually
jpayne@69 2118 * belong to the command that is about to be
jpayne@69 2119 * called - i.e., they should be run *before*
jpayne@69 2120 * any tailcall is invoked. */
jpayne@69 2121
jpayne@69 2122 /*
jpayne@69 2123 * TIP #285, Script cancellation support.
jpayne@69 2124 */
jpayne@69 2125
jpayne@69 2126 Tcl_AsyncHandler asyncCancel;
jpayne@69 2127 /* Async handler token for Tcl_CancelEval. */
jpayne@69 2128 Tcl_Obj *asyncCancelMsg; /* Error message set by async cancel handler
jpayne@69 2129 * for the propagation of arbitrary Tcl
jpayne@69 2130 * errors. This information, if present
jpayne@69 2131 * (asyncCancelMsg not NULL), takes precedence
jpayne@69 2132 * over the default error messages returned by
jpayne@69 2133 * a script cancellation operation. */
jpayne@69 2134
jpayne@69 2135 /*
jpayne@69 2136 * TIP #348 IMPLEMENTATION - Substituted error stack
jpayne@69 2137 */
jpayne@69 2138 Tcl_Obj *errorStack; /* [info errorstack] value (as a Tcl_Obj). */
jpayne@69 2139 Tcl_Obj *upLiteral; /* "UP" literal for [info errorstack] */
jpayne@69 2140 Tcl_Obj *callLiteral; /* "CALL" literal for [info errorstack] */
jpayne@69 2141 Tcl_Obj *innerLiteral; /* "INNER" literal for [info errorstack] */
jpayne@69 2142 Tcl_Obj *innerContext; /* cached list for fast reallocation */
jpayne@69 2143 int resetErrorStack; /* controls cleaning up of ::errorStack */
jpayne@69 2144
jpayne@69 2145 #ifdef TCL_COMPILE_STATS
jpayne@69 2146 /*
jpayne@69 2147 * Statistical information about the bytecode compiler and interpreter's
jpayne@69 2148 * operation. This should be the last field of Interp.
jpayne@69 2149 */
jpayne@69 2150
jpayne@69 2151 ByteCodeStats stats; /* Holds compilation and execution statistics
jpayne@69 2152 * for this interpreter. */
jpayne@69 2153 #endif /* TCL_COMPILE_STATS */
jpayne@69 2154 } Interp;
jpayne@69 2155
jpayne@69 2156 /*
jpayne@69 2157 * Macros that use the TSD-ekeko.
jpayne@69 2158 */
jpayne@69 2159
jpayne@69 2160 #define TclAsyncReady(iPtr) \
jpayne@69 2161 *((iPtr)->asyncReadyPtr)
jpayne@69 2162
jpayne@69 2163 /*
jpayne@69 2164 * Macros for script cancellation support (TIP #285).
jpayne@69 2165 */
jpayne@69 2166
jpayne@69 2167 #define TclCanceled(iPtr) \
jpayne@69 2168 (((iPtr)->flags & CANCELED) || ((iPtr)->flags & TCL_CANCEL_UNWIND))
jpayne@69 2169
jpayne@69 2170 #define TclSetCancelFlags(iPtr, cancelFlags) \
jpayne@69 2171 (iPtr)->flags |= CANCELED; \
jpayne@69 2172 if ((cancelFlags) & TCL_CANCEL_UNWIND) { \
jpayne@69 2173 (iPtr)->flags |= TCL_CANCEL_UNWIND; \
jpayne@69 2174 }
jpayne@69 2175
jpayne@69 2176 #define TclUnsetCancelFlags(iPtr) \
jpayne@69 2177 (iPtr)->flags &= (~(CANCELED | TCL_CANCEL_UNWIND))
jpayne@69 2178
jpayne@69 2179 /*
jpayne@69 2180 * Macros for splicing into and out of doubly linked lists. They assume
jpayne@69 2181 * existence of struct items 'prevPtr' and 'nextPtr'.
jpayne@69 2182 *
jpayne@69 2183 * a = element to add or remove.
jpayne@69 2184 * b = list head.
jpayne@69 2185 *
jpayne@69 2186 * TclSpliceIn adds to the head of the list.
jpayne@69 2187 */
jpayne@69 2188
jpayne@69 2189 #define TclSpliceIn(a,b) \
jpayne@69 2190 (a)->nextPtr = (b); \
jpayne@69 2191 if ((b) != NULL) { \
jpayne@69 2192 (b)->prevPtr = (a); \
jpayne@69 2193 } \
jpayne@69 2194 (a)->prevPtr = NULL, (b) = (a);
jpayne@69 2195
jpayne@69 2196 #define TclSpliceOut(a,b) \
jpayne@69 2197 if ((a)->prevPtr != NULL) { \
jpayne@69 2198 (a)->prevPtr->nextPtr = (a)->nextPtr; \
jpayne@69 2199 } else { \
jpayne@69 2200 (b) = (a)->nextPtr; \
jpayne@69 2201 } \
jpayne@69 2202 if ((a)->nextPtr != NULL) { \
jpayne@69 2203 (a)->nextPtr->prevPtr = (a)->prevPtr; \
jpayne@69 2204 }
jpayne@69 2205
jpayne@69 2206 /*
jpayne@69 2207 * EvalFlag bits for Interp structures:
jpayne@69 2208 *
jpayne@69 2209 * TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with a
jpayne@69 2210 * code other than TCL_OK or TCL_ERROR; 0 means codes
jpayne@69 2211 * other than these should be turned into errors.
jpayne@69 2212 */
jpayne@69 2213
jpayne@69 2214 #define TCL_ALLOW_EXCEPTIONS 0x04
jpayne@69 2215 #define TCL_EVAL_FILE 0x02
jpayne@69 2216 #define TCL_EVAL_SOURCE_IN_FRAME 0x10
jpayne@69 2217 #define TCL_EVAL_NORESOLVE 0x20
jpayne@69 2218 #define TCL_EVAL_DISCARD_RESULT 0x40
jpayne@69 2219
jpayne@69 2220 /*
jpayne@69 2221 * Flag bits for Interp structures:
jpayne@69 2222 *
jpayne@69 2223 * DELETED: Non-zero means the interpreter has been deleted:
jpayne@69 2224 * don't process any more commands for it, and destroy
jpayne@69 2225 * the structure as soon as all nested invocations of
jpayne@69 2226 * Tcl_Eval are done.
jpayne@69 2227 * ERR_ALREADY_LOGGED: Non-zero means information has already been logged in
jpayne@69 2228 * iPtr->errorInfo for the current Tcl_Eval instance, so
jpayne@69 2229 * Tcl_Eval needn't log it (used to implement the "error
jpayne@69 2230 * message log" command).
jpayne@69 2231 * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler should
jpayne@69 2232 * not compile any commands into an inline sequence of
jpayne@69 2233 * instructions. This is set 1, for example, when command
jpayne@69 2234 * traces are requested.
jpayne@69 2235 * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the interp
jpayne@69 2236 * has not be initialized. This is set 1 when we first
jpayne@69 2237 * use the rand() or srand() functions.
jpayne@69 2238 * SAFE_INTERP: Non zero means that the current interp is a safe
jpayne@69 2239 * interp (i.e. it has only the safe commands installed,
jpayne@69 2240 * less privilege than a regular interp).
jpayne@69 2241 * INTERP_DEBUG_FRAME: Used for switching on various extra interpreter
jpayne@69 2242 * debug/info mechanisms (e.g. info frame eval/uplevel
jpayne@69 2243 * tracing) which are performance intensive.
jpayne@69 2244 * INTERP_TRACE_IN_PROGRESS: Non-zero means that an interp trace is currently
jpayne@69 2245 * active; so no further trace callbacks should be
jpayne@69 2246 * invoked.
jpayne@69 2247 * INTERP_ALTERNATE_WRONG_ARGS: Used for listing second and subsequent forms
jpayne@69 2248 * of the wrong-num-args string in Tcl_WrongNumArgs.
jpayne@69 2249 * Makes it append instead of replacing and uses
jpayne@69 2250 * different intermediate text.
jpayne@69 2251 * CANCELED: Non-zero means that the script in progress should be
jpayne@69 2252 * canceled as soon as possible. This can be checked by
jpayne@69 2253 * extensions (and the core itself) by calling
jpayne@69 2254 * Tcl_Canceled and checking if TCL_ERROR is returned.
jpayne@69 2255 * This is a one-shot flag that is reset immediately upon
jpayne@69 2256 * being detected; however, if the TCL_CANCEL_UNWIND flag
jpayne@69 2257 * is set Tcl_Canceled will continue to report that the
jpayne@69 2258 * script in progress has been canceled thereby allowing
jpayne@69 2259 * the evaluation stack for the interp to be fully
jpayne@69 2260 * unwound.
jpayne@69 2261 *
jpayne@69 2262 * WARNING: For the sake of some extensions that have made use of former
jpayne@69 2263 * internal values, do not re-use the flag values 2 (formerly ERR_IN_PROGRESS)
jpayne@69 2264 * or 8 (formerly ERROR_CODE_SET).
jpayne@69 2265 */
jpayne@69 2266
jpayne@69 2267 #define DELETED 1
jpayne@69 2268 #define ERR_ALREADY_LOGGED 4
jpayne@69 2269 #define INTERP_DEBUG_FRAME 0x10
jpayne@69 2270 #define DONT_COMPILE_CMDS_INLINE 0x20
jpayne@69 2271 #define RAND_SEED_INITIALIZED 0x40
jpayne@69 2272 #define SAFE_INTERP 0x80
jpayne@69 2273 #define INTERP_TRACE_IN_PROGRESS 0x200
jpayne@69 2274 #define INTERP_ALTERNATE_WRONG_ARGS 0x400
jpayne@69 2275 #define ERR_LEGACY_COPY 0x800
jpayne@69 2276 #define CANCELED 0x1000
jpayne@69 2277
jpayne@69 2278 /*
jpayne@69 2279 * Maximum number of levels of nesting permitted in Tcl commands (used to
jpayne@69 2280 * catch infinite recursion).
jpayne@69 2281 */
jpayne@69 2282
jpayne@69 2283 #define MAX_NESTING_DEPTH 1000
jpayne@69 2284
jpayne@69 2285 /*
jpayne@69 2286 * The macro below is used to modify a "char" value (e.g. by casting it to an
jpayne@69 2287 * unsigned character) so that it can be used safely with macros such as
jpayne@69 2288 * isspace.
jpayne@69 2289 */
jpayne@69 2290
jpayne@69 2291 #define UCHAR(c) ((unsigned char) (c))
jpayne@69 2292
jpayne@69 2293 /*
jpayne@69 2294 * This macro is used to properly align the memory allocated by Tcl, giving
jpayne@69 2295 * the same alignment as the native malloc.
jpayne@69 2296 */
jpayne@69 2297
jpayne@69 2298 #if defined(__APPLE__)
jpayne@69 2299 #define TCL_ALLOCALIGN 16
jpayne@69 2300 #else
jpayne@69 2301 #define TCL_ALLOCALIGN (2*sizeof(void *))
jpayne@69 2302 #endif
jpayne@69 2303
jpayne@69 2304 /*
jpayne@69 2305 * This macro is used to determine the offset needed to safely allocate any
jpayne@69 2306 * data structure in memory. Given a starting offset or size, it "rounds up"
jpayne@69 2307 * or "aligns" the offset to the next 8-byte boundary so that any data
jpayne@69 2308 * structure can be placed at the resulting offset without fear of an
jpayne@69 2309 * alignment error.
jpayne@69 2310 *
jpayne@69 2311 * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce the
jpayne@69 2312 * wrong result on platforms that allocate addresses that are divisible by 4
jpayne@69 2313 * or 2. Only use it for offsets or sizes.
jpayne@69 2314 *
jpayne@69 2315 * This macro is only used by tclCompile.c in the core (Bug 926445). It
jpayne@69 2316 * however not be made file static, as extensions that touch bytecodes
jpayne@69 2317 * (notably tbcload) require it.
jpayne@69 2318 */
jpayne@69 2319
jpayne@69 2320 #define TCL_ALIGN(x) (((int)(x) + 7) & ~7)
jpayne@69 2321
jpayne@69 2322 /*
jpayne@69 2323 * The following enum values are used to specify the runtime platform setting
jpayne@69 2324 * of the tclPlatform variable.
jpayne@69 2325 */
jpayne@69 2326
jpayne@69 2327 typedef enum {
jpayne@69 2328 TCL_PLATFORM_UNIX = 0, /* Any Unix-like OS. */
jpayne@69 2329 TCL_PLATFORM_WINDOWS = 2 /* Any Microsoft Windows OS. */
jpayne@69 2330 } TclPlatformType;
jpayne@69 2331
jpayne@69 2332 /*
jpayne@69 2333 * The following enum values are used to indicate the translation of a Tcl
jpayne@69 2334 * channel. Declared here so that each platform can define
jpayne@69 2335 * TCL_PLATFORM_TRANSLATION to the native translation on that platform.
jpayne@69 2336 */
jpayne@69 2337
jpayne@69 2338 typedef enum TclEolTranslation {
jpayne@69 2339 TCL_TRANSLATE_AUTO, /* Eol == \r, \n and \r\n. */
jpayne@69 2340 TCL_TRANSLATE_CR, /* Eol == \r. */
jpayne@69 2341 TCL_TRANSLATE_LF, /* Eol == \n. */
jpayne@69 2342 TCL_TRANSLATE_CRLF /* Eol == \r\n. */
jpayne@69 2343 } TclEolTranslation;
jpayne@69 2344
jpayne@69 2345 /*
jpayne@69 2346 * Flags for TclInvoke:
jpayne@69 2347 *
jpayne@69 2348 * TCL_INVOKE_HIDDEN Invoke a hidden command; if not set, invokes
jpayne@69 2349 * an exposed command.
jpayne@69 2350 * TCL_INVOKE_NO_UNKNOWN If set, "unknown" is not invoked if the
jpayne@69 2351 * command to be invoked is not found. Only has
jpayne@69 2352 * an effect if invoking an exposed command,
jpayne@69 2353 * i.e. if TCL_INVOKE_HIDDEN is not also set.
jpayne@69 2354 * TCL_INVOKE_NO_TRACEBACK Does not record traceback information if the
jpayne@69 2355 * invoked command returns an error. Used if the
jpayne@69 2356 * caller plans on recording its own traceback
jpayne@69 2357 * information.
jpayne@69 2358 */
jpayne@69 2359
jpayne@69 2360 #define TCL_INVOKE_HIDDEN (1<<0)
jpayne@69 2361 #define TCL_INVOKE_NO_UNKNOWN (1<<1)
jpayne@69 2362 #define TCL_INVOKE_NO_TRACEBACK (1<<2)
jpayne@69 2363
jpayne@69 2364 /*
jpayne@69 2365 * The structure used as the internal representation of Tcl list objects. This
jpayne@69 2366 * struct is grown (reallocated and copied) as necessary to hold all the
jpayne@69 2367 * list's element pointers. The struct might contain more slots than currently
jpayne@69 2368 * used to hold all element pointers. This is done to make append operations
jpayne@69 2369 * faster.
jpayne@69 2370 */
jpayne@69 2371
jpayne@69 2372 typedef struct List {
jpayne@69 2373 int refCount;
jpayne@69 2374 int maxElemCount; /* Total number of element array slots. */
jpayne@69 2375 int elemCount; /* Current number of list elements. */
jpayne@69 2376 int canonicalFlag; /* Set if the string representation was
jpayne@69 2377 * derived from the list representation. May
jpayne@69 2378 * be ignored if there is no string rep at
jpayne@69 2379 * all.*/
jpayne@69 2380 Tcl_Obj *elements; /* First list element; the struct is grown to
jpayne@69 2381 * accommodate all elements. */
jpayne@69 2382 } List;
jpayne@69 2383
jpayne@69 2384 #define LIST_MAX \
jpayne@69 2385 (1 + (int)(((size_t)UINT_MAX - sizeof(List))/sizeof(Tcl_Obj *)))
jpayne@69 2386 #define LIST_SIZE(numElems) \
jpayne@69 2387 (unsigned)(sizeof(List) + (((numElems) - 1) * sizeof(Tcl_Obj *)))
jpayne@69 2388
jpayne@69 2389 /*
jpayne@69 2390 * Macro used to get the elements of a list object.
jpayne@69 2391 */
jpayne@69 2392
jpayne@69 2393 #define ListRepPtr(listPtr) \
jpayne@69 2394 ((List *) (listPtr)->internalRep.twoPtrValue.ptr1)
jpayne@69 2395
jpayne@69 2396 /* Not used any more */
jpayne@69 2397 #define ListSetIntRep(objPtr, listRepPtr) \
jpayne@69 2398 (objPtr)->internalRep.twoPtrValue.ptr1 = (void *)(listRepPtr), \
jpayne@69 2399 (objPtr)->internalRep.twoPtrValue.ptr2 = NULL, \
jpayne@69 2400 (listRepPtr)->refCount++, \
jpayne@69 2401 (objPtr)->typePtr = &tclListType
jpayne@69 2402
jpayne@69 2403 #define ListObjGetElements(listPtr, objc, objv) \
jpayne@69 2404 ((objv) = &(ListRepPtr(listPtr)->elements), \
jpayne@69 2405 (objc) = ListRepPtr(listPtr)->elemCount)
jpayne@69 2406
jpayne@69 2407 #define ListObjLength(listPtr, len) \
jpayne@69 2408 ((len) = ListRepPtr(listPtr)->elemCount)
jpayne@69 2409
jpayne@69 2410 #define ListObjIsCanonical(listPtr) \
jpayne@69 2411 (((listPtr)->bytes == NULL) || ListRepPtr(listPtr)->canonicalFlag)
jpayne@69 2412
jpayne@69 2413 #define TclListObjGetElements(interp, listPtr, objcPtr, objvPtr) \
jpayne@69 2414 (((listPtr)->typePtr == &tclListType) \
jpayne@69 2415 ? ((ListObjGetElements((listPtr), *(objcPtr), *(objvPtr))), TCL_OK)\
jpayne@69 2416 : Tcl_ListObjGetElements((interp), (listPtr), (objcPtr), (objvPtr)))
jpayne@69 2417
jpayne@69 2418 #define TclListObjLength(interp, listPtr, lenPtr) \
jpayne@69 2419 (((listPtr)->typePtr == &tclListType) \
jpayne@69 2420 ? ((ListObjLength((listPtr), *(lenPtr))), TCL_OK)\
jpayne@69 2421 : Tcl_ListObjLength((interp), (listPtr), (lenPtr)))
jpayne@69 2422
jpayne@69 2423 #define TclListObjIsCanonical(listPtr) \
jpayne@69 2424 (((listPtr)->typePtr == &tclListType) ? ListObjIsCanonical((listPtr)) : 0)
jpayne@69 2425
jpayne@69 2426 /*
jpayne@69 2427 * Modes for collecting (or not) in the implementations of TclNRForeachCmd,
jpayne@69 2428 * TclNRLmapCmd and their compilations.
jpayne@69 2429 */
jpayne@69 2430
jpayne@69 2431 #define TCL_EACH_KEEP_NONE 0 /* Discard iteration result like [foreach] */
jpayne@69 2432 #define TCL_EACH_COLLECT 1 /* Collect iteration result like [lmap] */
jpayne@69 2433
jpayne@69 2434 /*
jpayne@69 2435 * Macros providing a faster path to integers: Tcl_GetLongFromObj,
jpayne@69 2436 * Tcl_GetIntFromObj and TclGetIntForIndex.
jpayne@69 2437 *
jpayne@69 2438 * WARNING: these macros eval their args more than once.
jpayne@69 2439 */
jpayne@69 2440
jpayne@69 2441 #define TclGetLongFromObj(interp, objPtr, longPtr) \
jpayne@69 2442 (((objPtr)->typePtr == &tclIntType) \
jpayne@69 2443 ? ((*(longPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
jpayne@69 2444 : Tcl_GetLongFromObj((interp), (objPtr), (longPtr)))
jpayne@69 2445
jpayne@69 2446 #if (LONG_MAX == INT_MAX)
jpayne@69 2447 #define TclGetIntFromObj(interp, objPtr, intPtr) \
jpayne@69 2448 (((objPtr)->typePtr == &tclIntType) \
jpayne@69 2449 ? ((*(intPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
jpayne@69 2450 : Tcl_GetIntFromObj((interp), (objPtr), (intPtr)))
jpayne@69 2451 #define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \
jpayne@69 2452 (((objPtr)->typePtr == &tclIntType) \
jpayne@69 2453 ? ((*(idxPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
jpayne@69 2454 : TclGetIntForIndex((interp), (objPtr), (endValue), (idxPtr)))
jpayne@69 2455 #else
jpayne@69 2456 #define TclGetIntFromObj(interp, objPtr, intPtr) \
jpayne@69 2457 (((objPtr)->typePtr == &tclIntType \
jpayne@69 2458 && (objPtr)->internalRep.longValue >= -(Tcl_WideInt)(UINT_MAX) \
jpayne@69 2459 && (objPtr)->internalRep.longValue <= (Tcl_WideInt)(UINT_MAX)) \
jpayne@69 2460 ? ((*(intPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
jpayne@69 2461 : Tcl_GetIntFromObj((interp), (objPtr), (intPtr)))
jpayne@69 2462 #define TclGetIntForIndexM(interp, objPtr, endValue, idxPtr) \
jpayne@69 2463 (((objPtr)->typePtr == &tclIntType \
jpayne@69 2464 && (objPtr)->internalRep.longValue >= INT_MIN \
jpayne@69 2465 && (objPtr)->internalRep.longValue <= INT_MAX) \
jpayne@69 2466 ? ((*(idxPtr) = (objPtr)->internalRep.longValue), TCL_OK) \
jpayne@69 2467 : TclGetIntForIndex((interp), (objPtr), (endValue), (idxPtr)))
jpayne@69 2468 #endif
jpayne@69 2469
jpayne@69 2470 /*
jpayne@69 2471 * Macro used to save a function call for common uses of
jpayne@69 2472 * Tcl_GetWideIntFromObj(). The ANSI C "prototype" is:
jpayne@69 2473 *
jpayne@69 2474 * MODULE_SCOPE int TclGetWideIntFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
jpayne@69 2475 * Tcl_WideInt *wideIntPtr);
jpayne@69 2476 */
jpayne@69 2477
jpayne@69 2478 #ifdef TCL_WIDE_INT_IS_LONG
jpayne@69 2479 #define TclGetWideIntFromObj(interp, objPtr, wideIntPtr) \
jpayne@69 2480 (((objPtr)->typePtr == &tclIntType) \
jpayne@69 2481 ? (*(wideIntPtr) = (Tcl_WideInt) \
jpayne@69 2482 ((objPtr)->internalRep.longValue), TCL_OK) : \
jpayne@69 2483 Tcl_GetWideIntFromObj((interp), (objPtr), (wideIntPtr)))
jpayne@69 2484 #else /* !TCL_WIDE_INT_IS_LONG */
jpayne@69 2485 #define TclGetWideIntFromObj(interp, objPtr, wideIntPtr) \
jpayne@69 2486 (((objPtr)->typePtr == &tclWideIntType) \
jpayne@69 2487 ? (*(wideIntPtr) = (objPtr)->internalRep.wideValue, TCL_OK) : \
jpayne@69 2488 ((objPtr)->typePtr == &tclIntType) \
jpayne@69 2489 ? (*(wideIntPtr) = (Tcl_WideInt) \
jpayne@69 2490 ((objPtr)->internalRep.longValue), TCL_OK) : \
jpayne@69 2491 Tcl_GetWideIntFromObj((interp), (objPtr), (wideIntPtr)))
jpayne@69 2492 #endif /* TCL_WIDE_INT_IS_LONG */
jpayne@69 2493
jpayne@69 2494 /*
jpayne@69 2495 * Flag values for TclTraceDictPath().
jpayne@69 2496 *
jpayne@69 2497 * DICT_PATH_READ indicates that all entries on the path must exist but no
jpayne@69 2498 * updates will be needed.
jpayne@69 2499 *
jpayne@69 2500 * DICT_PATH_UPDATE indicates that we are going to be doing an update at the
jpayne@69 2501 * tip of the path, so duplication of shared objects should be done along the
jpayne@69 2502 * way.
jpayne@69 2503 *
jpayne@69 2504 * DICT_PATH_EXISTS indicates that we are performing an existence test and a
jpayne@69 2505 * lookup failure should therefore not be an error. If (and only if) this flag
jpayne@69 2506 * is set, TclTraceDictPath() will return the special value
jpayne@69 2507 * DICT_PATH_NON_EXISTENT if the path is not traceable.
jpayne@69 2508 *
jpayne@69 2509 * DICT_PATH_CREATE (which also requires the DICT_PATH_UPDATE bit to be set)
jpayne@69 2510 * indicates that we are to create non-existent dictionaries on the path.
jpayne@69 2511 */
jpayne@69 2512
jpayne@69 2513 #define DICT_PATH_READ 0
jpayne@69 2514 #define DICT_PATH_UPDATE 1
jpayne@69 2515 #define DICT_PATH_EXISTS 2
jpayne@69 2516 #define DICT_PATH_CREATE 5
jpayne@69 2517
jpayne@69 2518 #define DICT_PATH_NON_EXISTENT ((Tcl_Obj *) (void *) 1)
jpayne@69 2519
jpayne@69 2520 /*
jpayne@69 2521 *----------------------------------------------------------------
jpayne@69 2522 * Data structures related to the filesystem internals
jpayne@69 2523 *----------------------------------------------------------------
jpayne@69 2524 */
jpayne@69 2525
jpayne@69 2526 /*
jpayne@69 2527 * The version_2 filesystem is private to Tcl. As and when these changes have
jpayne@69 2528 * been thoroughly tested and investigated a new public filesystem interface
jpayne@69 2529 * will be released. The aim is more versatile virtual filesystem interfaces,
jpayne@69 2530 * more efficiency in 'path' manipulation and usage, and cleaner filesystem
jpayne@69 2531 * code internally.
jpayne@69 2532 */
jpayne@69 2533
jpayne@69 2534 #define TCL_FILESYSTEM_VERSION_2 ((Tcl_FSVersion) 0x2)
jpayne@69 2535 typedef ClientData (TclFSGetCwdProc2)(ClientData clientData);
jpayne@69 2536 typedef int (Tcl_FSLoadFileProc2) (Tcl_Interp *interp, Tcl_Obj *pathPtr,
jpayne@69 2537 Tcl_LoadHandle *handlePtr, Tcl_FSUnloadFileProc **unloadProcPtr, int flags);
jpayne@69 2538
jpayne@69 2539 /*
jpayne@69 2540 * The following types are used for getting and storing platform-specific file
jpayne@69 2541 * attributes in tclFCmd.c and the various platform-versions of that file.
jpayne@69 2542 * This is done to have as much common code as possible in the file attributes
jpayne@69 2543 * code. For more information about the callbacks, see TclFileAttrsCmd in
jpayne@69 2544 * tclFCmd.c.
jpayne@69 2545 */
jpayne@69 2546
jpayne@69 2547 typedef int (TclGetFileAttrProc)(Tcl_Interp *interp, int objIndex,
jpayne@69 2548 Tcl_Obj *fileName, Tcl_Obj **attrObjPtrPtr);
jpayne@69 2549 typedef int (TclSetFileAttrProc)(Tcl_Interp *interp, int objIndex,
jpayne@69 2550 Tcl_Obj *fileName, Tcl_Obj *attrObjPtr);
jpayne@69 2551
jpayne@69 2552 typedef struct TclFileAttrProcs {
jpayne@69 2553 TclGetFileAttrProc *getProc;/* The procedure for getting attrs. */
jpayne@69 2554 TclSetFileAttrProc *setProc;/* The procedure for setting attrs. */
jpayne@69 2555 } TclFileAttrProcs;
jpayne@69 2556
jpayne@69 2557 /*
jpayne@69 2558 * Opaque handle used in pipeline routines to encapsulate platform-dependent
jpayne@69 2559 * state.
jpayne@69 2560 */
jpayne@69 2561
jpayne@69 2562 typedef struct TclFile_ *TclFile;
jpayne@69 2563
jpayne@69 2564 /*
jpayne@69 2565 * The "globParameters" argument of the function TclGlob is an or'ed
jpayne@69 2566 * combination of the following values:
jpayne@69 2567 */
jpayne@69 2568
jpayne@69 2569 #define TCL_GLOBMODE_NO_COMPLAIN 1
jpayne@69 2570 #define TCL_GLOBMODE_JOIN 2
jpayne@69 2571 #define TCL_GLOBMODE_DIR 4
jpayne@69 2572 #define TCL_GLOBMODE_TAILS 8
jpayne@69 2573
jpayne@69 2574 typedef enum Tcl_PathPart {
jpayne@69 2575 TCL_PATH_DIRNAME,
jpayne@69 2576 TCL_PATH_TAIL,
jpayne@69 2577 TCL_PATH_EXTENSION,
jpayne@69 2578 TCL_PATH_ROOT
jpayne@69 2579 } Tcl_PathPart;
jpayne@69 2580
jpayne@69 2581 /*
jpayne@69 2582 *----------------------------------------------------------------
jpayne@69 2583 * Data structures related to obsolete filesystem hooks
jpayne@69 2584 *----------------------------------------------------------------
jpayne@69 2585 */
jpayne@69 2586
jpayne@69 2587 typedef int (TclStatProc_)(const char *path, struct stat *buf);
jpayne@69 2588 typedef int (TclAccessProc_)(const char *path, int mode);
jpayne@69 2589 typedef Tcl_Channel (TclOpenFileChannelProc_)(Tcl_Interp *interp,
jpayne@69 2590 const char *fileName, const char *modeString, int permissions);
jpayne@69 2591
jpayne@69 2592 /*
jpayne@69 2593 *----------------------------------------------------------------
jpayne@69 2594 * Data structures related to procedures
jpayne@69 2595 *----------------------------------------------------------------
jpayne@69 2596 */
jpayne@69 2597
jpayne@69 2598 typedef Tcl_CmdProc *TclCmdProcType;
jpayne@69 2599 typedef Tcl_ObjCmdProc *TclObjCmdProcType;
jpayne@69 2600
jpayne@69 2601 /*
jpayne@69 2602 *----------------------------------------------------------------
jpayne@69 2603 * Data structures for process-global values.
jpayne@69 2604 *----------------------------------------------------------------
jpayne@69 2605 */
jpayne@69 2606
jpayne@69 2607 typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, int *lengthPtr,
jpayne@69 2608 Tcl_Encoding *encodingPtr);
jpayne@69 2609
jpayne@69 2610 /*
jpayne@69 2611 * A ProcessGlobalValue struct exists for each internal value in Tcl that is
jpayne@69 2612 * to be shared among several threads. Each thread sees a (Tcl_Obj) copy of
jpayne@69 2613 * the value, and the gobal value is kept as a counted string, with epoch and
jpayne@69 2614 * mutex control. Each ProcessGlobalValue struct should be a static variable in
jpayne@69 2615 * some file.
jpayne@69 2616 */
jpayne@69 2617
jpayne@69 2618 typedef struct ProcessGlobalValue {
jpayne@69 2619 int epoch; /* Epoch counter to detect changes in the
jpayne@69 2620 * global value. */
jpayne@69 2621 int numBytes; /* Length of the global string. */
jpayne@69 2622 char *value; /* The global string value. */
jpayne@69 2623 Tcl_Encoding encoding; /* system encoding when global string was
jpayne@69 2624 * initialized. */
jpayne@69 2625 TclInitProcessGlobalValueProc *proc;
jpayne@69 2626 /* A procedure to initialize the global string
jpayne@69 2627 * copy when a "get" request comes in before
jpayne@69 2628 * any "set" request has been received. */
jpayne@69 2629 Tcl_Mutex mutex; /* Enforce orderly access from multiple
jpayne@69 2630 * threads. */
jpayne@69 2631 Tcl_ThreadDataKey key; /* Key for per-thread data holding the
jpayne@69 2632 * (Tcl_Obj) copy for each thread. */
jpayne@69 2633 } ProcessGlobalValue;
jpayne@69 2634
jpayne@69 2635 /*
jpayne@69 2636 *----------------------------------------------------------------------
jpayne@69 2637 * Flags for TclParseNumber
jpayne@69 2638 *----------------------------------------------------------------------
jpayne@69 2639 */
jpayne@69 2640
jpayne@69 2641 #define TCL_PARSE_DECIMAL_ONLY 1
jpayne@69 2642 /* Leading zero doesn't denote octal or
jpayne@69 2643 * hex. */
jpayne@69 2644 #define TCL_PARSE_OCTAL_ONLY 2
jpayne@69 2645 /* Parse octal even without prefix. */
jpayne@69 2646 #define TCL_PARSE_HEXADECIMAL_ONLY 4
jpayne@69 2647 /* Parse hexadecimal even without prefix. */
jpayne@69 2648 #define TCL_PARSE_INTEGER_ONLY 8
jpayne@69 2649 /* Disable floating point parsing. */
jpayne@69 2650 #define TCL_PARSE_SCAN_PREFIXES 16
jpayne@69 2651 /* Use [scan] rules dealing with 0?
jpayne@69 2652 * prefixes. */
jpayne@69 2653 #define TCL_PARSE_NO_WHITESPACE 32
jpayne@69 2654 /* Reject leading/trailing whitespace. */
jpayne@69 2655 #define TCL_PARSE_BINARY_ONLY 64
jpayne@69 2656 /* Parse binary even without prefix. */
jpayne@69 2657
jpayne@69 2658 /*
jpayne@69 2659 *----------------------------------------------------------------------
jpayne@69 2660 * Type values TclGetNumberFromObj
jpayne@69 2661 *----------------------------------------------------------------------
jpayne@69 2662 */
jpayne@69 2663
jpayne@69 2664 #define TCL_NUMBER_LONG 1
jpayne@69 2665 #define TCL_NUMBER_WIDE 2
jpayne@69 2666 #define TCL_NUMBER_BIG 3
jpayne@69 2667 #define TCL_NUMBER_DOUBLE 4
jpayne@69 2668 #define TCL_NUMBER_NAN 5
jpayne@69 2669
jpayne@69 2670 /*
jpayne@69 2671 *----------------------------------------------------------------
jpayne@69 2672 * Variables shared among Tcl modules but not used by the outside world.
jpayne@69 2673 *----------------------------------------------------------------
jpayne@69 2674 */
jpayne@69 2675
jpayne@69 2676 MODULE_SCOPE char *tclNativeExecutableName;
jpayne@69 2677 MODULE_SCOPE int tclFindExecutableSearchDone;
jpayne@69 2678 MODULE_SCOPE char *tclMemDumpFileName;
jpayne@69 2679 MODULE_SCOPE TclPlatformType tclPlatform;
jpayne@69 2680 MODULE_SCOPE Tcl_NotifierProcs tclNotifierHooks;
jpayne@69 2681
jpayne@69 2682 MODULE_SCOPE Tcl_Encoding tclIdentityEncoding;
jpayne@69 2683
jpayne@69 2684 /*
jpayne@69 2685 * TIP #233 (Virtualized Time)
jpayne@69 2686 * Data for the time hooks, if any.
jpayne@69 2687 */
jpayne@69 2688
jpayne@69 2689 MODULE_SCOPE Tcl_GetTimeProc *tclGetTimeProcPtr;
jpayne@69 2690 MODULE_SCOPE Tcl_ScaleTimeProc *tclScaleTimeProcPtr;
jpayne@69 2691 MODULE_SCOPE ClientData tclTimeClientData;
jpayne@69 2692
jpayne@69 2693 /*
jpayne@69 2694 * Variables denoting the Tcl object types defined in the core.
jpayne@69 2695 */
jpayne@69 2696
jpayne@69 2697 MODULE_SCOPE const Tcl_ObjType tclBignumType;
jpayne@69 2698 MODULE_SCOPE const Tcl_ObjType tclBooleanType;
jpayne@69 2699 MODULE_SCOPE const Tcl_ObjType tclByteArrayType;
jpayne@69 2700 MODULE_SCOPE const Tcl_ObjType tclByteCodeType;
jpayne@69 2701 MODULE_SCOPE const Tcl_ObjType tclDoubleType;
jpayne@69 2702 MODULE_SCOPE const Tcl_ObjType tclEndOffsetType;
jpayne@69 2703 MODULE_SCOPE const Tcl_ObjType tclIntType;
jpayne@69 2704 MODULE_SCOPE const Tcl_ObjType tclListType;
jpayne@69 2705 MODULE_SCOPE const Tcl_ObjType tclDictType;
jpayne@69 2706 MODULE_SCOPE const Tcl_ObjType tclProcBodyType;
jpayne@69 2707 MODULE_SCOPE const Tcl_ObjType tclStringType;
jpayne@69 2708 MODULE_SCOPE const Tcl_ObjType tclArraySearchType;
jpayne@69 2709 MODULE_SCOPE const Tcl_ObjType tclEnsembleCmdType;
jpayne@69 2710 #ifndef TCL_WIDE_INT_IS_LONG
jpayne@69 2711 MODULE_SCOPE const Tcl_ObjType tclWideIntType;
jpayne@69 2712 #endif
jpayne@69 2713 MODULE_SCOPE const Tcl_ObjType tclRegexpType;
jpayne@69 2714 MODULE_SCOPE Tcl_ObjType tclCmdNameType;
jpayne@69 2715
jpayne@69 2716 /*
jpayne@69 2717 * Variables denoting the hash key types defined in the core.
jpayne@69 2718 */
jpayne@69 2719
jpayne@69 2720 MODULE_SCOPE const Tcl_HashKeyType tclArrayHashKeyType;
jpayne@69 2721 MODULE_SCOPE const Tcl_HashKeyType tclOneWordHashKeyType;
jpayne@69 2722 MODULE_SCOPE const Tcl_HashKeyType tclStringHashKeyType;
jpayne@69 2723 MODULE_SCOPE const Tcl_HashKeyType tclObjHashKeyType;
jpayne@69 2724
jpayne@69 2725 /*
jpayne@69 2726 * The head of the list of free Tcl objects, and the total number of Tcl
jpayne@69 2727 * objects ever allocated and freed.
jpayne@69 2728 */
jpayne@69 2729
jpayne@69 2730 MODULE_SCOPE Tcl_Obj * tclFreeObjList;
jpayne@69 2731
jpayne@69 2732 #ifdef TCL_COMPILE_STATS
jpayne@69 2733 MODULE_SCOPE long tclObjsAlloced;
jpayne@69 2734 MODULE_SCOPE long tclObjsFreed;
jpayne@69 2735 #define TCL_MAX_SHARED_OBJ_STATS 5
jpayne@69 2736 MODULE_SCOPE long tclObjsShared[TCL_MAX_SHARED_OBJ_STATS];
jpayne@69 2737 #endif /* TCL_COMPILE_STATS */
jpayne@69 2738
jpayne@69 2739 /*
jpayne@69 2740 * Pointer to a heap-allocated string of length zero that the Tcl core uses as
jpayne@69 2741 * the value of an empty string representation for an object. This value is
jpayne@69 2742 * shared by all new objects allocated by Tcl_NewObj.
jpayne@69 2743 */
jpayne@69 2744
jpayne@69 2745 MODULE_SCOPE char * tclEmptyStringRep;
jpayne@69 2746 MODULE_SCOPE char tclEmptyString;
jpayne@69 2747
jpayne@69 2748 enum CheckEmptyStringResult {
jpayne@69 2749 TCL_EMPTYSTRING_UNKNOWN = -1, TCL_EMPTYSTRING_NO, TCL_EMPTYSTRING_YES
jpayne@69 2750 };
jpayne@69 2751
jpayne@69 2752 /*
jpayne@69 2753 *----------------------------------------------------------------
jpayne@69 2754 * Procedures shared among Tcl modules but not used by the outside world,
jpayne@69 2755 * introduced by/for NRE.
jpayne@69 2756 *----------------------------------------------------------------
jpayne@69 2757 */
jpayne@69 2758
jpayne@69 2759 MODULE_SCOPE Tcl_ObjCmdProc TclNRApplyObjCmd;
jpayne@69 2760 MODULE_SCOPE Tcl_ObjCmdProc TclNREvalObjCmd;
jpayne@69 2761 MODULE_SCOPE Tcl_ObjCmdProc TclNRCatchObjCmd;
jpayne@69 2762 MODULE_SCOPE Tcl_ObjCmdProc TclNRExprObjCmd;
jpayne@69 2763 MODULE_SCOPE Tcl_ObjCmdProc TclNRForObjCmd;
jpayne@69 2764 MODULE_SCOPE Tcl_ObjCmdProc TclNRForeachCmd;
jpayne@69 2765 MODULE_SCOPE Tcl_ObjCmdProc TclNRIfObjCmd;
jpayne@69 2766 MODULE_SCOPE Tcl_ObjCmdProc TclNRLmapCmd;
jpayne@69 2767 MODULE_SCOPE Tcl_ObjCmdProc TclNRPackageObjCmd;
jpayne@69 2768 MODULE_SCOPE Tcl_ObjCmdProc TclNRSourceObjCmd;
jpayne@69 2769 MODULE_SCOPE Tcl_ObjCmdProc TclNRSubstObjCmd;
jpayne@69 2770 MODULE_SCOPE Tcl_ObjCmdProc TclNRSwitchObjCmd;
jpayne@69 2771 MODULE_SCOPE Tcl_ObjCmdProc TclNRTryObjCmd;
jpayne@69 2772 MODULE_SCOPE Tcl_ObjCmdProc TclNRUplevelObjCmd;
jpayne@69 2773 MODULE_SCOPE Tcl_ObjCmdProc TclNRWhileObjCmd;
jpayne@69 2774
jpayne@69 2775 MODULE_SCOPE Tcl_NRPostProc TclNRForIterCallback;
jpayne@69 2776 MODULE_SCOPE Tcl_NRPostProc TclNRCoroutineActivateCallback;
jpayne@69 2777 MODULE_SCOPE Tcl_ObjCmdProc TclNRTailcallObjCmd;
jpayne@69 2778 MODULE_SCOPE Tcl_NRPostProc TclNRTailcallEval;
jpayne@69 2779 MODULE_SCOPE Tcl_ObjCmdProc TclNRCoroutineObjCmd;
jpayne@69 2780 MODULE_SCOPE Tcl_ObjCmdProc TclNRYieldObjCmd;
jpayne@69 2781 MODULE_SCOPE Tcl_ObjCmdProc TclNRYieldmObjCmd;
jpayne@69 2782 MODULE_SCOPE Tcl_ObjCmdProc TclNRYieldToObjCmd;
jpayne@69 2783 MODULE_SCOPE Tcl_ObjCmdProc TclNRInvoke;
jpayne@69 2784 MODULE_SCOPE Tcl_NRPostProc TclNRReleaseValues;
jpayne@69 2785
jpayne@69 2786 MODULE_SCOPE void TclSetTailcall(Tcl_Interp *interp, Tcl_Obj *tailcallPtr);
jpayne@69 2787 MODULE_SCOPE void TclPushTailcallPoint(Tcl_Interp *interp);
jpayne@69 2788
jpayne@69 2789 /* These two can be considered for the public api */
jpayne@69 2790 MODULE_SCOPE void TclMarkTailcall(Tcl_Interp *interp);
jpayne@69 2791 MODULE_SCOPE void TclSkipTailcall(Tcl_Interp *interp);
jpayne@69 2792
jpayne@69 2793 /*
jpayne@69 2794 * This structure holds the data for the various iteration callbacks used to
jpayne@69 2795 * NRE the 'for' and 'while' commands. We need a separate structure because we
jpayne@69 2796 * have more than the 4 client data entries we can provide directly thorugh
jpayne@69 2797 * the callback API. It is the 'word' information which puts us over the
jpayne@69 2798 * limit. It is needed because the loop body is argument 4 of 'for' and
jpayne@69 2799 * argument 2 of 'while'. Not providing the correct index confuses the #280
jpayne@69 2800 * code. We TclSmallAlloc/Free this.
jpayne@69 2801 */
jpayne@69 2802
jpayne@69 2803 typedef struct ForIterData {
jpayne@69 2804 Tcl_Obj *cond; /* Loop condition expression. */
jpayne@69 2805 Tcl_Obj *body; /* Loop body. */
jpayne@69 2806 Tcl_Obj *next; /* Loop step script, NULL for 'while'. */
jpayne@69 2807 const char *msg; /* Error message part. */
jpayne@69 2808 int word; /* Index of the body script in the command */
jpayne@69 2809 } ForIterData;
jpayne@69 2810
jpayne@69 2811 /* TIP #357 - Structure doing the bookkeeping of handles for Tcl_LoadFile
jpayne@69 2812 * and Tcl_FindSymbol. This structure corresponds to an opaque
jpayne@69 2813 * typedef in tcl.h */
jpayne@69 2814
jpayne@69 2815 typedef void* TclFindSymbolProc(Tcl_Interp* interp, Tcl_LoadHandle loadHandle,
jpayne@69 2816 const char* symbol);
jpayne@69 2817 struct Tcl_LoadHandle_ {
jpayne@69 2818 ClientData clientData; /* Client data is the load handle in the
jpayne@69 2819 * native filesystem if a module was loaded
jpayne@69 2820 * there, or an opaque pointer to a structure
jpayne@69 2821 * for further bookkeeping on load-from-VFS
jpayne@69 2822 * and load-from-memory */
jpayne@69 2823 TclFindSymbolProc* findSymbolProcPtr;
jpayne@69 2824 /* Procedure that resolves symbols in a
jpayne@69 2825 * loaded module */
jpayne@69 2826 Tcl_FSUnloadFileProc* unloadFileProcPtr;
jpayne@69 2827 /* Procedure that unloads a loaded module */
jpayne@69 2828 };
jpayne@69 2829
jpayne@69 2830 /* Flags for conversion of doubles to digit strings */
jpayne@69 2831
jpayne@69 2832 #define TCL_DD_SHORTEST 0x4
jpayne@69 2833 /* Use the shortest possible string */
jpayne@69 2834 #define TCL_DD_STEELE 0x5
jpayne@69 2835 /* Use the original Steele&White algorithm */
jpayne@69 2836 #define TCL_DD_E_FORMAT 0x2
jpayne@69 2837 /* Use a fixed-length string of digits,
jpayne@69 2838 * suitable for E format*/
jpayne@69 2839 #define TCL_DD_F_FORMAT 0x3
jpayne@69 2840 /* Use a fixed number of digits after the
jpayne@69 2841 * decimal point, suitable for F format */
jpayne@69 2842
jpayne@69 2843 #define TCL_DD_SHORTEN_FLAG 0x4
jpayne@69 2844 /* Allow return of a shorter digit string
jpayne@69 2845 * if it converts losslessly */
jpayne@69 2846 #define TCL_DD_NO_QUICK 0x8
jpayne@69 2847 /* Debug flag: forbid quick FP conversion */
jpayne@69 2848
jpayne@69 2849 #define TCL_DD_CONVERSION_TYPE_MASK 0x3
jpayne@69 2850 /* Mask to isolate the conversion type */
jpayne@69 2851 #define TCL_DD_STEELE0 0x1
jpayne@69 2852 /* 'Steele&White' after masking */
jpayne@69 2853 #define TCL_DD_SHORTEST0 0x0
jpayne@69 2854 /* 'Shortest possible' after masking */
jpayne@69 2855
jpayne@69 2856 /*
jpayne@69 2857 *----------------------------------------------------------------
jpayne@69 2858 * Procedures shared among Tcl modules but not used by the outside world:
jpayne@69 2859 *----------------------------------------------------------------
jpayne@69 2860 */
jpayne@69 2861
jpayne@69 2862 MODULE_SCOPE void TclAppendBytesToByteArray(Tcl_Obj *objPtr,
jpayne@69 2863 const unsigned char *bytes, int len);
jpayne@69 2864 MODULE_SCOPE int TclNREvalCmd(Tcl_Interp *interp, Tcl_Obj *objPtr,
jpayne@69 2865 int flags);
jpayne@69 2866 MODULE_SCOPE void TclAdvanceContinuations(int *line, int **next,
jpayne@69 2867 int loc);
jpayne@69 2868 MODULE_SCOPE void TclAdvanceLines(int *line, const char *start,
jpayne@69 2869 const char *end);
jpayne@69 2870 MODULE_SCOPE void TclArgumentEnter(Tcl_Interp *interp,
jpayne@69 2871 Tcl_Obj *objv[], int objc, CmdFrame *cf);
jpayne@69 2872 MODULE_SCOPE void TclArgumentRelease(Tcl_Interp *interp,
jpayne@69 2873 Tcl_Obj *objv[], int objc);
jpayne@69 2874 MODULE_SCOPE void TclArgumentBCEnter(Tcl_Interp *interp,
jpayne@69 2875 Tcl_Obj *objv[], int objc,
jpayne@69 2876 void *codePtr, CmdFrame *cfPtr, int cmd, int pc);
jpayne@69 2877 MODULE_SCOPE void TclArgumentBCRelease(Tcl_Interp *interp,
jpayne@69 2878 CmdFrame *cfPtr);
jpayne@69 2879 MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj,
jpayne@69 2880 CmdFrame **cfPtrPtr, int *wordPtr);
jpayne@69 2881 MODULE_SCOPE double TclBignumToDouble(const mp_int *bignum);
jpayne@69 2882 MODULE_SCOPE int TclByteArrayMatch(const unsigned char *string,
jpayne@69 2883 int strLen, const unsigned char *pattern,
jpayne@69 2884 int ptnLen, int flags);
jpayne@69 2885 MODULE_SCOPE double TclCeil(const mp_int *a);
jpayne@69 2886 MODULE_SCOPE void TclChannelPreserve(Tcl_Channel chan);
jpayne@69 2887 MODULE_SCOPE void TclChannelRelease(Tcl_Channel chan);
jpayne@69 2888 MODULE_SCOPE int TclCheckArrayTraces(Tcl_Interp *interp, Var *varPtr,
jpayne@69 2889 Var *arrayPtr, Tcl_Obj *name, int index);
jpayne@69 2890 MODULE_SCOPE int TclCheckBadOctal(Tcl_Interp *interp,
jpayne@69 2891 const char *value);
jpayne@69 2892 MODULE_SCOPE int TclCheckEmptyString(Tcl_Obj *objPtr);
jpayne@69 2893 MODULE_SCOPE int TclChanCaughtErrorBypass(Tcl_Interp *interp,
jpayne@69 2894 Tcl_Channel chan);
jpayne@69 2895 MODULE_SCOPE Tcl_ObjCmdProc TclChannelNamesCmd;
jpayne@69 2896 MODULE_SCOPE Tcl_NRPostProc TclClearRootEnsemble;
jpayne@69 2897 MODULE_SCOPE ContLineLoc *TclContinuationsEnter(Tcl_Obj *objPtr, int num,
jpayne@69 2898 int *loc);
jpayne@69 2899 MODULE_SCOPE void TclContinuationsEnterDerived(Tcl_Obj *objPtr,
jpayne@69 2900 int start, int *clNext);
jpayne@69 2901 MODULE_SCOPE ContLineLoc *TclContinuationsGet(Tcl_Obj *objPtr);
jpayne@69 2902 MODULE_SCOPE void TclContinuationsCopy(Tcl_Obj *objPtr,
jpayne@69 2903 Tcl_Obj *originObjPtr);
jpayne@69 2904 MODULE_SCOPE int TclConvertElement(const char *src, int length,
jpayne@69 2905 char *dst, int flags);
jpayne@69 2906 MODULE_SCOPE Tcl_Command TclCreateObjCommandInNs (
jpayne@69 2907 Tcl_Interp *interp,
jpayne@69 2908 const char *cmdName,
jpayne@69 2909 Tcl_Namespace *nsPtr,
jpayne@69 2910 Tcl_ObjCmdProc *proc,
jpayne@69 2911 ClientData clientData,
jpayne@69 2912 Tcl_CmdDeleteProc *deleteProc);
jpayne@69 2913 MODULE_SCOPE Tcl_Command TclCreateEnsembleInNs(
jpayne@69 2914 Tcl_Interp *interp,
jpayne@69 2915 const char *name,
jpayne@69 2916 Tcl_Namespace *nameNamespacePtr,
jpayne@69 2917 Tcl_Namespace *ensembleNamespacePtr,
jpayne@69 2918 int flags);
jpayne@69 2919 MODULE_SCOPE void TclDeleteNamespaceVars(Namespace *nsPtr);
jpayne@69 2920 MODULE_SCOPE int TclFindDictElement(Tcl_Interp *interp,
jpayne@69 2921 const char *dict, int dictLength,
jpayne@69 2922 const char **elementPtr, const char **nextPtr,
jpayne@69 2923 int *sizePtr, int *literalPtr);
jpayne@69 2924 /* TIP #280 - Modified token based evulation, with line information. */
jpayne@69 2925 MODULE_SCOPE int TclEvalEx(Tcl_Interp *interp, const char *script,
jpayne@69 2926 int numBytes, int flags, int line,
jpayne@69 2927 int *clNextOuter, const char *outerScript);
jpayne@69 2928 MODULE_SCOPE Tcl_ObjCmdProc TclFileAttrsCmd;
jpayne@69 2929 MODULE_SCOPE Tcl_ObjCmdProc TclFileCopyCmd;
jpayne@69 2930 MODULE_SCOPE Tcl_ObjCmdProc TclFileDeleteCmd;
jpayne@69 2931 MODULE_SCOPE Tcl_ObjCmdProc TclFileLinkCmd;
jpayne@69 2932 MODULE_SCOPE Tcl_ObjCmdProc TclFileMakeDirsCmd;
jpayne@69 2933 MODULE_SCOPE Tcl_ObjCmdProc TclFileReadLinkCmd;
jpayne@69 2934 MODULE_SCOPE Tcl_ObjCmdProc TclFileRenameCmd;
jpayne@69 2935 MODULE_SCOPE Tcl_ObjCmdProc TclFileTemporaryCmd;
jpayne@69 2936 MODULE_SCOPE void TclCreateLateExitHandler(Tcl_ExitProc *proc,
jpayne@69 2937 ClientData clientData);
jpayne@69 2938 MODULE_SCOPE void TclDeleteLateExitHandler(Tcl_ExitProc *proc,
jpayne@69 2939 ClientData clientData);
jpayne@69 2940 MODULE_SCOPE char * TclDStringAppendObj(Tcl_DString *dsPtr,
jpayne@69 2941 Tcl_Obj *objPtr);
jpayne@69 2942 MODULE_SCOPE char * TclDStringAppendDString(Tcl_DString *dsPtr,
jpayne@69 2943 Tcl_DString *toAppendPtr);
jpayne@69 2944 MODULE_SCOPE Tcl_Obj * TclDStringToObj(Tcl_DString *dsPtr);
jpayne@69 2945 MODULE_SCOPE Tcl_Obj *const * TclFetchEnsembleRoot(Tcl_Interp *interp,
jpayne@69 2946 Tcl_Obj *const *objv, int objc, int *objcPtr);
jpayne@69 2947 MODULE_SCOPE Tcl_Obj *const *TclEnsembleGetRewriteValues(Tcl_Interp *interp);
jpayne@69 2948 MODULE_SCOPE Tcl_Namespace *TclEnsureNamespace(Tcl_Interp *interp,
jpayne@69 2949 Tcl_Namespace *namespacePtr);
jpayne@69 2950
jpayne@69 2951 MODULE_SCOPE void TclFinalizeAllocSubsystem(void);
jpayne@69 2952 MODULE_SCOPE void TclFinalizeAsync(void);
jpayne@69 2953 MODULE_SCOPE void TclFinalizeDoubleConversion(void);
jpayne@69 2954 MODULE_SCOPE void TclFinalizeEncodingSubsystem(void);
jpayne@69 2955 MODULE_SCOPE void TclFinalizeEnvironment(void);
jpayne@69 2956 MODULE_SCOPE void TclFinalizeEvaluation(void);
jpayne@69 2957 MODULE_SCOPE void TclFinalizeExecution(void);
jpayne@69 2958 MODULE_SCOPE void TclFinalizeIOSubsystem(void);
jpayne@69 2959 MODULE_SCOPE void TclFinalizeFilesystem(void);
jpayne@69 2960 MODULE_SCOPE void TclResetFilesystem(void);
jpayne@69 2961 MODULE_SCOPE void TclFinalizeLoad(void);
jpayne@69 2962 MODULE_SCOPE void TclFinalizeLock(void);
jpayne@69 2963 MODULE_SCOPE void TclFinalizeMemorySubsystem(void);
jpayne@69 2964 MODULE_SCOPE void TclFinalizeNotifier(void);
jpayne@69 2965 MODULE_SCOPE void TclFinalizeObjects(void);
jpayne@69 2966 MODULE_SCOPE void TclFinalizePreserve(void);
jpayne@69 2967 MODULE_SCOPE void TclFinalizeSynchronization(void);
jpayne@69 2968 MODULE_SCOPE void TclFinalizeThreadAlloc(void);
jpayne@69 2969 MODULE_SCOPE void TclFinalizeThreadAllocThread(void);
jpayne@69 2970 MODULE_SCOPE void TclFinalizeThreadData(int quick);
jpayne@69 2971 MODULE_SCOPE void TclFinalizeThreadObjects(void);
jpayne@69 2972 MODULE_SCOPE double TclFloor(const mp_int *a);
jpayne@69 2973 MODULE_SCOPE void TclFormatNaN(double value, char *buffer);
jpayne@69 2974 MODULE_SCOPE int TclFSFileAttrIndex(Tcl_Obj *pathPtr,
jpayne@69 2975 const char *attributeName, int *indexPtr);
jpayne@69 2976 MODULE_SCOPE Tcl_Command TclNRCreateCommandInNs (
jpayne@69 2977 Tcl_Interp *interp,
jpayne@69 2978 const char *cmdName,
jpayne@69 2979 Tcl_Namespace *nsPtr,
jpayne@69 2980 Tcl_ObjCmdProc *proc,
jpayne@69 2981 Tcl_ObjCmdProc *nreProc,
jpayne@69 2982 ClientData clientData,
jpayne@69 2983 Tcl_CmdDeleteProc *deleteProc);
jpayne@69 2984
jpayne@69 2985 MODULE_SCOPE int TclNREvalFile(Tcl_Interp *interp, Tcl_Obj *pathPtr,
jpayne@69 2986 const char *encodingName);
jpayne@69 2987 MODULE_SCOPE void TclFSUnloadTempFile(Tcl_LoadHandle loadHandle);
jpayne@69 2988 MODULE_SCOPE int * TclGetAsyncReadyPtr(void);
jpayne@69 2989 MODULE_SCOPE Tcl_Obj * TclGetBgErrorHandler(Tcl_Interp *interp);
jpayne@69 2990 MODULE_SCOPE int TclGetChannelFromObj(Tcl_Interp *interp,
jpayne@69 2991 Tcl_Obj *objPtr, Tcl_Channel *chanPtr,
jpayne@69 2992 int *modePtr, int flags);
jpayne@69 2993 MODULE_SCOPE CmdFrame * TclGetCmdFrameForProcedure(Proc *procPtr);
jpayne@69 2994 MODULE_SCOPE int TclGetCompletionCodeFromObj(Tcl_Interp *interp,
jpayne@69 2995 Tcl_Obj *value, int *code);
jpayne@69 2996 MODULE_SCOPE int TclGetNumberFromObj(Tcl_Interp *interp,
jpayne@69 2997 Tcl_Obj *objPtr, ClientData *clientDataPtr,
jpayne@69 2998 int *typePtr);
jpayne@69 2999 MODULE_SCOPE int TclGetOpenModeEx(Tcl_Interp *interp,
jpayne@69 3000 const char *modeString, int *seekFlagPtr,
jpayne@69 3001 int *binaryPtr);
jpayne@69 3002 MODULE_SCOPE Tcl_Obj * TclGetProcessGlobalValue(ProcessGlobalValue *pgvPtr);
jpayne@69 3003 MODULE_SCOPE Tcl_Obj * TclGetSourceFromFrame(CmdFrame *cfPtr, int objc,
jpayne@69 3004 Tcl_Obj *const objv[]);
jpayne@69 3005 MODULE_SCOPE char * TclGetStringStorage(Tcl_Obj *objPtr,
jpayne@69 3006 unsigned int *sizePtr);
jpayne@69 3007 MODULE_SCOPE int TclGlob(Tcl_Interp *interp, char *pattern,
jpayne@69 3008 Tcl_Obj *unquotedPrefix, int globFlags,
jpayne@69 3009 Tcl_GlobTypeData *types);
jpayne@69 3010 MODULE_SCOPE int TclIncrObj(Tcl_Interp *interp, Tcl_Obj *valuePtr,
jpayne@69 3011 Tcl_Obj *incrPtr);
jpayne@69 3012 MODULE_SCOPE Tcl_Obj * TclIncrObjVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr,
jpayne@69 3013 Tcl_Obj *part2Ptr, Tcl_Obj *incrPtr, int flags);
jpayne@69 3014 MODULE_SCOPE int TclInfoExistsCmd(ClientData dummy, Tcl_Interp *interp,
jpayne@69 3015 int objc, Tcl_Obj *const objv[]);
jpayne@69 3016 MODULE_SCOPE int TclInfoCoroutineCmd(ClientData dummy, Tcl_Interp *interp,
jpayne@69 3017 int objc, Tcl_Obj *const objv[]);
jpayne@69 3018 MODULE_SCOPE Tcl_Obj * TclInfoFrame(Tcl_Interp *interp, CmdFrame *framePtr);
jpayne@69 3019 MODULE_SCOPE int TclInfoGlobalsCmd(ClientData dummy, Tcl_Interp *interp,
jpayne@69 3020 int objc, Tcl_Obj *const objv[]);
jpayne@69 3021 MODULE_SCOPE int TclInfoLocalsCmd(ClientData dummy, Tcl_Interp *interp,
jpayne@69 3022 int objc, Tcl_Obj *const objv[]);
jpayne@69 3023 MODULE_SCOPE int TclInfoVarsCmd(ClientData dummy, Tcl_Interp *interp,
jpayne@69 3024 int objc, Tcl_Obj *const objv[]);
jpayne@69 3025 MODULE_SCOPE void TclInitAlloc(void);
jpayne@69 3026 MODULE_SCOPE void TclInitDbCkalloc(void);
jpayne@69 3027 MODULE_SCOPE void TclInitDoubleConversion(void);
jpayne@69 3028 MODULE_SCOPE void TclInitEmbeddedConfigurationInformation(
jpayne@69 3029 Tcl_Interp *interp);
jpayne@69 3030 MODULE_SCOPE void TclInitEncodingSubsystem(void);
jpayne@69 3031 MODULE_SCOPE void TclInitIOSubsystem(void);
jpayne@69 3032 MODULE_SCOPE void TclInitLimitSupport(Tcl_Interp *interp);
jpayne@69 3033 MODULE_SCOPE void TclInitNamespaceSubsystem(void);
jpayne@69 3034 MODULE_SCOPE void TclInitNotifier(void);
jpayne@69 3035 MODULE_SCOPE void TclInitObjSubsystem(void);
jpayne@69 3036 MODULE_SCOPE const char *TclInitSubsystems(void);
jpayne@69 3037 MODULE_SCOPE int TclInterpReady(Tcl_Interp *interp);
jpayne@69 3038 MODULE_SCOPE int TclIsBareword(int byte);
jpayne@69 3039 MODULE_SCOPE Tcl_Obj * TclJoinPath(int elements, Tcl_Obj * const objv[],
jpayne@69 3040 int forceRelative);
jpayne@69 3041 MODULE_SCOPE int TclJoinThread(Tcl_ThreadId id, int *result);
jpayne@69 3042 MODULE_SCOPE void TclLimitRemoveAllHandlers(Tcl_Interp *interp);
jpayne@69 3043 MODULE_SCOPE Tcl_Obj * TclLindexList(Tcl_Interp *interp,
jpayne@69 3044 Tcl_Obj *listPtr, Tcl_Obj *argPtr);
jpayne@69 3045 MODULE_SCOPE Tcl_Obj * TclLindexFlat(Tcl_Interp *interp, Tcl_Obj *listPtr,
jpayne@69 3046 int indexCount, Tcl_Obj *const indexArray[]);
jpayne@69 3047 /* TIP #280 */
jpayne@69 3048 MODULE_SCOPE void TclListLines(Tcl_Obj *listObj, int line, int n,
jpayne@69 3049 int *lines, Tcl_Obj *const *elems);
jpayne@69 3050 MODULE_SCOPE Tcl_Obj * TclListObjCopy(Tcl_Interp *interp, Tcl_Obj *listPtr);
jpayne@69 3051 MODULE_SCOPE Tcl_Obj * TclLsetList(Tcl_Interp *interp, Tcl_Obj *listPtr,
jpayne@69 3052 Tcl_Obj *indexPtr, Tcl_Obj *valuePtr);
jpayne@69 3053 MODULE_SCOPE Tcl_Obj * TclLsetFlat(Tcl_Interp *interp, Tcl_Obj *listPtr,
jpayne@69 3054 int indexCount, Tcl_Obj *const indexArray[],
jpayne@69 3055 Tcl_Obj *valuePtr);
jpayne@69 3056 MODULE_SCOPE Tcl_Command TclMakeEnsemble(Tcl_Interp *interp, const char *name,
jpayne@69 3057 const EnsembleImplMap map[]);
jpayne@69 3058 MODULE_SCOPE int TclMaxListLength(const char *bytes, int numBytes,
jpayne@69 3059 const char **endPtr);
jpayne@69 3060 MODULE_SCOPE int TclMergeReturnOptions(Tcl_Interp *interp, int objc,
jpayne@69 3061 Tcl_Obj *const objv[], Tcl_Obj **optionsPtrPtr,
jpayne@69 3062 int *codePtr, int *levelPtr);
jpayne@69 3063 MODULE_SCOPE Tcl_Obj * TclNoErrorStack(Tcl_Interp *interp, Tcl_Obj *options);
jpayne@69 3064 MODULE_SCOPE int TclNokia770Doubles(void);
jpayne@69 3065 MODULE_SCOPE void TclNsDecrRefCount(Namespace *nsPtr);
jpayne@69 3066 MODULE_SCOPE void TclNsDecrRefCount(Namespace *nsPtr);
jpayne@69 3067 MODULE_SCOPE int TclNamespaceDeleted(Namespace *nsPtr);
jpayne@69 3068 MODULE_SCOPE void TclObjVarErrMsg(Tcl_Interp *interp, Tcl_Obj *part1Ptr,
jpayne@69 3069 Tcl_Obj *part2Ptr, const char *operation,
jpayne@69 3070 const char *reason, int index);
jpayne@69 3071 MODULE_SCOPE int TclObjInvokeNamespace(Tcl_Interp *interp,
jpayne@69 3072 int objc, Tcl_Obj *const objv[],
jpayne@69 3073 Tcl_Namespace *nsPtr, int flags);
jpayne@69 3074 MODULE_SCOPE int TclObjUnsetVar2(Tcl_Interp *interp,
jpayne@69 3075 Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags);
jpayne@69 3076 MODULE_SCOPE int TclParseBackslash(const char *src,
jpayne@69 3077 int numBytes, int *readPtr, char *dst);
jpayne@69 3078 MODULE_SCOPE int TclParseNumber(Tcl_Interp *interp, Tcl_Obj *objPtr,
jpayne@69 3079 const char *expected, const char *bytes,
jpayne@69 3080 int numBytes, const char **endPtrPtr, int flags);
jpayne@69 3081 MODULE_SCOPE void TclParseInit(Tcl_Interp *interp, const char *string,
jpayne@69 3082 int numBytes, Tcl_Parse *parsePtr);
jpayne@69 3083 MODULE_SCOPE int TclParseAllWhiteSpace(const char *src, int numBytes);
jpayne@69 3084 MODULE_SCOPE int TclProcessReturn(Tcl_Interp *interp,
jpayne@69 3085 int code, int level, Tcl_Obj *returnOpts);
jpayne@69 3086 MODULE_SCOPE int TclpObjLstat(Tcl_Obj *pathPtr, Tcl_StatBuf *buf);
jpayne@69 3087 MODULE_SCOPE Tcl_Obj * TclpTempFileName(void);
jpayne@69 3088 MODULE_SCOPE Tcl_Obj * TclpTempFileNameForLibrary(Tcl_Interp *interp, Tcl_Obj* pathPtr);
jpayne@69 3089 MODULE_SCOPE Tcl_Obj * TclNewFSPathObj(Tcl_Obj *dirPtr, const char *addStrRep,
jpayne@69 3090 int len);
jpayne@69 3091 MODULE_SCOPE int TclpDeleteFile(const void *path);
jpayne@69 3092 MODULE_SCOPE void TclpFinalizeCondition(Tcl_Condition *condPtr);
jpayne@69 3093 MODULE_SCOPE void TclpFinalizeMutex(Tcl_Mutex *mutexPtr);
jpayne@69 3094 MODULE_SCOPE void TclpFinalizePipes(void);
jpayne@69 3095 MODULE_SCOPE void TclpFinalizeSockets(void);
jpayne@69 3096 MODULE_SCOPE int TclCreateSocketAddress(Tcl_Interp *interp,
jpayne@69 3097 struct addrinfo **addrlist,
jpayne@69 3098 const char *host, int port, int willBind,
jpayne@69 3099 const char **errorMsgPtr);
jpayne@69 3100 MODULE_SCOPE int TclpThreadCreate(Tcl_ThreadId *idPtr,
jpayne@69 3101 Tcl_ThreadCreateProc *proc, ClientData clientData,
jpayne@69 3102 int stackSize, int flags);
jpayne@69 3103 MODULE_SCOPE int TclpFindVariable(const char *name, int *lengthPtr);
jpayne@69 3104 MODULE_SCOPE void TclpInitLibraryPath(char **valuePtr,
jpayne@69 3105 int *lengthPtr, Tcl_Encoding *encodingPtr);
jpayne@69 3106 MODULE_SCOPE void TclpInitLock(void);
jpayne@69 3107 MODULE_SCOPE void TclpInitPlatform(void);
jpayne@69 3108 MODULE_SCOPE void TclpInitUnlock(void);
jpayne@69 3109 MODULE_SCOPE Tcl_Obj * TclpObjListVolumes(void);
jpayne@69 3110 MODULE_SCOPE void TclpGlobalLock(void);
jpayne@69 3111 MODULE_SCOPE void TclpGlobalUnlock(void);
jpayne@69 3112 MODULE_SCOPE int TclpMatchFiles(Tcl_Interp *interp, char *separators,
jpayne@69 3113 Tcl_DString *dirPtr, char *pattern, char *tail);
jpayne@69 3114 MODULE_SCOPE int TclpObjNormalizePath(Tcl_Interp *interp,
jpayne@69 3115 Tcl_Obj *pathPtr, int nextCheckpoint);
jpayne@69 3116 MODULE_SCOPE void TclpNativeJoinPath(Tcl_Obj *prefix, const char *joining);
jpayne@69 3117 MODULE_SCOPE Tcl_Obj * TclpNativeSplitPath(Tcl_Obj *pathPtr, int *lenPtr);
jpayne@69 3118 MODULE_SCOPE Tcl_PathType TclpGetNativePathType(Tcl_Obj *pathPtr,
jpayne@69 3119 int *driveNameLengthPtr, Tcl_Obj **driveNameRef);
jpayne@69 3120 MODULE_SCOPE int TclCrossFilesystemCopy(Tcl_Interp *interp,
jpayne@69 3121 Tcl_Obj *source, Tcl_Obj *target);
jpayne@69 3122 MODULE_SCOPE int TclpMatchInDirectory(Tcl_Interp *interp,
jpayne@69 3123 Tcl_Obj *resultPtr, Tcl_Obj *pathPtr,
jpayne@69 3124 const char *pattern, Tcl_GlobTypeData *types);
jpayne@69 3125 MODULE_SCOPE ClientData TclpGetNativeCwd(ClientData clientData);
jpayne@69 3126 MODULE_SCOPE Tcl_FSDupInternalRepProc TclNativeDupInternalRep;
jpayne@69 3127 MODULE_SCOPE Tcl_Obj * TclpObjLink(Tcl_Obj *pathPtr, Tcl_Obj *toPtr,
jpayne@69 3128 int linkType);
jpayne@69 3129 MODULE_SCOPE int TclpObjChdir(Tcl_Obj *pathPtr);
jpayne@69 3130 MODULE_SCOPE Tcl_Channel TclpOpenTemporaryFile(Tcl_Obj *dirObj,
jpayne@69 3131 Tcl_Obj *basenameObj, Tcl_Obj *extensionObj,
jpayne@69 3132 Tcl_Obj *resultingNameObj);
jpayne@69 3133 MODULE_SCOPE Tcl_Obj * TclPathPart(Tcl_Interp *interp, Tcl_Obj *pathPtr,
jpayne@69 3134 Tcl_PathPart portion);
jpayne@69 3135 MODULE_SCOPE char * TclpReadlink(const char *fileName,
jpayne@69 3136 Tcl_DString *linkPtr);
jpayne@69 3137 MODULE_SCOPE void TclpSetVariables(Tcl_Interp *interp);
jpayne@69 3138 MODULE_SCOPE void * TclThreadStorageKeyGet(Tcl_ThreadDataKey *keyPtr);
jpayne@69 3139 MODULE_SCOPE void TclThreadStorageKeySet(Tcl_ThreadDataKey *keyPtr,
jpayne@69 3140 void *data);
jpayne@69 3141 MODULE_SCOPE void TclpThreadExit(int status);
jpayne@69 3142 MODULE_SCOPE void TclRememberCondition(Tcl_Condition *mutex);
jpayne@69 3143 MODULE_SCOPE void TclRememberJoinableThread(Tcl_ThreadId id);
jpayne@69 3144 MODULE_SCOPE void TclRememberMutex(Tcl_Mutex *mutex);
jpayne@69 3145 MODULE_SCOPE void TclRemoveScriptLimitCallbacks(Tcl_Interp *interp);
jpayne@69 3146 MODULE_SCOPE int TclReToGlob(Tcl_Interp *interp, const char *reStr,
jpayne@69 3147 int reStrLen, Tcl_DString *dsPtr, int *flagsPtr,
jpayne@69 3148 int *quantifiersFoundPtr);
jpayne@69 3149 MODULE_SCOPE unsigned int TclScanElement(const char *string, int length,
jpayne@69 3150 char *flagPtr);
jpayne@69 3151 MODULE_SCOPE void TclSetBgErrorHandler(Tcl_Interp *interp,
jpayne@69 3152 Tcl_Obj *cmdPrefix);
jpayne@69 3153 MODULE_SCOPE void TclSetBignumInternalRep(Tcl_Obj *objPtr,
jpayne@69 3154 mp_int *bignumValue);
jpayne@69 3155 MODULE_SCOPE int TclSetBooleanFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
jpayne@69 3156 MODULE_SCOPE void TclSetCmdNameObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
jpayne@69 3157 Command *cmdPtr);
jpayne@69 3158 MODULE_SCOPE void TclSetDuplicateObj(Tcl_Obj *dupPtr, Tcl_Obj *objPtr);
jpayne@69 3159 MODULE_SCOPE void TclSetProcessGlobalValue(ProcessGlobalValue *pgvPtr,
jpayne@69 3160 Tcl_Obj *newValue, Tcl_Encoding encoding);
jpayne@69 3161 MODULE_SCOPE void TclSignalExitThread(Tcl_ThreadId id, int result);
jpayne@69 3162 MODULE_SCOPE void TclSpellFix(Tcl_Interp *interp,
jpayne@69 3163 Tcl_Obj *const *objv, int objc, int subIdx,
jpayne@69 3164 Tcl_Obj *bad, Tcl_Obj *fix);
jpayne@69 3165 MODULE_SCOPE void * TclStackRealloc(Tcl_Interp *interp, void *ptr,
jpayne@69 3166 int numBytes);
jpayne@69 3167
jpayne@69 3168 typedef int (*memCmpFn_t)(const void*, const void*, size_t);
jpayne@69 3169 MODULE_SCOPE int TclStringCmp (Tcl_Obj *value1Ptr, Tcl_Obj *value2Ptr,
jpayne@69 3170 int checkEq, int nocase, int reqlength);
jpayne@69 3171 MODULE_SCOPE int TclStringCmpOpts (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[],
jpayne@69 3172 int *nocase, int *reqlength);
jpayne@69 3173 MODULE_SCOPE int TclStringMatch(const char *str, int strLen,
jpayne@69 3174 const char *pattern, int ptnLen, int flags);
jpayne@69 3175 MODULE_SCOPE int TclStringMatchObj(Tcl_Obj *stringObj,
jpayne@69 3176 Tcl_Obj *patternObj, int flags);
jpayne@69 3177 MODULE_SCOPE Tcl_Obj * TclStringReverse(Tcl_Obj *objPtr);
jpayne@69 3178 MODULE_SCOPE void TclSubstCompile(Tcl_Interp *interp, const char *bytes,
jpayne@69 3179 int numBytes, int flags, int line,
jpayne@69 3180 struct CompileEnv *envPtr);
jpayne@69 3181 MODULE_SCOPE int TclSubstOptions(Tcl_Interp *interp, int numOpts,
jpayne@69 3182 Tcl_Obj *const opts[], int *flagPtr);
jpayne@69 3183 MODULE_SCOPE void TclSubstParse(Tcl_Interp *interp, const char *bytes,
jpayne@69 3184 int numBytes, int flags, Tcl_Parse *parsePtr,
jpayne@69 3185 Tcl_InterpState *statePtr);
jpayne@69 3186 MODULE_SCOPE int TclSubstTokens(Tcl_Interp *interp, Tcl_Token *tokenPtr,
jpayne@69 3187 int count, int *tokensLeftPtr, int line,
jpayne@69 3188 int *clNextOuter, const char *outerScript);
jpayne@69 3189 MODULE_SCOPE int TclTrim(const char *bytes, int numBytes,
jpayne@69 3190 const char *trim, int numTrim, int *trimRight);
jpayne@69 3191 MODULE_SCOPE int TclTrimLeft(const char *bytes, int numBytes,
jpayne@69 3192 const char *trim, int numTrim);
jpayne@69 3193 MODULE_SCOPE int TclTrimRight(const char *bytes, int numBytes,
jpayne@69 3194 const char *trim, int numTrim);
jpayne@69 3195 MODULE_SCOPE int TclUtfCasecmp(const char *cs, const char *ct);
jpayne@69 3196 MODULE_SCOPE int TclUtfToUCS4(const char *, int *);
jpayne@69 3197 MODULE_SCOPE int TclUCS4ToUtf(int, char *);
jpayne@69 3198 MODULE_SCOPE int TclUCS4ToLower(int ch);
jpayne@69 3199 #if TCL_UTF_MAX == 4
jpayne@69 3200 MODULE_SCOPE int TclGetUCS4(Tcl_Obj *, int);
jpayne@69 3201 MODULE_SCOPE int TclUniCharToUCS4(const Tcl_UniChar *, int *);
jpayne@69 3202 #else
jpayne@69 3203 # define TclGetUCS4 Tcl_GetUniChar
jpayne@69 3204 # define TclUniCharToUCS4(src, ptr) (*ptr = *(src),1)
jpayne@69 3205 #endif
jpayne@69 3206
jpayne@69 3207 /*
jpayne@69 3208 * Bytes F0-F4 are start-bytes for 4-byte sequences.
jpayne@69 3209 * Byte 0xED can be the start-byte of an upper surrogate. In that case,
jpayne@69 3210 * TclUtfToUCS4() might read the lower surrogate following it too.
jpayne@69 3211 */
jpayne@69 3212 # define TclUCS4Complete(src, length) (((unsigned)(UCHAR(*(src)) - 0xF0) < 5) \
jpayne@69 3213 ? ((length) >= 4) : (UCHAR(*(src)) == 0xED) ? ((length) >= 6) : Tcl_UtfCharComplete((src), (length)))
jpayne@69 3214 MODULE_SCOPE Tcl_Obj * TclpNativeToNormalized(ClientData clientData);
jpayne@69 3215 MODULE_SCOPE Tcl_Obj * TclpFilesystemPathType(Tcl_Obj *pathPtr);
jpayne@69 3216 MODULE_SCOPE int TclpDlopen(Tcl_Interp *interp, Tcl_Obj *pathPtr,
jpayne@69 3217 Tcl_LoadHandle *loadHandle,
jpayne@69 3218 Tcl_FSUnloadFileProc **unloadProcPtr, int flags);
jpayne@69 3219 MODULE_SCOPE int TclpUtime(Tcl_Obj *pathPtr, struct utimbuf *tval);
jpayne@69 3220 #ifdef TCL_LOAD_FROM_MEMORY
jpayne@69 3221 MODULE_SCOPE void * TclpLoadMemoryGetBuffer(Tcl_Interp *interp, int size);
jpayne@69 3222 MODULE_SCOPE int TclpLoadMemory(Tcl_Interp *interp, void *buffer,
jpayne@69 3223 int size, int codeSize, Tcl_LoadHandle *loadHandle,
jpayne@69 3224 Tcl_FSUnloadFileProc **unloadProcPtr, int flags);
jpayne@69 3225 #endif
jpayne@69 3226 MODULE_SCOPE void TclInitThreadStorage(void);
jpayne@69 3227 MODULE_SCOPE void TclFinalizeThreadDataThread(void);
jpayne@69 3228 MODULE_SCOPE void TclFinalizeThreadStorage(void);
jpayne@69 3229
jpayne@69 3230 /* TclWideMUInt -- wide integer used for measurement calculations: */
jpayne@69 3231 #if (!defined(_WIN32) || !defined(_MSC_VER) || (_MSC_VER >= 1400))
jpayne@69 3232 # define TclWideMUInt Tcl_WideUInt
jpayne@69 3233 #else
jpayne@69 3234 /* older MSVS may not allow conversions between unsigned __int64 and double) */
jpayne@69 3235 # define TclWideMUInt Tcl_WideInt
jpayne@69 3236 #endif
jpayne@69 3237 #ifdef TCL_WIDE_CLICKS
jpayne@69 3238 MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void);
jpayne@69 3239 MODULE_SCOPE double TclpWideClicksToNanoseconds(Tcl_WideInt clicks);
jpayne@69 3240 MODULE_SCOPE double TclpWideClickInMicrosec(void);
jpayne@69 3241 #else
jpayne@69 3242 # ifdef _WIN32
jpayne@69 3243 # define TCL_WIDE_CLICKS 1
jpayne@69 3244 MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void);
jpayne@69 3245 MODULE_SCOPE double TclpWideClickInMicrosec(void);
jpayne@69 3246 # define TclpWideClicksToNanoseconds(clicks) \
jpayne@69 3247 ((double)(clicks) * TclpWideClickInMicrosec() * 1000)
jpayne@69 3248 # endif
jpayne@69 3249 #endif
jpayne@69 3250 MODULE_SCOPE Tcl_WideInt TclpGetMicroseconds(void);
jpayne@69 3251
jpayne@69 3252 MODULE_SCOPE int TclZlibInit(Tcl_Interp *interp);
jpayne@69 3253 MODULE_SCOPE void * TclpThreadCreateKey(void);
jpayne@69 3254 MODULE_SCOPE void TclpThreadDeleteKey(void *keyPtr);
jpayne@69 3255 MODULE_SCOPE void TclpThreadSetGlobalTSD(void *tsdKeyPtr, void *ptr);
jpayne@69 3256 MODULE_SCOPE void * TclpThreadGetGlobalTSD(void *tsdKeyPtr);
jpayne@69 3257
jpayne@69 3258 MODULE_SCOPE void TclErrorStackResetIf(Tcl_Interp *interp, const char *msg, int length);
jpayne@69 3259
jpayne@69 3260 /*
jpayne@69 3261 * Many parsing tasks need a common definition of whitespace.
jpayne@69 3262 * Use this routine and macro to achieve that and place
jpayne@69 3263 * optimization (fragile on changes) in one place.
jpayne@69 3264 */
jpayne@69 3265
jpayne@69 3266 MODULE_SCOPE int TclIsSpaceProc(int byte);
jpayne@69 3267 # define TclIsSpaceProcM(byte) \
jpayne@69 3268 (((byte) > 0x20) ? 0 : TclIsSpaceProc(byte))
jpayne@69 3269
jpayne@69 3270 /*
jpayne@69 3271 *----------------------------------------------------------------
jpayne@69 3272 * Command procedures in the generic core:
jpayne@69 3273 *----------------------------------------------------------------
jpayne@69 3274 */
jpayne@69 3275
jpayne@69 3276 MODULE_SCOPE int Tcl_AfterObjCmd(ClientData clientData,
jpayne@69 3277 Tcl_Interp *interp, int objc,
jpayne@69 3278 Tcl_Obj *const objv[]);
jpayne@69 3279 MODULE_SCOPE int Tcl_AppendObjCmd(ClientData clientData,
jpayne@69 3280 Tcl_Interp *interp, int objc,
jpayne@69 3281 Tcl_Obj *const objv[]);
jpayne@69 3282 MODULE_SCOPE int Tcl_ApplyObjCmd(ClientData clientData,
jpayne@69 3283 Tcl_Interp *interp, int objc,
jpayne@69 3284 Tcl_Obj *const objv[]);
jpayne@69 3285 MODULE_SCOPE Tcl_Command TclInitArrayCmd(Tcl_Interp *interp);
jpayne@69 3286 MODULE_SCOPE Tcl_Command TclInitBinaryCmd(Tcl_Interp *interp);
jpayne@69 3287 MODULE_SCOPE int Tcl_BreakObjCmd(ClientData clientData,
jpayne@69 3288 Tcl_Interp *interp, int objc,
jpayne@69 3289 Tcl_Obj *const objv[]);
jpayne@69 3290 MODULE_SCOPE int Tcl_CaseObjCmd(ClientData clientData,
jpayne@69 3291 Tcl_Interp *interp, int objc,
jpayne@69 3292 Tcl_Obj *const objv[]);
jpayne@69 3293 MODULE_SCOPE int Tcl_CatchObjCmd(ClientData clientData,
jpayne@69 3294 Tcl_Interp *interp, int objc,
jpayne@69 3295 Tcl_Obj *const objv[]);
jpayne@69 3296 MODULE_SCOPE int Tcl_CdObjCmd(ClientData clientData,
jpayne@69 3297 Tcl_Interp *interp, int objc,
jpayne@69 3298 Tcl_Obj *const objv[]);
jpayne@69 3299 MODULE_SCOPE Tcl_Command TclInitChanCmd(Tcl_Interp *interp);
jpayne@69 3300 MODULE_SCOPE int TclChanCreateObjCmd(ClientData clientData,
jpayne@69 3301 Tcl_Interp *interp, int objc,
jpayne@69 3302 Tcl_Obj *const objv[]);
jpayne@69 3303 MODULE_SCOPE int TclChanPostEventObjCmd(ClientData clientData,
jpayne@69 3304 Tcl_Interp *interp, int objc,
jpayne@69 3305 Tcl_Obj *const objv[]);
jpayne@69 3306 MODULE_SCOPE int TclChanPopObjCmd(ClientData clientData,
jpayne@69 3307 Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
jpayne@69 3308 MODULE_SCOPE int TclChanPushObjCmd(ClientData clientData,
jpayne@69 3309 Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
jpayne@69 3310 MODULE_SCOPE void TclClockInit(Tcl_Interp *interp);
jpayne@69 3311 MODULE_SCOPE int TclClockOldscanObjCmd(
jpayne@69 3312 ClientData clientData, Tcl_Interp *interp,
jpayne@69 3313 int objc, Tcl_Obj *const objv[]);
jpayne@69 3314 MODULE_SCOPE int Tcl_CloseObjCmd(ClientData clientData,
jpayne@69 3315 Tcl_Interp *interp, int objc,
jpayne@69 3316 Tcl_Obj *const objv[]);
jpayne@69 3317 MODULE_SCOPE int Tcl_ConcatObjCmd(ClientData clientData,
jpayne@69 3318 Tcl_Interp *interp, int objc,
jpayne@69 3319 Tcl_Obj *const objv[]);
jpayne@69 3320 MODULE_SCOPE int Tcl_ContinueObjCmd(ClientData clientData,
jpayne@69 3321 Tcl_Interp *interp, int objc,
jpayne@69 3322 Tcl_Obj *const objv[]);
jpayne@69 3323 MODULE_SCOPE Tcl_TimerToken TclCreateAbsoluteTimerHandler(
jpayne@69 3324 Tcl_Time *timePtr, Tcl_TimerProc *proc,
jpayne@69 3325 ClientData clientData);
jpayne@69 3326 MODULE_SCOPE int TclDefaultBgErrorHandlerObjCmd(
jpayne@69 3327 ClientData clientData, Tcl_Interp *interp,
jpayne@69 3328 int objc, Tcl_Obj *const objv[]);
jpayne@69 3329 MODULE_SCOPE Tcl_Command TclInitDictCmd(Tcl_Interp *interp);
jpayne@69 3330 MODULE_SCOPE int TclDictWithFinish(Tcl_Interp *interp, Var *varPtr,
jpayne@69 3331 Var *arrayPtr, Tcl_Obj *part1Ptr,
jpayne@69 3332 Tcl_Obj *part2Ptr, int index, int pathc,
jpayne@69 3333 Tcl_Obj *const pathv[], Tcl_Obj *keysPtr);
jpayne@69 3334 MODULE_SCOPE Tcl_Obj * TclDictWithInit(Tcl_Interp *interp, Tcl_Obj *dictPtr,
jpayne@69 3335 int pathc, Tcl_Obj *const pathv[]);
jpayne@69 3336 MODULE_SCOPE int Tcl_DisassembleObjCmd(ClientData clientData,
jpayne@69 3337 Tcl_Interp *interp, int objc,
jpayne@69 3338 Tcl_Obj *const objv[]);
jpayne@69 3339
jpayne@69 3340 /* Assemble command function */
jpayne@69 3341 MODULE_SCOPE int Tcl_AssembleObjCmd(ClientData clientData,
jpayne@69 3342 Tcl_Interp *interp, int objc,
jpayne@69 3343 Tcl_Obj *const objv[]);
jpayne@69 3344 MODULE_SCOPE int TclNRAssembleObjCmd(ClientData clientData,
jpayne@69 3345 Tcl_Interp *interp, int objc,
jpayne@69 3346 Tcl_Obj *const objv[]);
jpayne@69 3347 MODULE_SCOPE Tcl_Command TclInitEncodingCmd(Tcl_Interp *interp);
jpayne@69 3348 MODULE_SCOPE int TclMakeEncodingCommandSafe(Tcl_Interp *interp);
jpayne@69 3349 MODULE_SCOPE int Tcl_EofObjCmd(ClientData clientData,
jpayne@69 3350 Tcl_Interp *interp, int objc,
jpayne@69 3351 Tcl_Obj *const objv[]);
jpayne@69 3352 MODULE_SCOPE int Tcl_ErrorObjCmd(ClientData clientData,
jpayne@69 3353 Tcl_Interp *interp, int objc,
jpayne@69 3354 Tcl_Obj *const objv[]);
jpayne@69 3355 MODULE_SCOPE int Tcl_EvalObjCmd(ClientData clientData,
jpayne@69 3356 Tcl_Interp *interp, int objc,
jpayne@69 3357 Tcl_Obj *const objv[]);
jpayne@69 3358 MODULE_SCOPE int Tcl_ExecObjCmd(ClientData clientData,
jpayne@69 3359 Tcl_Interp *interp, int objc,
jpayne@69 3360 Tcl_Obj *const objv[]);
jpayne@69 3361 MODULE_SCOPE int Tcl_ExitObjCmd(ClientData clientData,
jpayne@69 3362 Tcl_Interp *interp, int objc,
jpayne@69 3363 Tcl_Obj *const objv[]);
jpayne@69 3364 MODULE_SCOPE int Tcl_ExprObjCmd(ClientData clientData,
jpayne@69 3365 Tcl_Interp *interp, int objc,
jpayne@69 3366 Tcl_Obj *const objv[]);
jpayne@69 3367 MODULE_SCOPE int Tcl_FblockedObjCmd(ClientData clientData,
jpayne@69 3368 Tcl_Interp *interp, int objc,
jpayne@69 3369 Tcl_Obj *const objv[]);
jpayne@69 3370 MODULE_SCOPE int Tcl_FconfigureObjCmd(
jpayne@69 3371 ClientData clientData, Tcl_Interp *interp,
jpayne@69 3372 int objc, Tcl_Obj *const objv[]);
jpayne@69 3373 MODULE_SCOPE int Tcl_FcopyObjCmd(ClientData dummy,
jpayne@69 3374 Tcl_Interp *interp, int objc,
jpayne@69 3375 Tcl_Obj *const objv[]);
jpayne@69 3376 MODULE_SCOPE Tcl_Command TclInitFileCmd(Tcl_Interp *interp);
jpayne@69 3377 MODULE_SCOPE int TclMakeFileCommandSafe(Tcl_Interp *interp);
jpayne@69 3378 MODULE_SCOPE int Tcl_FileEventObjCmd(ClientData clientData,
jpayne@69 3379 Tcl_Interp *interp, int objc,
jpayne@69 3380 Tcl_Obj *const objv[]);
jpayne@69 3381 MODULE_SCOPE int Tcl_FlushObjCmd(ClientData clientData,
jpayne@69 3382 Tcl_Interp *interp, int objc,
jpayne@69 3383 Tcl_Obj *const objv[]);
jpayne@69 3384 MODULE_SCOPE int Tcl_ForObjCmd(ClientData clientData,
jpayne@69 3385 Tcl_Interp *interp, int objc,
jpayne@69 3386 Tcl_Obj *const objv[]);
jpayne@69 3387 MODULE_SCOPE int Tcl_ForeachObjCmd(ClientData clientData,
jpayne@69 3388 Tcl_Interp *interp, int objc,
jpayne@69 3389 Tcl_Obj *const objv[]);
jpayne@69 3390 MODULE_SCOPE int Tcl_FormatObjCmd(ClientData dummy,
jpayne@69 3391 Tcl_Interp *interp, int objc,
jpayne@69 3392 Tcl_Obj *const objv[]);
jpayne@69 3393 MODULE_SCOPE int Tcl_GetsObjCmd(ClientData clientData,
jpayne@69 3394 Tcl_Interp *interp, int objc,
jpayne@69 3395 Tcl_Obj *const objv[]);
jpayne@69 3396 MODULE_SCOPE int Tcl_GlobalObjCmd(ClientData clientData,
jpayne@69 3397 Tcl_Interp *interp, int objc,
jpayne@69 3398 Tcl_Obj *const objv[]);
jpayne@69 3399 MODULE_SCOPE int Tcl_GlobObjCmd(ClientData clientData,
jpayne@69 3400 Tcl_Interp *interp, int objc,
jpayne@69 3401 Tcl_Obj *const objv[]);
jpayne@69 3402 MODULE_SCOPE int Tcl_IfObjCmd(ClientData clientData,
jpayne@69 3403 Tcl_Interp *interp, int objc,
jpayne@69 3404 Tcl_Obj *const objv[]);
jpayne@69 3405 MODULE_SCOPE int Tcl_IncrObjCmd(ClientData clientData,
jpayne@69 3406 Tcl_Interp *interp, int objc,
jpayne@69 3407 Tcl_Obj *const objv[]);
jpayne@69 3408 MODULE_SCOPE Tcl_Command TclInitInfoCmd(Tcl_Interp *interp);
jpayne@69 3409 MODULE_SCOPE int Tcl_InterpObjCmd(ClientData clientData,
jpayne@69 3410 Tcl_Interp *interp, int argc,
jpayne@69 3411 Tcl_Obj *const objv[]);
jpayne@69 3412 MODULE_SCOPE int Tcl_JoinObjCmd(ClientData clientData,
jpayne@69 3413 Tcl_Interp *interp, int objc,
jpayne@69 3414 Tcl_Obj *const objv[]);
jpayne@69 3415 MODULE_SCOPE int Tcl_LappendObjCmd(ClientData clientData,
jpayne@69 3416 Tcl_Interp *interp, int objc,
jpayne@69 3417 Tcl_Obj *const objv[]);
jpayne@69 3418 MODULE_SCOPE int Tcl_LassignObjCmd(ClientData clientData,
jpayne@69 3419 Tcl_Interp *interp, int objc,
jpayne@69 3420 Tcl_Obj *const objv[]);
jpayne@69 3421 MODULE_SCOPE int Tcl_LindexObjCmd(ClientData clientData,
jpayne@69 3422 Tcl_Interp *interp, int objc,
jpayne@69 3423 Tcl_Obj *const objv[]);
jpayne@69 3424 MODULE_SCOPE int Tcl_LinsertObjCmd(ClientData clientData,
jpayne@69 3425 Tcl_Interp *interp, int objc,
jpayne@69 3426 Tcl_Obj *const objv[]);
jpayne@69 3427 MODULE_SCOPE int Tcl_LlengthObjCmd(ClientData clientData,
jpayne@69 3428 Tcl_Interp *interp, int objc,
jpayne@69 3429 Tcl_Obj *const objv[]);
jpayne@69 3430 MODULE_SCOPE int Tcl_ListObjCmd(ClientData clientData,
jpayne@69 3431 Tcl_Interp *interp, int objc,
jpayne@69 3432 Tcl_Obj *const objv[]);
jpayne@69 3433 MODULE_SCOPE int Tcl_LmapObjCmd(ClientData clientData,
jpayne@69 3434 Tcl_Interp *interp, int objc,
jpayne@69 3435 Tcl_Obj *const objv[]);
jpayne@69 3436 MODULE_SCOPE int Tcl_LoadObjCmd(ClientData clientData,
jpayne@69 3437 Tcl_Interp *interp, int objc,
jpayne@69 3438 Tcl_Obj *const objv[]);
jpayne@69 3439 MODULE_SCOPE int Tcl_LrangeObjCmd(ClientData clientData,
jpayne@69 3440 Tcl_Interp *interp, int objc,
jpayne@69 3441 Tcl_Obj *const objv[]);
jpayne@69 3442 MODULE_SCOPE int Tcl_LrepeatObjCmd(ClientData clientData,
jpayne@69 3443 Tcl_Interp *interp, int objc,
jpayne@69 3444 Tcl_Obj *const objv[]);
jpayne@69 3445 MODULE_SCOPE int Tcl_LreplaceObjCmd(ClientData clientData,
jpayne@69 3446 Tcl_Interp *interp, int objc,
jpayne@69 3447 Tcl_Obj *const objv[]);
jpayne@69 3448 MODULE_SCOPE int Tcl_LreverseObjCmd(ClientData clientData,
jpayne@69 3449 Tcl_Interp *interp, int objc,
jpayne@69 3450 Tcl_Obj *const objv[]);
jpayne@69 3451 MODULE_SCOPE int Tcl_LsearchObjCmd(ClientData clientData,
jpayne@69 3452 Tcl_Interp *interp, int objc,
jpayne@69 3453 Tcl_Obj *const objv[]);
jpayne@69 3454 MODULE_SCOPE int Tcl_LsetObjCmd(ClientData clientData,
jpayne@69 3455 Tcl_Interp *interp, int objc,
jpayne@69 3456 Tcl_Obj *const objv[]);
jpayne@69 3457 MODULE_SCOPE int Tcl_LsortObjCmd(ClientData clientData,
jpayne@69 3458 Tcl_Interp *interp, int objc,
jpayne@69 3459 Tcl_Obj *const objv[]);
jpayne@69 3460 MODULE_SCOPE Tcl_Command TclInitNamespaceCmd(Tcl_Interp *interp);
jpayne@69 3461 MODULE_SCOPE int TclNamespaceEnsembleCmd(ClientData dummy,
jpayne@69 3462 Tcl_Interp *interp, int objc,
jpayne@69 3463 Tcl_Obj *const objv[]);
jpayne@69 3464 MODULE_SCOPE int Tcl_OpenObjCmd(ClientData clientData,
jpayne@69 3465 Tcl_Interp *interp, int objc,
jpayne@69 3466 Tcl_Obj *const objv[]);
jpayne@69 3467 MODULE_SCOPE int Tcl_PackageObjCmd(ClientData clientData,
jpayne@69 3468 Tcl_Interp *interp, int objc,
jpayne@69 3469 Tcl_Obj *const objv[]);
jpayne@69 3470 MODULE_SCOPE int Tcl_PidObjCmd(ClientData clientData,
jpayne@69 3471 Tcl_Interp *interp, int objc,
jpayne@69 3472 Tcl_Obj *const objv[]);
jpayne@69 3473 MODULE_SCOPE Tcl_Command TclInitPrefixCmd(Tcl_Interp *interp);
jpayne@69 3474 MODULE_SCOPE int Tcl_PutsObjCmd(ClientData clientData,
jpayne@69 3475 Tcl_Interp *interp, int objc,
jpayne@69 3476 Tcl_Obj *const objv[]);
jpayne@69 3477 MODULE_SCOPE int Tcl_PwdObjCmd(ClientData clientData,
jpayne@69 3478 Tcl_Interp *interp, int objc,
jpayne@69 3479 Tcl_Obj *const objv[]);
jpayne@69 3480 MODULE_SCOPE int Tcl_ReadObjCmd(ClientData clientData,
jpayne@69 3481 Tcl_Interp *interp, int objc,
jpayne@69 3482 Tcl_Obj *const objv[]);
jpayne@69 3483 MODULE_SCOPE int Tcl_RegexpObjCmd(ClientData clientData,
jpayne@69 3484 Tcl_Interp *interp, int objc,
jpayne@69 3485 Tcl_Obj *const objv[]);
jpayne@69 3486 MODULE_SCOPE int Tcl_RegsubObjCmd(ClientData clientData,
jpayne@69 3487 Tcl_Interp *interp, int objc,
jpayne@69 3488 Tcl_Obj *const objv[]);
jpayne@69 3489 MODULE_SCOPE int Tcl_RenameObjCmd(ClientData clientData,
jpayne@69 3490 Tcl_Interp *interp, int objc,
jpayne@69 3491 Tcl_Obj *const objv[]);
jpayne@69 3492 MODULE_SCOPE int Tcl_RepresentationCmd(ClientData clientData,
jpayne@69 3493 Tcl_Interp *interp, int objc,
jpayne@69 3494 Tcl_Obj *const objv[]);
jpayne@69 3495 MODULE_SCOPE int Tcl_ReturnObjCmd(ClientData clientData,
jpayne@69 3496 Tcl_Interp *interp, int objc,
jpayne@69 3497 Tcl_Obj *const objv[]);
jpayne@69 3498 MODULE_SCOPE int Tcl_ScanObjCmd(ClientData clientData,
jpayne@69 3499 Tcl_Interp *interp, int objc,
jpayne@69 3500 Tcl_Obj *const objv[]);
jpayne@69 3501 MODULE_SCOPE int Tcl_SeekObjCmd(ClientData clientData,
jpayne@69 3502 Tcl_Interp *interp, int objc,
jpayne@69 3503 Tcl_Obj *const objv[]);
jpayne@69 3504 MODULE_SCOPE int Tcl_SetObjCmd(ClientData clientData,
jpayne@69 3505 Tcl_Interp *interp, int objc,
jpayne@69 3506 Tcl_Obj *const objv[]);
jpayne@69 3507 MODULE_SCOPE int Tcl_SplitObjCmd(ClientData clientData,
jpayne@69 3508 Tcl_Interp *interp, int objc,
jpayne@69 3509 Tcl_Obj *const objv[]);
jpayne@69 3510 MODULE_SCOPE int Tcl_SocketObjCmd(ClientData clientData,
jpayne@69 3511 Tcl_Interp *interp, int objc,
jpayne@69 3512 Tcl_Obj *const objv[]);
jpayne@69 3513 MODULE_SCOPE int Tcl_SourceObjCmd(ClientData clientData,
jpayne@69 3514 Tcl_Interp *interp, int objc,
jpayne@69 3515 Tcl_Obj *const objv[]);
jpayne@69 3516 MODULE_SCOPE Tcl_Command TclInitStringCmd(Tcl_Interp *interp);
jpayne@69 3517 MODULE_SCOPE int Tcl_SubstObjCmd(ClientData clientData,
jpayne@69 3518 Tcl_Interp *interp, int objc,
jpayne@69 3519 Tcl_Obj *const objv[]);
jpayne@69 3520 MODULE_SCOPE int Tcl_SwitchObjCmd(ClientData clientData,
jpayne@69 3521 Tcl_Interp *interp, int objc,
jpayne@69 3522 Tcl_Obj *const objv[]);
jpayne@69 3523 MODULE_SCOPE int Tcl_TellObjCmd(ClientData clientData,
jpayne@69 3524 Tcl_Interp *interp, int objc,
jpayne@69 3525 Tcl_Obj *const objv[]);
jpayne@69 3526 MODULE_SCOPE int Tcl_ThrowObjCmd(ClientData dummy, Tcl_Interp *interp,
jpayne@69 3527 int objc, Tcl_Obj *const objv[]);
jpayne@69 3528 MODULE_SCOPE int Tcl_TimeObjCmd(ClientData clientData,
jpayne@69 3529 Tcl_Interp *interp, int objc,
jpayne@69 3530 Tcl_Obj *const objv[]);
jpayne@69 3531 MODULE_SCOPE int Tcl_TimeRateObjCmd(ClientData clientData,
jpayne@69 3532 Tcl_Interp *interp, int objc,
jpayne@69 3533 Tcl_Obj *const objv[]);
jpayne@69 3534 MODULE_SCOPE int Tcl_TraceObjCmd(ClientData clientData,
jpayne@69 3535 Tcl_Interp *interp, int objc,
jpayne@69 3536 Tcl_Obj *const objv[]);
jpayne@69 3537 MODULE_SCOPE int Tcl_TryObjCmd(ClientData clientData,
jpayne@69 3538 Tcl_Interp *interp, int objc,
jpayne@69 3539 Tcl_Obj *const objv[]);
jpayne@69 3540 MODULE_SCOPE int Tcl_UnloadObjCmd(ClientData clientData,
jpayne@69 3541 Tcl_Interp *interp, int objc,
jpayne@69 3542 Tcl_Obj *const objv[]);
jpayne@69 3543 MODULE_SCOPE int Tcl_UnsetObjCmd(ClientData clientData,
jpayne@69 3544 Tcl_Interp *interp, int objc,
jpayne@69 3545 Tcl_Obj *const objv[]);
jpayne@69 3546 MODULE_SCOPE int Tcl_UpdateObjCmd(ClientData clientData,
jpayne@69 3547 Tcl_Interp *interp, int objc,
jpayne@69 3548 Tcl_Obj *const objv[]);
jpayne@69 3549 MODULE_SCOPE int Tcl_UplevelObjCmd(ClientData clientData,
jpayne@69 3550 Tcl_Interp *interp, int objc,
jpayne@69 3551 Tcl_Obj *const objv[]);
jpayne@69 3552 MODULE_SCOPE int Tcl_UpvarObjCmd(ClientData clientData,
jpayne@69 3553 Tcl_Interp *interp, int objc,
jpayne@69 3554 Tcl_Obj *const objv[]);
jpayne@69 3555 MODULE_SCOPE int Tcl_VariableObjCmd(ClientData clientData,
jpayne@69 3556 Tcl_Interp *interp, int objc,
jpayne@69 3557 Tcl_Obj *const objv[]);
jpayne@69 3558 MODULE_SCOPE int Tcl_VwaitObjCmd(ClientData clientData,
jpayne@69 3559 Tcl_Interp *interp, int objc,
jpayne@69 3560 Tcl_Obj *const objv[]);
jpayne@69 3561 MODULE_SCOPE int Tcl_WhileObjCmd(ClientData clientData,
jpayne@69 3562 Tcl_Interp *interp, int objc,
jpayne@69 3563 Tcl_Obj *const objv[]);
jpayne@69 3564
jpayne@69 3565 /*
jpayne@69 3566 *----------------------------------------------------------------
jpayne@69 3567 * Compilation procedures for commands in the generic core:
jpayne@69 3568 *----------------------------------------------------------------
jpayne@69 3569 */
jpayne@69 3570
jpayne@69 3571 MODULE_SCOPE int TclCompileAppendCmd(Tcl_Interp *interp,
jpayne@69 3572 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3573 struct CompileEnv *envPtr);
jpayne@69 3574 MODULE_SCOPE int TclCompileArrayExistsCmd(Tcl_Interp *interp,
jpayne@69 3575 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3576 struct CompileEnv *envPtr);
jpayne@69 3577 MODULE_SCOPE int TclCompileArraySetCmd(Tcl_Interp *interp,
jpayne@69 3578 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3579 struct CompileEnv *envPtr);
jpayne@69 3580 MODULE_SCOPE int TclCompileArrayUnsetCmd(Tcl_Interp *interp,
jpayne@69 3581 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3582 struct CompileEnv *envPtr);
jpayne@69 3583 MODULE_SCOPE int TclCompileBreakCmd(Tcl_Interp *interp,
jpayne@69 3584 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3585 struct CompileEnv *envPtr);
jpayne@69 3586 MODULE_SCOPE int TclCompileCatchCmd(Tcl_Interp *interp,
jpayne@69 3587 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3588 struct CompileEnv *envPtr);
jpayne@69 3589 MODULE_SCOPE int TclCompileClockClicksCmd(Tcl_Interp *interp,
jpayne@69 3590 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3591 struct CompileEnv *envPtr);
jpayne@69 3592 MODULE_SCOPE int TclCompileClockReadingCmd(Tcl_Interp *interp,
jpayne@69 3593 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3594 struct CompileEnv *envPtr);
jpayne@69 3595 MODULE_SCOPE int TclCompileConcatCmd(Tcl_Interp *interp,
jpayne@69 3596 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3597 struct CompileEnv *envPtr);
jpayne@69 3598 MODULE_SCOPE int TclCompileContinueCmd(Tcl_Interp *interp,
jpayne@69 3599 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3600 struct CompileEnv *envPtr);
jpayne@69 3601 MODULE_SCOPE int TclCompileDictAppendCmd(Tcl_Interp *interp,
jpayne@69 3602 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3603 struct CompileEnv *envPtr);
jpayne@69 3604 MODULE_SCOPE int TclCompileDictCreateCmd(Tcl_Interp *interp,
jpayne@69 3605 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3606 struct CompileEnv *envPtr);
jpayne@69 3607 MODULE_SCOPE int TclCompileDictExistsCmd(Tcl_Interp *interp,
jpayne@69 3608 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3609 struct CompileEnv *envPtr);
jpayne@69 3610 MODULE_SCOPE int TclCompileDictForCmd(Tcl_Interp *interp,
jpayne@69 3611 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3612 struct CompileEnv *envPtr);
jpayne@69 3613 MODULE_SCOPE int TclCompileDictGetCmd(Tcl_Interp *interp,
jpayne@69 3614 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3615 struct CompileEnv *envPtr);
jpayne@69 3616 MODULE_SCOPE int TclCompileDictIncrCmd(Tcl_Interp *interp,
jpayne@69 3617 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3618 struct CompileEnv *envPtr);
jpayne@69 3619 MODULE_SCOPE int TclCompileDictLappendCmd(Tcl_Interp *interp,
jpayne@69 3620 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3621 struct CompileEnv *envPtr);
jpayne@69 3622 MODULE_SCOPE int TclCompileDictMapCmd(Tcl_Interp *interp,
jpayne@69 3623 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3624 struct CompileEnv *envPtr);
jpayne@69 3625 MODULE_SCOPE int TclCompileDictMergeCmd(Tcl_Interp *interp,
jpayne@69 3626 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3627 struct CompileEnv *envPtr);
jpayne@69 3628 MODULE_SCOPE int TclCompileDictSetCmd(Tcl_Interp *interp,
jpayne@69 3629 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3630 struct CompileEnv *envPtr);
jpayne@69 3631 MODULE_SCOPE int TclCompileDictUnsetCmd(Tcl_Interp *interp,
jpayne@69 3632 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3633 struct CompileEnv *envPtr);
jpayne@69 3634 MODULE_SCOPE int TclCompileDictUpdateCmd(Tcl_Interp *interp,
jpayne@69 3635 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3636 struct CompileEnv *envPtr);
jpayne@69 3637 MODULE_SCOPE int TclCompileDictWithCmd(Tcl_Interp *interp,
jpayne@69 3638 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3639 struct CompileEnv *envPtr);
jpayne@69 3640 MODULE_SCOPE int TclCompileEnsemble(Tcl_Interp *interp,
jpayne@69 3641 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3642 struct CompileEnv *envPtr);
jpayne@69 3643 MODULE_SCOPE int TclCompileErrorCmd(Tcl_Interp *interp,
jpayne@69 3644 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3645 struct CompileEnv *envPtr);
jpayne@69 3646 MODULE_SCOPE int TclCompileExprCmd(Tcl_Interp *interp,
jpayne@69 3647 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3648 struct CompileEnv *envPtr);
jpayne@69 3649 MODULE_SCOPE int TclCompileForCmd(Tcl_Interp *interp,
jpayne@69 3650 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3651 struct CompileEnv *envPtr);
jpayne@69 3652 MODULE_SCOPE int TclCompileForeachCmd(Tcl_Interp *interp,
jpayne@69 3653 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3654 struct CompileEnv *envPtr);
jpayne@69 3655 MODULE_SCOPE int TclCompileFormatCmd(Tcl_Interp *interp,
jpayne@69 3656 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3657 struct CompileEnv *envPtr);
jpayne@69 3658 MODULE_SCOPE int TclCompileGlobalCmd(Tcl_Interp *interp,
jpayne@69 3659 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3660 struct CompileEnv *envPtr);
jpayne@69 3661 MODULE_SCOPE int TclCompileIfCmd(Tcl_Interp *interp,
jpayne@69 3662 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3663 struct CompileEnv *envPtr);
jpayne@69 3664 MODULE_SCOPE int TclCompileInfoCommandsCmd(Tcl_Interp *interp,
jpayne@69 3665 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3666 struct CompileEnv *envPtr);
jpayne@69 3667 MODULE_SCOPE int TclCompileInfoCoroutineCmd(Tcl_Interp *interp,
jpayne@69 3668 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3669 struct CompileEnv *envPtr);
jpayne@69 3670 MODULE_SCOPE int TclCompileInfoExistsCmd(Tcl_Interp *interp,
jpayne@69 3671 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3672 struct CompileEnv *envPtr);
jpayne@69 3673 MODULE_SCOPE int TclCompileInfoLevelCmd(Tcl_Interp *interp,
jpayne@69 3674 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3675 struct CompileEnv *envPtr);
jpayne@69 3676 MODULE_SCOPE int TclCompileInfoObjectClassCmd(Tcl_Interp *interp,
jpayne@69 3677 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3678 struct CompileEnv *envPtr);
jpayne@69 3679 MODULE_SCOPE int TclCompileInfoObjectIsACmd(Tcl_Interp *interp,
jpayne@69 3680 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3681 struct CompileEnv *envPtr);
jpayne@69 3682 MODULE_SCOPE int TclCompileInfoObjectNamespaceCmd(Tcl_Interp *interp,
jpayne@69 3683 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3684 struct CompileEnv *envPtr);
jpayne@69 3685 MODULE_SCOPE int TclCompileIncrCmd(Tcl_Interp *interp,
jpayne@69 3686 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3687 struct CompileEnv *envPtr);
jpayne@69 3688 MODULE_SCOPE int TclCompileLappendCmd(Tcl_Interp *interp,
jpayne@69 3689 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3690 struct CompileEnv *envPtr);
jpayne@69 3691 MODULE_SCOPE int TclCompileLassignCmd(Tcl_Interp *interp,
jpayne@69 3692 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3693 struct CompileEnv *envPtr);
jpayne@69 3694 MODULE_SCOPE int TclCompileLindexCmd(Tcl_Interp *interp,
jpayne@69 3695 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3696 struct CompileEnv *envPtr);
jpayne@69 3697 MODULE_SCOPE int TclCompileLinsertCmd(Tcl_Interp *interp,
jpayne@69 3698 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3699 struct CompileEnv *envPtr);
jpayne@69 3700 MODULE_SCOPE int TclCompileListCmd(Tcl_Interp *interp,
jpayne@69 3701 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3702 struct CompileEnv *envPtr);
jpayne@69 3703 MODULE_SCOPE int TclCompileLlengthCmd(Tcl_Interp *interp,
jpayne@69 3704 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3705 struct CompileEnv *envPtr);
jpayne@69 3706 MODULE_SCOPE int TclCompileLmapCmd(Tcl_Interp *interp,
jpayne@69 3707 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3708 struct CompileEnv *envPtr);
jpayne@69 3709 MODULE_SCOPE int TclCompileLrangeCmd(Tcl_Interp *interp,
jpayne@69 3710 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3711 struct CompileEnv *envPtr);
jpayne@69 3712 MODULE_SCOPE int TclCompileLreplaceCmd(Tcl_Interp *interp,
jpayne@69 3713 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3714 struct CompileEnv *envPtr);
jpayne@69 3715 MODULE_SCOPE int TclCompileLsetCmd(Tcl_Interp *interp,
jpayne@69 3716 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3717 struct CompileEnv *envPtr);
jpayne@69 3718 MODULE_SCOPE int TclCompileNamespaceCodeCmd(Tcl_Interp *interp,
jpayne@69 3719 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3720 struct CompileEnv *envPtr);
jpayne@69 3721 MODULE_SCOPE int TclCompileNamespaceCurrentCmd(Tcl_Interp *interp,
jpayne@69 3722 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3723 struct CompileEnv *envPtr);
jpayne@69 3724 MODULE_SCOPE int TclCompileNamespaceOriginCmd(Tcl_Interp *interp,
jpayne@69 3725 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3726 struct CompileEnv *envPtr);
jpayne@69 3727 MODULE_SCOPE int TclCompileNamespaceQualifiersCmd(Tcl_Interp *interp,
jpayne@69 3728 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3729 struct CompileEnv *envPtr);
jpayne@69 3730 MODULE_SCOPE int TclCompileNamespaceTailCmd(Tcl_Interp *interp,
jpayne@69 3731 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3732 struct CompileEnv *envPtr);
jpayne@69 3733 MODULE_SCOPE int TclCompileNamespaceUpvarCmd(Tcl_Interp *interp,
jpayne@69 3734 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3735 struct CompileEnv *envPtr);
jpayne@69 3736 MODULE_SCOPE int TclCompileNamespaceWhichCmd(Tcl_Interp *interp,
jpayne@69 3737 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3738 struct CompileEnv *envPtr);
jpayne@69 3739 MODULE_SCOPE int TclCompileNoOp(Tcl_Interp *interp,
jpayne@69 3740 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3741 struct CompileEnv *envPtr);
jpayne@69 3742 MODULE_SCOPE int TclCompileObjectNextCmd(Tcl_Interp *interp,
jpayne@69 3743 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3744 struct CompileEnv *envPtr);
jpayne@69 3745 MODULE_SCOPE int TclCompileObjectNextToCmd(Tcl_Interp *interp,
jpayne@69 3746 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3747 struct CompileEnv *envPtr);
jpayne@69 3748 MODULE_SCOPE int TclCompileObjectSelfCmd(Tcl_Interp *interp,
jpayne@69 3749 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3750 struct CompileEnv *envPtr);
jpayne@69 3751 MODULE_SCOPE int TclCompileRegexpCmd(Tcl_Interp *interp,
jpayne@69 3752 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3753 struct CompileEnv *envPtr);
jpayne@69 3754 MODULE_SCOPE int TclCompileRegsubCmd(Tcl_Interp *interp,
jpayne@69 3755 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3756 struct CompileEnv *envPtr);
jpayne@69 3757 MODULE_SCOPE int TclCompileReturnCmd(Tcl_Interp *interp,
jpayne@69 3758 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3759 struct CompileEnv *envPtr);
jpayne@69 3760 MODULE_SCOPE int TclCompileSetCmd(Tcl_Interp *interp,
jpayne@69 3761 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3762 struct CompileEnv *envPtr);
jpayne@69 3763 MODULE_SCOPE int TclCompileStringCatCmd(Tcl_Interp *interp,
jpayne@69 3764 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3765 struct CompileEnv *envPtr);
jpayne@69 3766 MODULE_SCOPE int TclCompileStringCmpCmd(Tcl_Interp *interp,
jpayne@69 3767 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3768 struct CompileEnv *envPtr);
jpayne@69 3769 MODULE_SCOPE int TclCompileStringEqualCmd(Tcl_Interp *interp,
jpayne@69 3770 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3771 struct CompileEnv *envPtr);
jpayne@69 3772 MODULE_SCOPE int TclCompileStringFirstCmd(Tcl_Interp *interp,
jpayne@69 3773 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3774 struct CompileEnv *envPtr);
jpayne@69 3775 MODULE_SCOPE int TclCompileStringIndexCmd(Tcl_Interp *interp,
jpayne@69 3776 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3777 struct CompileEnv *envPtr);
jpayne@69 3778 MODULE_SCOPE int TclCompileStringIsCmd(Tcl_Interp *interp,
jpayne@69 3779 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3780 struct CompileEnv *envPtr);
jpayne@69 3781 MODULE_SCOPE int TclCompileStringLastCmd(Tcl_Interp *interp,
jpayne@69 3782 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3783 struct CompileEnv *envPtr);
jpayne@69 3784 MODULE_SCOPE int TclCompileStringLenCmd(Tcl_Interp *interp,
jpayne@69 3785 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3786 struct CompileEnv *envPtr);
jpayne@69 3787 MODULE_SCOPE int TclCompileStringMapCmd(Tcl_Interp *interp,
jpayne@69 3788 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3789 struct CompileEnv *envPtr);
jpayne@69 3790 MODULE_SCOPE int TclCompileStringMatchCmd(Tcl_Interp *interp,
jpayne@69 3791 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3792 struct CompileEnv *envPtr);
jpayne@69 3793 MODULE_SCOPE int TclCompileStringRangeCmd(Tcl_Interp *interp,
jpayne@69 3794 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3795 struct CompileEnv *envPtr);
jpayne@69 3796 MODULE_SCOPE int TclCompileStringReplaceCmd(Tcl_Interp *interp,
jpayne@69 3797 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3798 struct CompileEnv *envPtr);
jpayne@69 3799 MODULE_SCOPE int TclCompileStringToLowerCmd(Tcl_Interp *interp,
jpayne@69 3800 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3801 struct CompileEnv *envPtr);
jpayne@69 3802 MODULE_SCOPE int TclCompileStringToTitleCmd(Tcl_Interp *interp,
jpayne@69 3803 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3804 struct CompileEnv *envPtr);
jpayne@69 3805 MODULE_SCOPE int TclCompileStringToUpperCmd(Tcl_Interp *interp,
jpayne@69 3806 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3807 struct CompileEnv *envPtr);
jpayne@69 3808 MODULE_SCOPE int TclCompileStringTrimCmd(Tcl_Interp *interp,
jpayne@69 3809 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3810 struct CompileEnv *envPtr);
jpayne@69 3811 MODULE_SCOPE int TclCompileStringTrimLCmd(Tcl_Interp *interp,
jpayne@69 3812 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3813 struct CompileEnv *envPtr);
jpayne@69 3814 MODULE_SCOPE int TclCompileStringTrimRCmd(Tcl_Interp *interp,
jpayne@69 3815 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3816 struct CompileEnv *envPtr);
jpayne@69 3817 MODULE_SCOPE int TclCompileSubstCmd(Tcl_Interp *interp,
jpayne@69 3818 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3819 struct CompileEnv *envPtr);
jpayne@69 3820 MODULE_SCOPE int TclCompileSwitchCmd(Tcl_Interp *interp,
jpayne@69 3821 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3822 struct CompileEnv *envPtr);
jpayne@69 3823 MODULE_SCOPE int TclCompileTailcallCmd(Tcl_Interp *interp,
jpayne@69 3824 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3825 struct CompileEnv *envPtr);
jpayne@69 3826 MODULE_SCOPE int TclCompileThrowCmd(Tcl_Interp *interp,
jpayne@69 3827 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3828 struct CompileEnv *envPtr);
jpayne@69 3829 MODULE_SCOPE int TclCompileTryCmd(Tcl_Interp *interp,
jpayne@69 3830 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3831 struct CompileEnv *envPtr);
jpayne@69 3832 MODULE_SCOPE int TclCompileUnsetCmd(Tcl_Interp *interp,
jpayne@69 3833 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3834 struct CompileEnv *envPtr);
jpayne@69 3835 MODULE_SCOPE int TclCompileUpvarCmd(Tcl_Interp *interp,
jpayne@69 3836 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3837 struct CompileEnv *envPtr);
jpayne@69 3838 MODULE_SCOPE int TclCompileVariableCmd(Tcl_Interp *interp,
jpayne@69 3839 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3840 struct CompileEnv *envPtr);
jpayne@69 3841 MODULE_SCOPE int TclCompileWhileCmd(Tcl_Interp *interp,
jpayne@69 3842 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3843 struct CompileEnv *envPtr);
jpayne@69 3844 MODULE_SCOPE int TclCompileYieldCmd(Tcl_Interp *interp,
jpayne@69 3845 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3846 struct CompileEnv *envPtr);
jpayne@69 3847 MODULE_SCOPE int TclCompileYieldToCmd(Tcl_Interp *interp,
jpayne@69 3848 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3849 struct CompileEnv *envPtr);
jpayne@69 3850 MODULE_SCOPE int TclCompileBasic0ArgCmd(Tcl_Interp *interp,
jpayne@69 3851 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3852 struct CompileEnv *envPtr);
jpayne@69 3853 MODULE_SCOPE int TclCompileBasic1ArgCmd(Tcl_Interp *interp,
jpayne@69 3854 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3855 struct CompileEnv *envPtr);
jpayne@69 3856 MODULE_SCOPE int TclCompileBasic2ArgCmd(Tcl_Interp *interp,
jpayne@69 3857 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3858 struct CompileEnv *envPtr);
jpayne@69 3859 MODULE_SCOPE int TclCompileBasic3ArgCmd(Tcl_Interp *interp,
jpayne@69 3860 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3861 struct CompileEnv *envPtr);
jpayne@69 3862 MODULE_SCOPE int TclCompileBasic0Or1ArgCmd(Tcl_Interp *interp,
jpayne@69 3863 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3864 struct CompileEnv *envPtr);
jpayne@69 3865 MODULE_SCOPE int TclCompileBasic1Or2ArgCmd(Tcl_Interp *interp,
jpayne@69 3866 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3867 struct CompileEnv *envPtr);
jpayne@69 3868 MODULE_SCOPE int TclCompileBasic2Or3ArgCmd(Tcl_Interp *interp,
jpayne@69 3869 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3870 struct CompileEnv *envPtr);
jpayne@69 3871 MODULE_SCOPE int TclCompileBasic0To2ArgCmd(Tcl_Interp *interp,
jpayne@69 3872 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3873 struct CompileEnv *envPtr);
jpayne@69 3874 MODULE_SCOPE int TclCompileBasic1To3ArgCmd(Tcl_Interp *interp,
jpayne@69 3875 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3876 struct CompileEnv *envPtr);
jpayne@69 3877 MODULE_SCOPE int TclCompileBasicMin0ArgCmd(Tcl_Interp *interp,
jpayne@69 3878 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3879 struct CompileEnv *envPtr);
jpayne@69 3880 MODULE_SCOPE int TclCompileBasicMin1ArgCmd(Tcl_Interp *interp,
jpayne@69 3881 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3882 struct CompileEnv *envPtr);
jpayne@69 3883 MODULE_SCOPE int TclCompileBasicMin2ArgCmd(Tcl_Interp *interp,
jpayne@69 3884 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3885 struct CompileEnv *envPtr);
jpayne@69 3886
jpayne@69 3887 MODULE_SCOPE int TclInvertOpCmd(ClientData clientData,
jpayne@69 3888 Tcl_Interp *interp, int objc,
jpayne@69 3889 Tcl_Obj *const objv[]);
jpayne@69 3890 MODULE_SCOPE int TclCompileInvertOpCmd(Tcl_Interp *interp,
jpayne@69 3891 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3892 struct CompileEnv *envPtr);
jpayne@69 3893 MODULE_SCOPE int TclNotOpCmd(ClientData clientData,
jpayne@69 3894 Tcl_Interp *interp, int objc,
jpayne@69 3895 Tcl_Obj *const objv[]);
jpayne@69 3896 MODULE_SCOPE int TclCompileNotOpCmd(Tcl_Interp *interp,
jpayne@69 3897 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3898 struct CompileEnv *envPtr);
jpayne@69 3899 MODULE_SCOPE int TclAddOpCmd(ClientData clientData,
jpayne@69 3900 Tcl_Interp *interp, int objc,
jpayne@69 3901 Tcl_Obj *const objv[]);
jpayne@69 3902 MODULE_SCOPE int TclCompileAddOpCmd(Tcl_Interp *interp,
jpayne@69 3903 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3904 struct CompileEnv *envPtr);
jpayne@69 3905 MODULE_SCOPE int TclMulOpCmd(ClientData clientData,
jpayne@69 3906 Tcl_Interp *interp, int objc,
jpayne@69 3907 Tcl_Obj *const objv[]);
jpayne@69 3908 MODULE_SCOPE int TclCompileMulOpCmd(Tcl_Interp *interp,
jpayne@69 3909 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3910 struct CompileEnv *envPtr);
jpayne@69 3911 MODULE_SCOPE int TclAndOpCmd(ClientData clientData,
jpayne@69 3912 Tcl_Interp *interp, int objc,
jpayne@69 3913 Tcl_Obj *const objv[]);
jpayne@69 3914 MODULE_SCOPE int TclCompileAndOpCmd(Tcl_Interp *interp,
jpayne@69 3915 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3916 struct CompileEnv *envPtr);
jpayne@69 3917 MODULE_SCOPE int TclOrOpCmd(ClientData clientData,
jpayne@69 3918 Tcl_Interp *interp, int objc,
jpayne@69 3919 Tcl_Obj *const objv[]);
jpayne@69 3920 MODULE_SCOPE int TclCompileOrOpCmd(Tcl_Interp *interp,
jpayne@69 3921 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3922 struct CompileEnv *envPtr);
jpayne@69 3923 MODULE_SCOPE int TclXorOpCmd(ClientData clientData,
jpayne@69 3924 Tcl_Interp *interp, int objc,
jpayne@69 3925 Tcl_Obj *const objv[]);
jpayne@69 3926 MODULE_SCOPE int TclCompileXorOpCmd(Tcl_Interp *interp,
jpayne@69 3927 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3928 struct CompileEnv *envPtr);
jpayne@69 3929 MODULE_SCOPE int TclPowOpCmd(ClientData clientData,
jpayne@69 3930 Tcl_Interp *interp, int objc,
jpayne@69 3931 Tcl_Obj *const objv[]);
jpayne@69 3932 MODULE_SCOPE int TclCompilePowOpCmd(Tcl_Interp *interp,
jpayne@69 3933 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3934 struct CompileEnv *envPtr);
jpayne@69 3935 MODULE_SCOPE int TclLshiftOpCmd(ClientData clientData,
jpayne@69 3936 Tcl_Interp *interp, int objc,
jpayne@69 3937 Tcl_Obj *const objv[]);
jpayne@69 3938 MODULE_SCOPE int TclCompileLshiftOpCmd(Tcl_Interp *interp,
jpayne@69 3939 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3940 struct CompileEnv *envPtr);
jpayne@69 3941 MODULE_SCOPE int TclRshiftOpCmd(ClientData clientData,
jpayne@69 3942 Tcl_Interp *interp, int objc,
jpayne@69 3943 Tcl_Obj *const objv[]);
jpayne@69 3944 MODULE_SCOPE int TclCompileRshiftOpCmd(Tcl_Interp *interp,
jpayne@69 3945 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3946 struct CompileEnv *envPtr);
jpayne@69 3947 MODULE_SCOPE int TclModOpCmd(ClientData clientData,
jpayne@69 3948 Tcl_Interp *interp, int objc,
jpayne@69 3949 Tcl_Obj *const objv[]);
jpayne@69 3950 MODULE_SCOPE int TclCompileModOpCmd(Tcl_Interp *interp,
jpayne@69 3951 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3952 struct CompileEnv *envPtr);
jpayne@69 3953 MODULE_SCOPE int TclNeqOpCmd(ClientData clientData,
jpayne@69 3954 Tcl_Interp *interp, int objc,
jpayne@69 3955 Tcl_Obj *const objv[]);
jpayne@69 3956 MODULE_SCOPE int TclCompileNeqOpCmd(Tcl_Interp *interp,
jpayne@69 3957 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3958 struct CompileEnv *envPtr);
jpayne@69 3959 MODULE_SCOPE int TclStrneqOpCmd(ClientData clientData,
jpayne@69 3960 Tcl_Interp *interp, int objc,
jpayne@69 3961 Tcl_Obj *const objv[]);
jpayne@69 3962 MODULE_SCOPE int TclCompileStrneqOpCmd(Tcl_Interp *interp,
jpayne@69 3963 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3964 struct CompileEnv *envPtr);
jpayne@69 3965 MODULE_SCOPE int TclInOpCmd(ClientData clientData,
jpayne@69 3966 Tcl_Interp *interp, int objc,
jpayne@69 3967 Tcl_Obj *const objv[]);
jpayne@69 3968 MODULE_SCOPE int TclCompileInOpCmd(Tcl_Interp *interp,
jpayne@69 3969 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3970 struct CompileEnv *envPtr);
jpayne@69 3971 MODULE_SCOPE int TclNiOpCmd(ClientData clientData,
jpayne@69 3972 Tcl_Interp *interp, int objc,
jpayne@69 3973 Tcl_Obj *const objv[]);
jpayne@69 3974 MODULE_SCOPE int TclCompileNiOpCmd(Tcl_Interp *interp,
jpayne@69 3975 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3976 struct CompileEnv *envPtr);
jpayne@69 3977 MODULE_SCOPE int TclMinusOpCmd(ClientData clientData,
jpayne@69 3978 Tcl_Interp *interp, int objc,
jpayne@69 3979 Tcl_Obj *const objv[]);
jpayne@69 3980 MODULE_SCOPE int TclCompileMinusOpCmd(Tcl_Interp *interp,
jpayne@69 3981 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3982 struct CompileEnv *envPtr);
jpayne@69 3983 MODULE_SCOPE int TclDivOpCmd(ClientData clientData,
jpayne@69 3984 Tcl_Interp *interp, int objc,
jpayne@69 3985 Tcl_Obj *const objv[]);
jpayne@69 3986 MODULE_SCOPE int TclCompileDivOpCmd(Tcl_Interp *interp,
jpayne@69 3987 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3988 struct CompileEnv *envPtr);
jpayne@69 3989 MODULE_SCOPE int TclCompileLessOpCmd(Tcl_Interp *interp,
jpayne@69 3990 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3991 struct CompileEnv *envPtr);
jpayne@69 3992 MODULE_SCOPE int TclCompileLeqOpCmd(Tcl_Interp *interp,
jpayne@69 3993 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3994 struct CompileEnv *envPtr);
jpayne@69 3995 MODULE_SCOPE int TclCompileGreaterOpCmd(Tcl_Interp *interp,
jpayne@69 3996 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 3997 struct CompileEnv *envPtr);
jpayne@69 3998 MODULE_SCOPE int TclCompileGeqOpCmd(Tcl_Interp *interp,
jpayne@69 3999 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 4000 struct CompileEnv *envPtr);
jpayne@69 4001 MODULE_SCOPE int TclCompileEqOpCmd(Tcl_Interp *interp,
jpayne@69 4002 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 4003 struct CompileEnv *envPtr);
jpayne@69 4004 MODULE_SCOPE int TclCompileStreqOpCmd(Tcl_Interp *interp,
jpayne@69 4005 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 4006 struct CompileEnv *envPtr);
jpayne@69 4007
jpayne@69 4008 MODULE_SCOPE int TclCompileAssembleCmd(Tcl_Interp *interp,
jpayne@69 4009 Tcl_Parse *parsePtr, Command *cmdPtr,
jpayne@69 4010 struct CompileEnv *envPtr);
jpayne@69 4011
jpayne@69 4012 /*
jpayne@69 4013 * Functions defined in generic/tclVar.c and currently exported only for use
jpayne@69 4014 * by the bytecode compiler and engine. Some of these could later be placed in
jpayne@69 4015 * the public interface.
jpayne@69 4016 */
jpayne@69 4017
jpayne@69 4018 MODULE_SCOPE Var * TclObjLookupVarEx(Tcl_Interp * interp,
jpayne@69 4019 Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr, int flags,
jpayne@69 4020 const char *msg, const int createPart1,
jpayne@69 4021 const int createPart2, Var **arrayPtrPtr);
jpayne@69 4022 MODULE_SCOPE Var * TclLookupArrayElement(Tcl_Interp *interp,
jpayne@69 4023 Tcl_Obj *arrayNamePtr, Tcl_Obj *elNamePtr,
jpayne@69 4024 const int flags, const char *msg,
jpayne@69 4025 const int createPart1, const int createPart2,
jpayne@69 4026 Var *arrayPtr, int index);
jpayne@69 4027 MODULE_SCOPE Tcl_Obj * TclPtrGetVarIdx(Tcl_Interp *interp,
jpayne@69 4028 Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr,
jpayne@69 4029 Tcl_Obj *part2Ptr, const int flags, int index);
jpayne@69 4030 MODULE_SCOPE Tcl_Obj * TclPtrSetVarIdx(Tcl_Interp *interp,
jpayne@69 4031 Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr,
jpayne@69 4032 Tcl_Obj *part2Ptr, Tcl_Obj *newValuePtr,
jpayne@69 4033 const int flags, int index);
jpayne@69 4034 MODULE_SCOPE Tcl_Obj * TclPtrIncrObjVarIdx(Tcl_Interp *interp,
jpayne@69 4035 Var *varPtr, Var *arrayPtr, Tcl_Obj *part1Ptr,
jpayne@69 4036 Tcl_Obj *part2Ptr, Tcl_Obj *incrPtr,
jpayne@69 4037 const int flags, int index);
jpayne@69 4038 MODULE_SCOPE int TclPtrObjMakeUpvarIdx(Tcl_Interp *interp,
jpayne@69 4039 Var *otherPtr, Tcl_Obj *myNamePtr, int myFlags,
jpayne@69 4040 int index);
jpayne@69 4041 MODULE_SCOPE int TclPtrUnsetVarIdx(Tcl_Interp *interp, Var *varPtr,
jpayne@69 4042 Var *arrayPtr, Tcl_Obj *part1Ptr,
jpayne@69 4043 Tcl_Obj *part2Ptr, const int flags,
jpayne@69 4044 int index);
jpayne@69 4045 MODULE_SCOPE void TclInvalidateNsPath(Namespace *nsPtr);
jpayne@69 4046 MODULE_SCOPE void TclFindArrayPtrElements(Var *arrayPtr,
jpayne@69 4047 Tcl_HashTable *tablePtr);
jpayne@69 4048
jpayne@69 4049 /*
jpayne@69 4050 * The new extended interface to the variable traces.
jpayne@69 4051 */
jpayne@69 4052
jpayne@69 4053 MODULE_SCOPE int TclObjCallVarTraces(Interp *iPtr, Var *arrayPtr,
jpayne@69 4054 Var *varPtr, Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
jpayne@69 4055 int flags, int leaveErrMsg, int index);
jpayne@69 4056
jpayne@69 4057 /*
jpayne@69 4058 * So tclObj.c and tclDictObj.c can share these implementations.
jpayne@69 4059 */
jpayne@69 4060
jpayne@69 4061 MODULE_SCOPE int TclCompareObjKeys(void *keyPtr, Tcl_HashEntry *hPtr);
jpayne@69 4062 MODULE_SCOPE void TclFreeObjEntry(Tcl_HashEntry *hPtr);
jpayne@69 4063 MODULE_SCOPE unsigned TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr);
jpayne@69 4064
jpayne@69 4065 MODULE_SCOPE int TclFullFinalizationRequested(void);
jpayne@69 4066
jpayne@69 4067 /*
jpayne@69 4068 * Utility routines for encoding index values as integers. Used by both
jpayne@69 4069 * some of the command compilers and by [lsort] and [lsearch].
jpayne@69 4070 */
jpayne@69 4071
jpayne@69 4072 MODULE_SCOPE int TclIndexEncode(Tcl_Interp *interp, Tcl_Obj *objPtr,
jpayne@69 4073 int before, int after, int *indexPtr);
jpayne@69 4074 MODULE_SCOPE int TclIndexDecode(int encoded, int endValue);
jpayne@69 4075
jpayne@69 4076 MODULE_SCOPE void TclBN_s_mp_reverse(unsigned char *s, size_t len);
jpayne@69 4077
jpayne@69 4078 /* Constants used in index value encoding routines. */
jpayne@69 4079 #define TCL_INDEX_END (-2)
jpayne@69 4080 #define TCL_INDEX_BEFORE (-1)
jpayne@69 4081 #define TCL_INDEX_START (0)
jpayne@69 4082 #define TCL_INDEX_AFTER (INT_MAX)
jpayne@69 4083
jpayne@69 4084 /*
jpayne@69 4085 *----------------------------------------------------------------
jpayne@69 4086 * Macros used by the Tcl core to create and release Tcl objects.
jpayne@69 4087 * TclNewObj(objPtr) creates a new object denoting an empty string.
jpayne@69 4088 * TclDecrRefCount(objPtr) decrements the object's reference count, and frees
jpayne@69 4089 * the object if its reference count is zero. These macros are inline versions
jpayne@69 4090 * of Tcl_NewObj() and Tcl_DecrRefCount(). Notice that the names differ in not
jpayne@69 4091 * having a "_" after the "Tcl". Notice also that these macros reference their
jpayne@69 4092 * argument more than once, so you should avoid calling them with an
jpayne@69 4093 * expression that is expensive to compute or has side effects. The ANSI C
jpayne@69 4094 * "prototypes" for these macros are:
jpayne@69 4095 *
jpayne@69 4096 * MODULE_SCOPE void TclNewObj(Tcl_Obj *objPtr);
jpayne@69 4097 * MODULE_SCOPE void TclDecrRefCount(Tcl_Obj *objPtr);
jpayne@69 4098 *
jpayne@69 4099 * These macros are defined in terms of two macros that depend on memory
jpayne@69 4100 * allocator in use: TclAllocObjStorage, TclFreeObjStorage. They are defined
jpayne@69 4101 * below.
jpayne@69 4102 *----------------------------------------------------------------
jpayne@69 4103 */
jpayne@69 4104
jpayne@69 4105 /*
jpayne@69 4106 * DTrace object allocation probe macros.
jpayne@69 4107 */
jpayne@69 4108
jpayne@69 4109 #ifdef USE_DTRACE
jpayne@69 4110 #ifndef _TCLDTRACE_H
jpayne@69 4111 #include "tclDTrace.h"
jpayne@69 4112 #endif
jpayne@69 4113 #define TCL_DTRACE_OBJ_CREATE(objPtr) TCL_OBJ_CREATE(objPtr)
jpayne@69 4114 #define TCL_DTRACE_OBJ_FREE(objPtr) TCL_OBJ_FREE(objPtr)
jpayne@69 4115 #else /* USE_DTRACE */
jpayne@69 4116 #define TCL_DTRACE_OBJ_CREATE(objPtr) {}
jpayne@69 4117 #define TCL_DTRACE_OBJ_FREE(objPtr) {}
jpayne@69 4118 #endif /* USE_DTRACE */
jpayne@69 4119
jpayne@69 4120 #ifdef TCL_COMPILE_STATS
jpayne@69 4121 # define TclIncrObjsAllocated() \
jpayne@69 4122 tclObjsAlloced++
jpayne@69 4123 # define TclIncrObjsFreed() \
jpayne@69 4124 tclObjsFreed++
jpayne@69 4125 #else
jpayne@69 4126 # define TclIncrObjsAllocated()
jpayne@69 4127 # define TclIncrObjsFreed()
jpayne@69 4128 #endif /* TCL_COMPILE_STATS */
jpayne@69 4129
jpayne@69 4130 # define TclAllocObjStorage(objPtr) \
jpayne@69 4131 TclAllocObjStorageEx(NULL, (objPtr))
jpayne@69 4132
jpayne@69 4133 # define TclFreeObjStorage(objPtr) \
jpayne@69 4134 TclFreeObjStorageEx(NULL, (objPtr))
jpayne@69 4135
jpayne@69 4136 #ifndef TCL_MEM_DEBUG
jpayne@69 4137 # define TclNewObj(objPtr) \
jpayne@69 4138 TclIncrObjsAllocated(); \
jpayne@69 4139 TclAllocObjStorage(objPtr); \
jpayne@69 4140 (objPtr)->refCount = 0; \
jpayne@69 4141 (objPtr)->bytes = tclEmptyStringRep; \
jpayne@69 4142 (objPtr)->length = 0; \
jpayne@69 4143 (objPtr)->typePtr = NULL; \
jpayne@69 4144 TCL_DTRACE_OBJ_CREATE(objPtr)
jpayne@69 4145
jpayne@69 4146 /*
jpayne@69 4147 * Invalidate the string rep first so we can use the bytes value for our
jpayne@69 4148 * pointer chain, and signal an obj deletion (as opposed to shimmering) with
jpayne@69 4149 * 'length == -1'.
jpayne@69 4150 * Use empty 'if ; else' to handle use in unbraced outer if/else conditions.
jpayne@69 4151 */
jpayne@69 4152
jpayne@69 4153 # define TclDecrRefCount(objPtr) \
jpayne@69 4154 if ((objPtr)->refCount-- > 1) ; else { \
jpayne@69 4155 if (!(objPtr)->typePtr || !(objPtr)->typePtr->freeIntRepProc) { \
jpayne@69 4156 TCL_DTRACE_OBJ_FREE(objPtr); \
jpayne@69 4157 if ((objPtr)->bytes \
jpayne@69 4158 && ((objPtr)->bytes != tclEmptyStringRep)) { \
jpayne@69 4159 ckfree((char *) (objPtr)->bytes); \
jpayne@69 4160 } \
jpayne@69 4161 (objPtr)->length = -1; \
jpayne@69 4162 TclFreeObjStorage(objPtr); \
jpayne@69 4163 TclIncrObjsFreed(); \
jpayne@69 4164 } else { \
jpayne@69 4165 TclFreeObj(objPtr); \
jpayne@69 4166 } \
jpayne@69 4167 }
jpayne@69 4168
jpayne@69 4169 #if defined(PURIFY)
jpayne@69 4170
jpayne@69 4171 /*
jpayne@69 4172 * The PURIFY mode is like the regular mode, but instead of doing block
jpayne@69 4173 * Tcl_Obj allocation and keeping a freed list for efficiency, it always
jpayne@69 4174 * allocates and frees a single Tcl_Obj so that tools like Purify can better
jpayne@69 4175 * track memory leaks.
jpayne@69 4176 */
jpayne@69 4177
jpayne@69 4178 # define TclAllocObjStorageEx(interp, objPtr) \
jpayne@69 4179 (objPtr) = (Tcl_Obj *) ckalloc(sizeof(Tcl_Obj))
jpayne@69 4180
jpayne@69 4181 # define TclFreeObjStorageEx(interp, objPtr) \
jpayne@69 4182 ckfree((char *) (objPtr))
jpayne@69 4183
jpayne@69 4184 #undef USE_THREAD_ALLOC
jpayne@69 4185 #undef USE_TCLALLOC
jpayne@69 4186 #elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
jpayne@69 4187
jpayne@69 4188 /*
jpayne@69 4189 * The TCL_THREADS mode is like the regular mode but allocates Tcl_Obj's from
jpayne@69 4190 * per-thread caches.
jpayne@69 4191 */
jpayne@69 4192
jpayne@69 4193 MODULE_SCOPE Tcl_Obj * TclThreadAllocObj(void);
jpayne@69 4194 MODULE_SCOPE void TclThreadFreeObj(Tcl_Obj *);
jpayne@69 4195 MODULE_SCOPE Tcl_Mutex *TclpNewAllocMutex(void);
jpayne@69 4196 MODULE_SCOPE void TclFreeAllocCache(void *);
jpayne@69 4197 MODULE_SCOPE void * TclpGetAllocCache(void);
jpayne@69 4198 MODULE_SCOPE void TclpSetAllocCache(void *);
jpayne@69 4199 MODULE_SCOPE void TclpFreeAllocMutex(Tcl_Mutex *mutex);
jpayne@69 4200 MODULE_SCOPE void TclpFreeAllocCache(void *);
jpayne@69 4201
jpayne@69 4202 /*
jpayne@69 4203 * These macros need to be kept in sync with the code of TclThreadAllocObj()
jpayne@69 4204 * and TclThreadFreeObj().
jpayne@69 4205 *
jpayne@69 4206 * Note that the optimiser should resolve the case (interp==NULL) at compile
jpayne@69 4207 * time.
jpayne@69 4208 */
jpayne@69 4209
jpayne@69 4210 # define ALLOC_NOBJHIGH 1200
jpayne@69 4211
jpayne@69 4212 # define TclAllocObjStorageEx(interp, objPtr) \
jpayne@69 4213 do { \
jpayne@69 4214 AllocCache *cachePtr; \
jpayne@69 4215 if (((interp) == NULL) || \
jpayne@69 4216 ((cachePtr = ((Interp *)(interp))->allocCache), \
jpayne@69 4217 (cachePtr->numObjects == 0))) { \
jpayne@69 4218 (objPtr) = TclThreadAllocObj(); \
jpayne@69 4219 } else { \
jpayne@69 4220 (objPtr) = cachePtr->firstObjPtr; \
jpayne@69 4221 cachePtr->firstObjPtr = (Tcl_Obj *)(objPtr)->internalRep.twoPtrValue.ptr1; \
jpayne@69 4222 --cachePtr->numObjects; \
jpayne@69 4223 } \
jpayne@69 4224 } while (0)
jpayne@69 4225
jpayne@69 4226 # define TclFreeObjStorageEx(interp, objPtr) \
jpayne@69 4227 do { \
jpayne@69 4228 AllocCache *cachePtr; \
jpayne@69 4229 if (((interp) == NULL) || \
jpayne@69 4230 ((cachePtr = ((Interp *)(interp))->allocCache), \
jpayne@69 4231 ((cachePtr->numObjects == 0) || \
jpayne@69 4232 (cachePtr->numObjects >= ALLOC_NOBJHIGH)))) { \
jpayne@69 4233 TclThreadFreeObj(objPtr); \
jpayne@69 4234 } else { \
jpayne@69 4235 (objPtr)->internalRep.twoPtrValue.ptr1 = cachePtr->firstObjPtr; \
jpayne@69 4236 cachePtr->firstObjPtr = objPtr; \
jpayne@69 4237 ++cachePtr->numObjects; \
jpayne@69 4238 } \
jpayne@69 4239 } while (0)
jpayne@69 4240
jpayne@69 4241 #else /* not PURIFY or USE_THREAD_ALLOC */
jpayne@69 4242
jpayne@69 4243 #if defined(USE_TCLALLOC) && USE_TCLALLOC
jpayne@69 4244 MODULE_SCOPE void TclFinalizeAllocSubsystem();
jpayne@69 4245 MODULE_SCOPE void TclInitAlloc();
jpayne@69 4246 #else
jpayne@69 4247 # define USE_TCLALLOC 0
jpayne@69 4248 #endif
jpayne@69 4249
jpayne@69 4250 #ifdef TCL_THREADS
jpayne@69 4251 /* declared in tclObj.c */
jpayne@69 4252 MODULE_SCOPE Tcl_Mutex tclObjMutex;
jpayne@69 4253 #endif
jpayne@69 4254
jpayne@69 4255 # define TclAllocObjStorageEx(interp, objPtr) \
jpayne@69 4256 do { \
jpayne@69 4257 Tcl_MutexLock(&tclObjMutex); \
jpayne@69 4258 if (tclFreeObjList == NULL) { \
jpayne@69 4259 TclAllocateFreeObjects(); \
jpayne@69 4260 } \
jpayne@69 4261 (objPtr) = tclFreeObjList; \
jpayne@69 4262 tclFreeObjList = (Tcl_Obj *) \
jpayne@69 4263 tclFreeObjList->internalRep.twoPtrValue.ptr1; \
jpayne@69 4264 Tcl_MutexUnlock(&tclObjMutex); \
jpayne@69 4265 } while (0)
jpayne@69 4266
jpayne@69 4267 # define TclFreeObjStorageEx(interp, objPtr) \
jpayne@69 4268 do { \
jpayne@69 4269 Tcl_MutexLock(&tclObjMutex); \
jpayne@69 4270 (objPtr)->internalRep.twoPtrValue.ptr1 = (void *) tclFreeObjList; \
jpayne@69 4271 tclFreeObjList = (objPtr); \
jpayne@69 4272 Tcl_MutexUnlock(&tclObjMutex); \
jpayne@69 4273 } while (0)
jpayne@69 4274 #endif
jpayne@69 4275
jpayne@69 4276 #else /* TCL_MEM_DEBUG */
jpayne@69 4277 MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file,
jpayne@69 4278 int line);
jpayne@69 4279
jpayne@69 4280 # define TclDbNewObj(objPtr, file, line) \
jpayne@69 4281 do { \
jpayne@69 4282 TclIncrObjsAllocated(); \
jpayne@69 4283 (objPtr) = (Tcl_Obj *) \
jpayne@69 4284 Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
jpayne@69 4285 TclDbInitNewObj((objPtr), (file), (line)); \
jpayne@69 4286 TCL_DTRACE_OBJ_CREATE(objPtr); \
jpayne@69 4287 } while (0)
jpayne@69 4288
jpayne@69 4289 # define TclNewObj(objPtr) \
jpayne@69 4290 TclDbNewObj(objPtr, __FILE__, __LINE__);
jpayne@69 4291
jpayne@69 4292 # define TclDecrRefCount(objPtr) \
jpayne@69 4293 Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
jpayne@69 4294
jpayne@69 4295 # define TclNewListObjDirect(objc, objv) \
jpayne@69 4296 TclDbNewListObjDirect(objc, objv, __FILE__, __LINE__)
jpayne@69 4297
jpayne@69 4298 #undef USE_THREAD_ALLOC
jpayne@69 4299 #endif /* TCL_MEM_DEBUG */
jpayne@69 4300
jpayne@69 4301 /*
jpayne@69 4302 *----------------------------------------------------------------
jpayne@69 4303 * Macro used by the Tcl core to set a Tcl_Obj's string representation to a
jpayne@69 4304 * copy of the "len" bytes starting at "bytePtr". This code works even if the
jpayne@69 4305 * byte array contains NULLs as long as the length is correct. Because "len"
jpayne@69 4306 * is referenced multiple times, it should be as simple an expression as
jpayne@69 4307 * possible. The ANSI C "prototype" for this macro is:
jpayne@69 4308 *
jpayne@69 4309 * MODULE_SCOPE void TclInitStringRep(Tcl_Obj *objPtr, char *bytePtr, int len);
jpayne@69 4310 *
jpayne@69 4311 * This macro should only be called on an unshared objPtr where
jpayne@69 4312 * objPtr->typePtr->freeIntRepProc == NULL
jpayne@69 4313 *----------------------------------------------------------------
jpayne@69 4314 */
jpayne@69 4315
jpayne@69 4316 #define TclInitStringRep(objPtr, bytePtr, len) \
jpayne@69 4317 if ((len) == 0) { \
jpayne@69 4318 (objPtr)->bytes = tclEmptyStringRep; \
jpayne@69 4319 (objPtr)->length = 0; \
jpayne@69 4320 } else { \
jpayne@69 4321 (objPtr)->bytes = (char *) ckalloc((unsigned int)(len) + 1U); \
jpayne@69 4322 memcpy((objPtr)->bytes, (bytePtr), (len)); \
jpayne@69 4323 (objPtr)->bytes[len] = '\0'; \
jpayne@69 4324 (objPtr)->length = (len); \
jpayne@69 4325 }
jpayne@69 4326
jpayne@69 4327 /*
jpayne@69 4328 *----------------------------------------------------------------
jpayne@69 4329 * Macro used by the Tcl core to get the string representation's byte array
jpayne@69 4330 * pointer from a Tcl_Obj. This is an inline version of Tcl_GetString(). The
jpayne@69 4331 * macro's expression result is the string rep's byte pointer which might be
jpayne@69 4332 * NULL. The bytes referenced by this pointer must not be modified by the
jpayne@69 4333 * caller. The ANSI C "prototype" for this macro is:
jpayne@69 4334 *
jpayne@69 4335 * MODULE_SCOPE char * TclGetString(Tcl_Obj *objPtr);
jpayne@69 4336 *----------------------------------------------------------------
jpayne@69 4337 */
jpayne@69 4338
jpayne@69 4339 #define TclGetString(objPtr) \
jpayne@69 4340 ((objPtr)->bytes? (objPtr)->bytes : Tcl_GetString((objPtr)))
jpayne@69 4341
jpayne@69 4342 #define TclGetStringFromObj(objPtr, lenPtr) \
jpayne@69 4343 ((objPtr)->bytes \
jpayne@69 4344 ? (*(lenPtr) = (objPtr)->length, (objPtr)->bytes) \
jpayne@69 4345 : Tcl_GetStringFromObj((objPtr), (lenPtr)))
jpayne@69 4346
jpayne@69 4347 /*
jpayne@69 4348 *----------------------------------------------------------------
jpayne@69 4349 * Macro used by the Tcl core to clean out an object's internal
jpayne@69 4350 * representation. Does not actually reset the rep's bytes. The ANSI C
jpayne@69 4351 * "prototype" for this macro is:
jpayne@69 4352 *
jpayne@69 4353 * MODULE_SCOPE void TclFreeIntRep(Tcl_Obj *objPtr);
jpayne@69 4354 *----------------------------------------------------------------
jpayne@69 4355 */
jpayne@69 4356
jpayne@69 4357 #define TclFreeIntRep(objPtr) \
jpayne@69 4358 if ((objPtr)->typePtr != NULL) { \
jpayne@69 4359 if ((objPtr)->typePtr->freeIntRepProc != NULL) { \
jpayne@69 4360 (objPtr)->typePtr->freeIntRepProc(objPtr); \
jpayne@69 4361 } \
jpayne@69 4362 (objPtr)->typePtr = NULL; \
jpayne@69 4363 }
jpayne@69 4364
jpayne@69 4365 /*
jpayne@69 4366 *----------------------------------------------------------------
jpayne@69 4367 * Macro used by the Tcl core to clean out an object's string representation.
jpayne@69 4368 * The ANSI C "prototype" for this macro is:
jpayne@69 4369 *
jpayne@69 4370 * MODULE_SCOPE void TclInvalidateStringRep(Tcl_Obj *objPtr);
jpayne@69 4371 *----------------------------------------------------------------
jpayne@69 4372 */
jpayne@69 4373
jpayne@69 4374 #define TclInvalidateStringRep(objPtr) \
jpayne@69 4375 do { \
jpayne@69 4376 Tcl_Obj *_isobjPtr = (Tcl_Obj *)(objPtr); \
jpayne@69 4377 if (_isobjPtr->bytes != NULL) { \
jpayne@69 4378 if (_isobjPtr->bytes != tclEmptyStringRep) { \
jpayne@69 4379 ckfree((char *)_isobjPtr->bytes); \
jpayne@69 4380 } \
jpayne@69 4381 _isobjPtr->bytes = NULL; \
jpayne@69 4382 } \
jpayne@69 4383 } while (0)
jpayne@69 4384
jpayne@69 4385 #define TclHasStringRep(objPtr) \
jpayne@69 4386 ((objPtr)->bytes != NULL)
jpayne@69 4387
jpayne@69 4388 /*
jpayne@69 4389 *----------------------------------------------------------------
jpayne@69 4390 * Macros used by the Tcl core to grow Tcl_Token arrays. They use the same
jpayne@69 4391 * growth algorithm as used in tclStringObj.c for growing strings. The ANSI C
jpayne@69 4392 * "prototype" for this macro is:
jpayne@69 4393 *
jpayne@69 4394 * MODULE_SCOPE void TclGrowTokenArray(Tcl_Token *tokenPtr, int used,
jpayne@69 4395 * int available, int append,
jpayne@69 4396 * Tcl_Token *staticPtr);
jpayne@69 4397 * MODULE_SCOPE void TclGrowParseTokenArray(Tcl_Parse *parsePtr,
jpayne@69 4398 * int append);
jpayne@69 4399 *----------------------------------------------------------------
jpayne@69 4400 */
jpayne@69 4401
jpayne@69 4402 /* General tuning for minimum growth in Tcl growth algorithms */
jpayne@69 4403 #ifndef TCL_MIN_GROWTH
jpayne@69 4404 # ifdef TCL_GROWTH_MIN_ALLOC
jpayne@69 4405 /* Support for any legacy tuners */
jpayne@69 4406 # define TCL_MIN_GROWTH TCL_GROWTH_MIN_ALLOC
jpayne@69 4407 # else
jpayne@69 4408 # define TCL_MIN_GROWTH 1024
jpayne@69 4409 # endif
jpayne@69 4410 #endif
jpayne@69 4411
jpayne@69 4412 /* Token growth tuning, default to the general value. */
jpayne@69 4413 #ifndef TCL_MIN_TOKEN_GROWTH
jpayne@69 4414 #define TCL_MIN_TOKEN_GROWTH TCL_MIN_GROWTH/sizeof(Tcl_Token)
jpayne@69 4415 #endif
jpayne@69 4416
jpayne@69 4417 #define TCL_MAX_TOKENS (int)(UINT_MAX / sizeof(Tcl_Token))
jpayne@69 4418 #define TclGrowTokenArray(tokenPtr, used, available, append, staticPtr) \
jpayne@69 4419 do { \
jpayne@69 4420 int _needed = (used) + (append); \
jpayne@69 4421 if (_needed > TCL_MAX_TOKENS) { \
jpayne@69 4422 Tcl_Panic("max # of tokens for a Tcl parse (%d) exceeded", \
jpayne@69 4423 TCL_MAX_TOKENS); \
jpayne@69 4424 } \
jpayne@69 4425 if (_needed > (available)) { \
jpayne@69 4426 int allocated = 2 * _needed; \
jpayne@69 4427 Tcl_Token *oldPtr = (tokenPtr); \
jpayne@69 4428 Tcl_Token *newPtr; \
jpayne@69 4429 if (oldPtr == (staticPtr)) { \
jpayne@69 4430 oldPtr = NULL; \
jpayne@69 4431 } \
jpayne@69 4432 if (allocated > TCL_MAX_TOKENS) { \
jpayne@69 4433 allocated = TCL_MAX_TOKENS; \
jpayne@69 4434 } \
jpayne@69 4435 newPtr = (Tcl_Token *) attemptckrealloc((char *) oldPtr, \
jpayne@69 4436 (unsigned int) (allocated * sizeof(Tcl_Token))); \
jpayne@69 4437 if (newPtr == NULL) { \
jpayne@69 4438 allocated = _needed + (append) + TCL_MIN_TOKEN_GROWTH; \
jpayne@69 4439 if (allocated > TCL_MAX_TOKENS) { \
jpayne@69 4440 allocated = TCL_MAX_TOKENS; \
jpayne@69 4441 } \
jpayne@69 4442 newPtr = (Tcl_Token *) ckrealloc((char *) oldPtr, \
jpayne@69 4443 (unsigned int) (allocated * sizeof(Tcl_Token))); \
jpayne@69 4444 } \
jpayne@69 4445 (available) = allocated; \
jpayne@69 4446 if (oldPtr == NULL) { \
jpayne@69 4447 memcpy(newPtr, staticPtr, \
jpayne@69 4448 (size_t) ((used) * sizeof(Tcl_Token))); \
jpayne@69 4449 } \
jpayne@69 4450 (tokenPtr) = newPtr; \
jpayne@69 4451 } \
jpayne@69 4452 } while (0)
jpayne@69 4453
jpayne@69 4454 #define TclGrowParseTokenArray(parsePtr, append) \
jpayne@69 4455 TclGrowTokenArray((parsePtr)->tokenPtr, (parsePtr)->numTokens, \
jpayne@69 4456 (parsePtr)->tokensAvailable, (append), \
jpayne@69 4457 (parsePtr)->staticTokens)
jpayne@69 4458
jpayne@69 4459 /*
jpayne@69 4460 *----------------------------------------------------------------
jpayne@69 4461 * Macro used by the Tcl core get a unicode char from a utf string. It checks
jpayne@69 4462 * to see if we have a one-byte utf char before calling the real
jpayne@69 4463 * Tcl_UtfToUniChar, as this will save a lot of time for primarily ASCII
jpayne@69 4464 * string handling. The macro's expression result is 1 for the 1-byte case or
jpayne@69 4465 * the result of Tcl_UtfToUniChar. The ANSI C "prototype" for this macro is:
jpayne@69 4466 *
jpayne@69 4467 * MODULE_SCOPE int TclUtfToUniChar(const char *string, Tcl_UniChar *ch);
jpayne@69 4468 *----------------------------------------------------------------
jpayne@69 4469 */
jpayne@69 4470
jpayne@69 4471 #define TclUtfToUniChar(str, chPtr) \
jpayne@69 4472 (((UCHAR(*(str))) < 0x80) ? \
jpayne@69 4473 ((*(chPtr) = UCHAR(*(str))), 1) \
jpayne@69 4474 : Tcl_UtfToUniChar(str, chPtr))
jpayne@69 4475
jpayne@69 4476 /*
jpayne@69 4477 *----------------------------------------------------------------
jpayne@69 4478 * Macro counterpart of the Tcl_NumUtfChars() function. To be used in speed-
jpayne@69 4479 * -sensitive points where it pays to avoid a function call in the common case
jpayne@69 4480 * of counting along a string of all one-byte characters. The ANSI C
jpayne@69 4481 * "prototype" for this macro is:
jpayne@69 4482 *
jpayne@69 4483 * MODULE_SCOPE void TclNumUtfChars(int numChars, const char *bytes,
jpayne@69 4484 * int numBytes);
jpayne@69 4485 *----------------------------------------------------------------
jpayne@69 4486 */
jpayne@69 4487
jpayne@69 4488 #define TclNumUtfChars(numChars, bytes, numBytes) \
jpayne@69 4489 do { \
jpayne@69 4490 int _count, _i = (numBytes); \
jpayne@69 4491 unsigned char *_str = (unsigned char *) (bytes); \
jpayne@69 4492 while (_i && (*_str < 0xC0)) { _i--; _str++; } \
jpayne@69 4493 _count = (numBytes) - _i; \
jpayne@69 4494 if (_i) { \
jpayne@69 4495 _count += Tcl_NumUtfChars((bytes) + _count, _i); \
jpayne@69 4496 } \
jpayne@69 4497 (numChars) = _count; \
jpayne@69 4498 } while (0);
jpayne@69 4499
jpayne@69 4500 #define TclUtfPrev(src, start) \
jpayne@69 4501 (((src) < (start)+2) ? (start) : \
jpayne@69 4502 (UCHAR(*((src) - 1))) < 0x80 ? (src)-1 : \
jpayne@69 4503 Tcl_UtfPrev(src, start))
jpayne@69 4504
jpayne@69 4505 /*
jpayne@69 4506 *----------------------------------------------------------------
jpayne@69 4507 * Macro that encapsulates the logic that determines when it is safe to
jpayne@69 4508 * interpret a string as a byte array directly. In summary, the object must be
jpayne@69 4509 * a byte array and must not have a string representation (as the operations
jpayne@69 4510 * that it is used in are defined on strings, not byte arrays). Theoretically
jpayne@69 4511 * it is possible to also be efficient in the case where the object's bytes
jpayne@69 4512 * field is filled by generation from the byte array (c.f. list canonicality)
jpayne@69 4513 * but we don't do that at the moment since this is purely about efficiency.
jpayne@69 4514 * The ANSI C "prototype" for this macro is:
jpayne@69 4515 *
jpayne@69 4516 * MODULE_SCOPE int TclIsPureByteArray(Tcl_Obj *objPtr);
jpayne@69 4517 *----------------------------------------------------------------
jpayne@69 4518 */
jpayne@69 4519
jpayne@69 4520 #define TclIsPureByteArray(objPtr) \
jpayne@69 4521 (((objPtr)->typePtr==&tclByteArrayType) && ((objPtr)->bytes==NULL))
jpayne@69 4522 #define TclIsPureDict(objPtr) \
jpayne@69 4523 (((objPtr)->bytes==NULL) && ((objPtr)->typePtr==&tclDictType))
jpayne@69 4524
jpayne@69 4525 #define TclIsPureList(objPtr) \
jpayne@69 4526 (((objPtr)->bytes==NULL) && ((objPtr)->typePtr==&tclListType))
jpayne@69 4527
jpayne@69 4528 /*
jpayne@69 4529 *----------------------------------------------------------------
jpayne@69 4530 * Macro used by the Tcl core to compare Unicode strings. On big-endian
jpayne@69 4531 * systems we can use the more efficient memcmp, but this would not be
jpayne@69 4532 * lexically correct on little-endian systems. The ANSI C "prototype" for
jpayne@69 4533 * this macro is:
jpayne@69 4534 *
jpayne@69 4535 * MODULE_SCOPE int TclUniCharNcmp(const Tcl_UniChar *cs,
jpayne@69 4536 * const Tcl_UniChar *ct, unsigned long n);
jpayne@69 4537 *----------------------------------------------------------------
jpayne@69 4538 */
jpayne@69 4539
jpayne@69 4540 #if defined(WORDS_BIGENDIAN) && (TCL_UTF_MAX != 4)
jpayne@69 4541 # define TclUniCharNcmp(cs,ct,n) memcmp((cs),(ct),(n)*sizeof(Tcl_UniChar))
jpayne@69 4542 #else /* !WORDS_BIGENDIAN */
jpayne@69 4543 # define TclUniCharNcmp Tcl_UniCharNcmp
jpayne@69 4544 #endif /* WORDS_BIGENDIAN */
jpayne@69 4545
jpayne@69 4546 /*
jpayne@69 4547 *----------------------------------------------------------------
jpayne@69 4548 * Macro used by the Tcl core to increment a namespace's export epoch
jpayne@69 4549 * counter. The ANSI C "prototype" for this macro is:
jpayne@69 4550 *
jpayne@69 4551 * MODULE_SCOPE void TclInvalidateNsCmdLookup(Namespace *nsPtr);
jpayne@69 4552 *----------------------------------------------------------------
jpayne@69 4553 */
jpayne@69 4554
jpayne@69 4555 #define TclInvalidateNsCmdLookup(nsPtr) \
jpayne@69 4556 if ((nsPtr)->numExportPatterns) { \
jpayne@69 4557 (nsPtr)->exportLookupEpoch++; \
jpayne@69 4558 } \
jpayne@69 4559 if ((nsPtr)->commandPathLength) { \
jpayne@69 4560 (nsPtr)->cmdRefEpoch++; \
jpayne@69 4561 }
jpayne@69 4562
jpayne@69 4563 /*
jpayne@69 4564 *----------------------------------------------------------------------
jpayne@69 4565 *
jpayne@69 4566 * Core procedure added to libtommath for bignum manipulation.
jpayne@69 4567 *
jpayne@69 4568 *----------------------------------------------------------------------
jpayne@69 4569 */
jpayne@69 4570
jpayne@69 4571 MODULE_SCOPE Tcl_PackageInitProc TclTommath_Init;
jpayne@69 4572
jpayne@69 4573 /*
jpayne@69 4574 *----------------------------------------------------------------------
jpayne@69 4575 *
jpayne@69 4576 * External (platform specific) initialization routine, these declarations
jpayne@69 4577 * explicitly don't use EXTERN since this code does not get compiled into the
jpayne@69 4578 * library:
jpayne@69 4579 *
jpayne@69 4580 *----------------------------------------------------------------------
jpayne@69 4581 */
jpayne@69 4582
jpayne@69 4583 MODULE_SCOPE Tcl_PackageInitProc TclplatformtestInit;
jpayne@69 4584 MODULE_SCOPE Tcl_PackageInitProc TclObjTest_Init;
jpayne@69 4585 MODULE_SCOPE Tcl_PackageInitProc TclThread_Init;
jpayne@69 4586 MODULE_SCOPE Tcl_PackageInitProc Procbodytest_Init;
jpayne@69 4587 MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit;
jpayne@69 4588
jpayne@69 4589 /*
jpayne@69 4590 *----------------------------------------------------------------
jpayne@69 4591 * Macro used by the Tcl core to check whether a pattern has any characters
jpayne@69 4592 * special to [string match]. The ANSI C "prototype" for this macro is:
jpayne@69 4593 *
jpayne@69 4594 * MODULE_SCOPE int TclMatchIsTrivial(const char *pattern);
jpayne@69 4595 *----------------------------------------------------------------
jpayne@69 4596 */
jpayne@69 4597
jpayne@69 4598 #define TclMatchIsTrivial(pattern) \
jpayne@69 4599 (strpbrk((pattern), "*[?\\") == NULL)
jpayne@69 4600
jpayne@69 4601 /*
jpayne@69 4602 *----------------------------------------------------------------
jpayne@69 4603 * Macros used by the Tcl core to set a Tcl_Obj's numeric representation
jpayne@69 4604 * avoiding the corresponding function calls in time critical parts of the
jpayne@69 4605 * core. They should only be called on unshared objects. The ANSI C
jpayne@69 4606 * "prototypes" for these macros are:
jpayne@69 4607 *
jpayne@69 4608 * MODULE_SCOPE void TclSetIntObj(Tcl_Obj *objPtr, int intValue);
jpayne@69 4609 * MODULE_SCOPE void TclSetLongObj(Tcl_Obj *objPtr, long longValue);
jpayne@69 4610 * MODULE_SCOPE void TclSetBooleanObj(Tcl_Obj *objPtr, int intValue);
jpayne@69 4611 * MODULE_SCOPE void TclSetWideIntObj(Tcl_Obj *objPtr, Tcl_WideInt w);
jpayne@69 4612 * MODULE_SCOPE void TclSetDoubleObj(Tcl_Obj *objPtr, double d);
jpayne@69 4613 *----------------------------------------------------------------
jpayne@69 4614 */
jpayne@69 4615
jpayne@69 4616 #define TclSetLongObj(objPtr, i) \
jpayne@69 4617 do { \
jpayne@69 4618 TclInvalidateStringRep(objPtr); \
jpayne@69 4619 TclFreeIntRep(objPtr); \
jpayne@69 4620 (objPtr)->internalRep.longValue = (long)(i); \
jpayne@69 4621 (objPtr)->typePtr = &tclIntType; \
jpayne@69 4622 } while (0)
jpayne@69 4623
jpayne@69 4624 #define TclSetIntObj(objPtr, l) \
jpayne@69 4625 TclSetLongObj(objPtr, l)
jpayne@69 4626
jpayne@69 4627 /*
jpayne@69 4628 * NOTE: There is to be no such thing as a "pure" boolean. Boolean values set
jpayne@69 4629 * programmatically go straight to being "int" Tcl_Obj's, with value 0 or 1.
jpayne@69 4630 * The only "boolean" Tcl_Obj's shall be those holding the cached boolean
jpayne@69 4631 * value of strings like: "yes", "no", "true", "false", "on", "off".
jpayne@69 4632 */
jpayne@69 4633
jpayne@69 4634 #define TclSetBooleanObj(objPtr, b) \
jpayne@69 4635 TclSetLongObj(objPtr, (b)!=0);
jpayne@69 4636
jpayne@69 4637 #ifndef TCL_WIDE_INT_IS_LONG
jpayne@69 4638 #define TclSetWideIntObj(objPtr, w) \
jpayne@69 4639 do { \
jpayne@69 4640 TclInvalidateStringRep(objPtr); \
jpayne@69 4641 TclFreeIntRep(objPtr); \
jpayne@69 4642 (objPtr)->internalRep.wideValue = (Tcl_WideInt)(w); \
jpayne@69 4643 (objPtr)->typePtr = &tclWideIntType; \
jpayne@69 4644 } while (0)
jpayne@69 4645 #endif
jpayne@69 4646
jpayne@69 4647 #define TclSetDoubleObj(objPtr, d) \
jpayne@69 4648 do { \
jpayne@69 4649 TclInvalidateStringRep(objPtr); \
jpayne@69 4650 TclFreeIntRep(objPtr); \
jpayne@69 4651 (objPtr)->internalRep.doubleValue = (double)(d); \
jpayne@69 4652 (objPtr)->typePtr = &tclDoubleType; \
jpayne@69 4653 } while (0)
jpayne@69 4654
jpayne@69 4655 /*
jpayne@69 4656 *----------------------------------------------------------------
jpayne@69 4657 * Macros used by the Tcl core to create and initialise objects of standard
jpayne@69 4658 * types, avoiding the corresponding function calls in time critical parts of
jpayne@69 4659 * the core. The ANSI C "prototypes" for these macros are:
jpayne@69 4660 *
jpayne@69 4661 * MODULE_SCOPE void TclNewIntObj(Tcl_Obj *objPtr, int i);
jpayne@69 4662 * MODULE_SCOPE void TclNewLongObj(Tcl_Obj *objPtr, long l);
jpayne@69 4663 * MODULE_SCOPE void TclNewBooleanObj(Tcl_Obj *objPtr, int b);
jpayne@69 4664 * MODULE_SCOPE void TclNewWideObj(Tcl_Obj *objPtr, Tcl_WideInt w);
jpayne@69 4665 * MODULE_SCOPE void TclNewDoubleObj(Tcl_Obj *objPtr, double d);
jpayne@69 4666 * MODULE_SCOPE void TclNewStringObj(Tcl_Obj *objPtr, char *s, int len);
jpayne@69 4667 * MODULE_SCOPE void TclNewLiteralStringObj(Tcl_Obj*objPtr, char*sLiteral);
jpayne@69 4668 *
jpayne@69 4669 *----------------------------------------------------------------
jpayne@69 4670 */
jpayne@69 4671
jpayne@69 4672 #ifndef TCL_MEM_DEBUG
jpayne@69 4673 #define TclNewLongObj(objPtr, i) \
jpayne@69 4674 do { \
jpayne@69 4675 TclIncrObjsAllocated(); \
jpayne@69 4676 TclAllocObjStorage(objPtr); \
jpayne@69 4677 (objPtr)->refCount = 0; \
jpayne@69 4678 (objPtr)->bytes = NULL; \
jpayne@69 4679 (objPtr)->internalRep.longValue = (long)(i); \
jpayne@69 4680 (objPtr)->typePtr = &tclIntType; \
jpayne@69 4681 TCL_DTRACE_OBJ_CREATE(objPtr); \
jpayne@69 4682 } while (0)
jpayne@69 4683
jpayne@69 4684 #define TclNewIntObj(objPtr, l) \
jpayne@69 4685 TclNewLongObj(objPtr, l)
jpayne@69 4686
jpayne@69 4687 /*
jpayne@69 4688 * NOTE: There is to be no such thing as a "pure" boolean.
jpayne@69 4689 * See comment above TclSetBooleanObj macro above.
jpayne@69 4690 */
jpayne@69 4691 #define TclNewBooleanObj(objPtr, b) \
jpayne@69 4692 TclNewLongObj((objPtr), (b)!=0)
jpayne@69 4693
jpayne@69 4694 #define TclNewDoubleObj(objPtr, d) \
jpayne@69 4695 do { \
jpayne@69 4696 TclIncrObjsAllocated(); \
jpayne@69 4697 TclAllocObjStorage(objPtr); \
jpayne@69 4698 (objPtr)->refCount = 0; \
jpayne@69 4699 (objPtr)->bytes = NULL; \
jpayne@69 4700 (objPtr)->internalRep.doubleValue = (double)(d); \
jpayne@69 4701 (objPtr)->typePtr = &tclDoubleType; \
jpayne@69 4702 TCL_DTRACE_OBJ_CREATE(objPtr); \
jpayne@69 4703 } while (0)
jpayne@69 4704
jpayne@69 4705 #define TclNewStringObj(objPtr, s, len) \
jpayne@69 4706 do { \
jpayne@69 4707 TclIncrObjsAllocated(); \
jpayne@69 4708 TclAllocObjStorage(objPtr); \
jpayne@69 4709 (objPtr)->refCount = 0; \
jpayne@69 4710 TclInitStringRep((objPtr), (s), (len)); \
jpayne@69 4711 (objPtr)->typePtr = NULL; \
jpayne@69 4712 TCL_DTRACE_OBJ_CREATE(objPtr); \
jpayne@69 4713 } while (0)
jpayne@69 4714
jpayne@69 4715 #else /* TCL_MEM_DEBUG */
jpayne@69 4716 #define TclNewIntObj(objPtr, i) \
jpayne@69 4717 (objPtr) = Tcl_NewIntObj(i)
jpayne@69 4718
jpayne@69 4719 #define TclNewLongObj(objPtr, l) \
jpayne@69 4720 (objPtr) = Tcl_NewLongObj(l)
jpayne@69 4721
jpayne@69 4722 #define TclNewBooleanObj(objPtr, b) \
jpayne@69 4723 (objPtr) = Tcl_NewBooleanObj(b)
jpayne@69 4724
jpayne@69 4725 #define TclNewDoubleObj(objPtr, d) \
jpayne@69 4726 (objPtr) = Tcl_NewDoubleObj(d)
jpayne@69 4727
jpayne@69 4728 #define TclNewStringObj(objPtr, s, len) \
jpayne@69 4729 (objPtr) = Tcl_NewStringObj((s), (len))
jpayne@69 4730 #endif /* TCL_MEM_DEBUG */
jpayne@69 4731
jpayne@69 4732 /*
jpayne@69 4733 * The sLiteral argument *must* be a string literal; the incantation with
jpayne@69 4734 * sizeof(sLiteral "") will fail to compile otherwise.
jpayne@69 4735 */
jpayne@69 4736 #define TclNewLiteralStringObj(objPtr, sLiteral) \
jpayne@69 4737 TclNewStringObj((objPtr), (sLiteral), (int) (sizeof(sLiteral "") - 1))
jpayne@69 4738
jpayne@69 4739 /*
jpayne@69 4740 *----------------------------------------------------------------
jpayne@69 4741 * Convenience macros for DStrings.
jpayne@69 4742 * The ANSI C "prototypes" for these macros are:
jpayne@69 4743 *
jpayne@69 4744 * MODULE_SCOPE char * TclDStringAppendLiteral(Tcl_DString *dsPtr,
jpayne@69 4745 * const char *sLiteral);
jpayne@69 4746 * MODULE_SCOPE void TclDStringClear(Tcl_DString *dsPtr);
jpayne@69 4747 */
jpayne@69 4748
jpayne@69 4749 #define TclDStringAppendLiteral(dsPtr, sLiteral) \
jpayne@69 4750 Tcl_DStringAppend((dsPtr), (sLiteral), (int) (sizeof(sLiteral "") - 1))
jpayne@69 4751 #define TclDStringClear(dsPtr) \
jpayne@69 4752 Tcl_DStringSetLength((dsPtr), 0)
jpayne@69 4753
jpayne@69 4754 /*
jpayne@69 4755 *----------------------------------------------------------------
jpayne@69 4756 * Macros used by the Tcl core to test for some special double values.
jpayne@69 4757 * The ANSI C "prototypes" for these macros are:
jpayne@69 4758 *
jpayne@69 4759 * MODULE_SCOPE int TclIsInfinite(double d);
jpayne@69 4760 * MODULE_SCOPE int TclIsNaN(double d);
jpayne@69 4761 */
jpayne@69 4762
jpayne@69 4763 #ifdef _MSC_VER
jpayne@69 4764 # define TclIsInfinite(d) (!(_finite((d))))
jpayne@69 4765 # define TclIsNaN(d) (_isnan((d)))
jpayne@69 4766 #else
jpayne@69 4767 # define TclIsInfinite(d) ((d) > DBL_MAX || (d) < -DBL_MAX)
jpayne@69 4768 # ifdef NO_ISNAN
jpayne@69 4769 # define TclIsNaN(d) ((d) != (d))
jpayne@69 4770 # else
jpayne@69 4771 # define TclIsNaN(d) (isnan(d))
jpayne@69 4772 # endif
jpayne@69 4773 #endif
jpayne@69 4774
jpayne@69 4775 /*
jpayne@69 4776 * ----------------------------------------------------------------------
jpayne@69 4777 * Macro to use to find the offset of a field in a structure. Computes number
jpayne@69 4778 * of bytes from beginning of structure to a given field.
jpayne@69 4779 */
jpayne@69 4780
jpayne@69 4781 #ifdef offsetof
jpayne@69 4782 #define TclOffset(type, field) ((int) offsetof(type, field))
jpayne@69 4783 #else
jpayne@69 4784 #define TclOffset(type, field) ((int) ((char *) &((type *) 0)->field))
jpayne@69 4785 #endif
jpayne@69 4786
jpayne@69 4787 /*
jpayne@69 4788 *----------------------------------------------------------------
jpayne@69 4789 * Inline version of Tcl_GetCurrentNamespace and Tcl_GetGlobalNamespace.
jpayne@69 4790 */
jpayne@69 4791
jpayne@69 4792 #define TclGetCurrentNamespace(interp) \
jpayne@69 4793 (Tcl_Namespace *) ((Interp *)(interp))->varFramePtr->nsPtr
jpayne@69 4794
jpayne@69 4795 #define TclGetGlobalNamespace(interp) \
jpayne@69 4796 (Tcl_Namespace *) ((Interp *)(interp))->globalNsPtr
jpayne@69 4797
jpayne@69 4798 /*
jpayne@69 4799 *----------------------------------------------------------------
jpayne@69 4800 * Inline version of TclCleanupCommand; still need the function as it is in
jpayne@69 4801 * the internal stubs, but the core can use the macro instead.
jpayne@69 4802 */
jpayne@69 4803
jpayne@69 4804 #define TclCleanupCommandMacro(cmdPtr) \
jpayne@69 4805 if ((cmdPtr)->refCount-- <= 1) { \
jpayne@69 4806 ckfree((char *) (cmdPtr));\
jpayne@69 4807 }
jpayne@69 4808
jpayne@69 4809 /*
jpayne@69 4810 *----------------------------------------------------------------
jpayne@69 4811 * Inline versions of Tcl_LimitReady() and Tcl_LimitExceeded to limit number
jpayne@69 4812 * of calls out of the critical path. Note that this code isn't particularly
jpayne@69 4813 * readable; the non-inline version (in tclInterp.c) is much easier to
jpayne@69 4814 * understand. Note also that these macros takes different args (iPtr->limit)
jpayne@69 4815 * to the non-inline version.
jpayne@69 4816 */
jpayne@69 4817
jpayne@69 4818 #define TclLimitExceeded(limit) ((limit).exceeded != 0)
jpayne@69 4819
jpayne@69 4820 #define TclLimitReady(limit) \
jpayne@69 4821 (((limit).active == 0) ? 0 : \
jpayne@69 4822 (++(limit).granularityTicker, \
jpayne@69 4823 ((((limit).active & TCL_LIMIT_COMMANDS) && \
jpayne@69 4824 (((limit).cmdGranularity == 1) || \
jpayne@69 4825 ((limit).granularityTicker % (limit).cmdGranularity == 0))) \
jpayne@69 4826 ? 1 : \
jpayne@69 4827 (((limit).active & TCL_LIMIT_TIME) && \
jpayne@69 4828 (((limit).timeGranularity == 1) || \
jpayne@69 4829 ((limit).granularityTicker % (limit).timeGranularity == 0)))\
jpayne@69 4830 ? 1 : 0)))
jpayne@69 4831
jpayne@69 4832 /*
jpayne@69 4833 * Compile-time assertions: these produce a compile time error if the
jpayne@69 4834 * expression is not known to be true at compile time. If the assertion is
jpayne@69 4835 * known to be false, the compiler (or optimizer?) will error out with
jpayne@69 4836 * "division by zero". If the assertion cannot be evaluated at compile time,
jpayne@69 4837 * the compiler will error out with "non-static initializer".
jpayne@69 4838 *
jpayne@69 4839 * Adapted with permission from
jpayne@69 4840 * http://www.pixelbeat.org/programming/gcc/static_assert.html
jpayne@69 4841 */
jpayne@69 4842
jpayne@69 4843 #define TCL_CT_ASSERT(e) \
jpayne@69 4844 {enum { ct_assert_value = 1/(!!(e)) };}
jpayne@69 4845
jpayne@69 4846 /*
jpayne@69 4847 *----------------------------------------------------------------
jpayne@69 4848 * Allocator for small structs (<=sizeof(Tcl_Obj)) using the Tcl_Obj pool.
jpayne@69 4849 * Only checked at compile time.
jpayne@69 4850 *
jpayne@69 4851 * ONLY USE FOR CONSTANT nBytes.
jpayne@69 4852 *
jpayne@69 4853 * DO NOT LET THEM CROSS THREAD BOUNDARIES
jpayne@69 4854 *----------------------------------------------------------------
jpayne@69 4855 */
jpayne@69 4856
jpayne@69 4857 #define TclSmallAlloc(nbytes, memPtr) \
jpayne@69 4858 TclSmallAllocEx(NULL, (nbytes), (memPtr))
jpayne@69 4859
jpayne@69 4860 #define TclSmallFree(memPtr) \
jpayne@69 4861 TclSmallFreeEx(NULL, (memPtr))
jpayne@69 4862
jpayne@69 4863 #ifndef TCL_MEM_DEBUG
jpayne@69 4864 #define TclSmallAllocEx(interp, nbytes, memPtr) \
jpayne@69 4865 do { \
jpayne@69 4866 Tcl_Obj *_objPtr; \
jpayne@69 4867 TCL_CT_ASSERT((nbytes)<=sizeof(Tcl_Obj)); \
jpayne@69 4868 TclIncrObjsAllocated(); \
jpayne@69 4869 TclAllocObjStorageEx((interp), (_objPtr)); \
jpayne@69 4870 memPtr = (ClientData) (_objPtr); \
jpayne@69 4871 } while (0)
jpayne@69 4872
jpayne@69 4873 #define TclSmallFreeEx(interp, memPtr) \
jpayne@69 4874 do { \
jpayne@69 4875 TclFreeObjStorageEx((interp), (Tcl_Obj *) (memPtr)); \
jpayne@69 4876 TclIncrObjsFreed(); \
jpayne@69 4877 } while (0)
jpayne@69 4878
jpayne@69 4879 #else /* TCL_MEM_DEBUG */
jpayne@69 4880 #define TclSmallAllocEx(interp, nbytes, memPtr) \
jpayne@69 4881 do { \
jpayne@69 4882 Tcl_Obj *_objPtr; \
jpayne@69 4883 TCL_CT_ASSERT((nbytes)<=sizeof(Tcl_Obj)); \
jpayne@69 4884 TclNewObj(_objPtr); \
jpayne@69 4885 memPtr = (ClientData) _objPtr; \
jpayne@69 4886 } while (0)
jpayne@69 4887
jpayne@69 4888 #define TclSmallFreeEx(interp, memPtr) \
jpayne@69 4889 do { \
jpayne@69 4890 Tcl_Obj *_objPtr = (Tcl_Obj *) memPtr; \
jpayne@69 4891 _objPtr->bytes = NULL; \
jpayne@69 4892 _objPtr->typePtr = NULL; \
jpayne@69 4893 _objPtr->refCount = 1; \
jpayne@69 4894 TclDecrRefCount(_objPtr); \
jpayne@69 4895 } while (0)
jpayne@69 4896 #endif /* TCL_MEM_DEBUG */
jpayne@69 4897
jpayne@69 4898 /*
jpayne@69 4899 * Support for Clang Static Analyzer <http://clang-analyzer.llvm.org>
jpayne@69 4900 */
jpayne@69 4901
jpayne@69 4902 #if defined(PURIFY) && defined(__clang__)
jpayne@69 4903 #if __has_feature(attribute_analyzer_noreturn) && \
jpayne@69 4904 !defined(Tcl_Panic) && defined(Tcl_Panic_TCL_DECLARED)
jpayne@69 4905 void Tcl_Panic(const char *, ...) __attribute__((analyzer_noreturn));
jpayne@69 4906 #endif
jpayne@69 4907 #if !defined(CLANG_ASSERT)
jpayne@69 4908 #include <assert.h>
jpayne@69 4909 #define CLANG_ASSERT(x) assert(x)
jpayne@69 4910 #endif
jpayne@69 4911 #elif !defined(CLANG_ASSERT)
jpayne@69 4912 #define CLANG_ASSERT(x)
jpayne@69 4913 #endif /* PURIFY && __clang__ */
jpayne@69 4914
jpayne@69 4915 /*
jpayne@69 4916 *----------------------------------------------------------------
jpayne@69 4917 * Parameters, structs and macros for the non-recursive engine (NRE)
jpayne@69 4918 *----------------------------------------------------------------
jpayne@69 4919 */
jpayne@69 4920
jpayne@69 4921 #define NRE_USE_SMALL_ALLOC 1 /* Only turn off for debugging purposes. */
jpayne@69 4922 #ifndef NRE_ENABLE_ASSERTS
jpayne@69 4923 #define NRE_ENABLE_ASSERTS 0
jpayne@69 4924 #endif
jpayne@69 4925
jpayne@69 4926 /*
jpayne@69 4927 * This is the main data struct for representing NR commands. It is designed
jpayne@69 4928 * to fit in sizeof(Tcl_Obj) in order to exploit the fastest memory allocator
jpayne@69 4929 * available.
jpayne@69 4930 */
jpayne@69 4931
jpayne@69 4932 typedef struct NRE_callback {
jpayne@69 4933 Tcl_NRPostProc *procPtr;
jpayne@69 4934 ClientData data[4];
jpayne@69 4935 struct NRE_callback *nextPtr;
jpayne@69 4936 } NRE_callback;
jpayne@69 4937
jpayne@69 4938 #define TOP_CB(iPtr) (((Interp *)(iPtr))->execEnvPtr->callbackPtr)
jpayne@69 4939
jpayne@69 4940 /*
jpayne@69 4941 * Inline version of Tcl_NRAddCallback.
jpayne@69 4942 */
jpayne@69 4943
jpayne@69 4944 #define TclNRAddCallback(interp,postProcPtr,data0,data1,data2,data3) \
jpayne@69 4945 do { \
jpayne@69 4946 NRE_callback *_callbackPtr; \
jpayne@69 4947 TCLNR_ALLOC((interp), (_callbackPtr)); \
jpayne@69 4948 _callbackPtr->procPtr = (postProcPtr); \
jpayne@69 4949 _callbackPtr->data[0] = (ClientData)(data0); \
jpayne@69 4950 _callbackPtr->data[1] = (ClientData)(data1); \
jpayne@69 4951 _callbackPtr->data[2] = (ClientData)(data2); \
jpayne@69 4952 _callbackPtr->data[3] = (ClientData)(data3); \
jpayne@69 4953 _callbackPtr->nextPtr = TOP_CB(interp); \
jpayne@69 4954 TOP_CB(interp) = _callbackPtr; \
jpayne@69 4955 } while (0)
jpayne@69 4956
jpayne@69 4957 #if NRE_USE_SMALL_ALLOC
jpayne@69 4958 #define TCLNR_ALLOC(interp, ptr) \
jpayne@69 4959 TclSmallAllocEx(interp, sizeof(NRE_callback), (ptr))
jpayne@69 4960 #define TCLNR_FREE(interp, ptr) TclSmallFreeEx((interp), (ptr))
jpayne@69 4961 #else
jpayne@69 4962 #define TCLNR_ALLOC(interp, ptr) \
jpayne@69 4963 ((ptr) = ((void *)ckalloc(sizeof(NRE_callback))))
jpayne@69 4964 #define TCLNR_FREE(interp, ptr) ckfree((char *) (ptr))
jpayne@69 4965 #endif
jpayne@69 4966
jpayne@69 4967 #if NRE_ENABLE_ASSERTS
jpayne@69 4968 #define NRE_ASSERT(expr) assert((expr))
jpayne@69 4969 #else
jpayne@69 4970 #define NRE_ASSERT(expr)
jpayne@69 4971 #endif
jpayne@69 4972
jpayne@69 4973 #include "tclIntDecls.h"
jpayne@69 4974 #include "tclIntPlatDecls.h"
jpayne@69 4975 #include "tclTomMathDecls.h"
jpayne@69 4976
jpayne@69 4977 #if !defined(USE_TCL_STUBS) && !defined(TCL_MEM_DEBUG)
jpayne@69 4978 #define Tcl_AttemptAlloc(size) TclpAlloc(size)
jpayne@69 4979 #define Tcl_AttemptRealloc(ptr, size) TclpRealloc((ptr), (size))
jpayne@69 4980 #define Tcl_Free(ptr) TclpFree(ptr)
jpayne@69 4981 #endif
jpayne@69 4982
jpayne@69 4983 /*
jpayne@69 4984 * Other externals.
jpayne@69 4985 */
jpayne@69 4986
jpayne@69 4987 MODULE_SCOPE size_t TclEnvEpoch; /* Epoch of the tcl environment
jpayne@69 4988 * (if changed with tcl-env). */
jpayne@69 4989
jpayne@69 4990 #endif /* _TCLINT */
jpayne@69 4991
jpayne@69 4992 /*
jpayne@69 4993 * Local Variables:
jpayne@69 4994 * mode: c
jpayne@69 4995 * c-basic-offset: 4
jpayne@69 4996 * fill-column: 78
jpayne@69 4997 * End:
jpayne@69 4998 */