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