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