OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [generic/] [tclInt.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
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) 1994-1997 Sun Microsystems, Inc.
8
 * Copyright (c) 1993-1997 Lucent Technologies.
9
 * Copyright (c) 1998 by Scriptics Corporation.
10
 *
11
 * See the file "license.terms" for information on usage and redistribution
12
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
 *
14
 * RCS: @(#) $Id: tclInt.h,v 1.1.1.1 2002-01-16 10:25:28 markom Exp $
15
 */
16
 
17
#ifndef _TCLINT
18
#define _TCLINT
19
 
20
/*
21
 * Common include files needed by most of the Tcl source files are
22
 * included here, so that system-dependent personalizations for the
23
 * include files only have to be made in once place.  This results
24
 * in a few extra includes, but greater modularity.  The order of
25
 * the three groups of #includes is important.  For example, stdio.h
26
 * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
27
 * needed by stdlib.h in some configurations.
28
 */
29
 
30
#include <stdio.h>
31
 
32
#ifndef _TCL
33
#include "tcl.h"
34
#endif
35
#ifndef _REGEXP
36
#include "tclRegexp.h"
37
#endif
38
 
39
#include <ctype.h>
40
#ifdef NO_LIMITS_H
41
#   include "../compat/limits.h"
42
#else
43
#   include <limits.h>
44
#endif
45
#ifdef NO_STDLIB_H
46
#   include "../compat/stdlib.h"
47
#else
48
#   include <stdlib.h>
49
#endif
50
#ifdef NO_STRING_H
51
#include "../compat/string.h"
52
#else
53
#include <string.h>
54
#endif
55
#if defined(__STDC__) || defined(HAS_STDARG)
56
#   include <stdarg.h>
57
#else
58
#   include <varargs.h>
59
#endif
60
 
61
#ifdef BUILD_tcl
62
# undef TCL_STORAGE_CLASS
63
# define TCL_STORAGE_CLASS DLLEXPORT
64
#endif
65
 
66
/*
67
 * The following procedures allow namespaces to be customized to
68
 * support special name resolution rules for commands/variables.
69
 *
70
 */
71
 
72
struct Tcl_ResolvedVarInfo;
73
 
74
typedef Tcl_Var (Tcl_ResolveRuntimeVarProc) _ANSI_ARGS_((
75
    Tcl_Interp* interp, struct Tcl_ResolvedVarInfo *vinfoPtr));
76
 
77
typedef void (Tcl_ResolveVarDeleteProc) _ANSI_ARGS_((
78
    struct Tcl_ResolvedVarInfo *vinfoPtr));
79
 
80
/*
81
 * The following structure encapsulates the routines needed to resolve a
82
 * variable reference at runtime.  Any variable specific state will typically
83
 * be appended to this structure.
84
 */
85
 
86
 
87
typedef struct Tcl_ResolvedVarInfo {
88
    Tcl_ResolveRuntimeVarProc *fetchProc;
89
    Tcl_ResolveVarDeleteProc *deleteProc;
90
} Tcl_ResolvedVarInfo;
91
 
92
 
93
 
94
typedef int (Tcl_ResolveCompiledVarProc) _ANSI_ARGS_((
95
    Tcl_Interp* interp, char* name, int length,
96
    Tcl_Namespace *context, Tcl_ResolvedVarInfo **rPtr));
97
 
98
typedef int (Tcl_ResolveVarProc) _ANSI_ARGS_((
99
    Tcl_Interp* interp, char* name, Tcl_Namespace *context,
100
    int flags, Tcl_Var *rPtr));
101
 
102
typedef int (Tcl_ResolveCmdProc) _ANSI_ARGS_((Tcl_Interp* interp,
103
        char* name, Tcl_Namespace *context, int flags,
104
        Tcl_Command *rPtr));
105
 
106
typedef struct Tcl_ResolverInfo {
107
    Tcl_ResolveCmdProc *cmdResProc;     /* Procedure handling command name
108
                                         * resolution. */
109
    Tcl_ResolveVarProc *varResProc;     /* Procedure handling variable name
110
                                         * resolution for variables that
111
                                         * can only be handled at runtime. */
112
    Tcl_ResolveCompiledVarProc *compiledVarResProc;
113
                                        /* Procedure handling variable name
114
                                         * resolution at compile time. */
115
} Tcl_ResolverInfo;
116
 
117
/*
118
 *----------------------------------------------------------------
119
 * Data structures related to namespaces.
120
 *----------------------------------------------------------------
121
 */
122
 
123
/*
124
 * The structure below defines a namespace.
125
 * Note: the first five fields must match exactly the fields in a
126
 * Tcl_Namespace structure (see tcl.h). If you change one, be sure to
127
 * change the other.
128
 */
129
 
130
typedef struct Namespace {
131
    char *name;                  /* The namespace's simple (unqualified)
132
                                  * name. This contains no ::'s. The name of
133
                                  * the global namespace is "" although "::"
134
                                  * is an synonym. */
135
    char *fullName;              /* The namespace's fully qualified name.
136
                                  * This starts with ::. */
137
    ClientData clientData;       /* An arbitrary value associated with this
138
                                  * namespace. */
139
    Tcl_NamespaceDeleteProc *deleteProc;
140
                                 /* Procedure invoked when deleting the
141
                                  * namespace to, e.g., free clientData. */
142
    struct Namespace *parentPtr; /* Points to the namespace that contains
143
                                  * this one. NULL if this is the global
144
                                  * namespace. */
145
    Tcl_HashTable childTable;    /* Contains any child namespaces. Indexed
146
                                  * by strings; values have type
147
                                  * (Namespace *). */
148
    long nsId;                   /* Unique id for the namespace. */
149
    Tcl_Interp *interp;          /* The interpreter containing this
150
                                  * namespace. */
151
    int flags;                   /* OR-ed combination of the namespace
152
                                  * status flags NS_DYING and NS_DEAD
153
                                  * listed below. */
154
    int activationCount;         /* Number of "activations" or active call
155
                                  * frames for this namespace that are on
156
                                  * the Tcl call stack. The namespace won't
157
                                  * be freed until activationCount becomes
158
                                  * zero. */
159
    int refCount;                /* Count of references by namespaceName *
160
                                  * objects. The namespace can't be freed
161
                                  * until refCount becomes zero. */
162
    Tcl_HashTable cmdTable;      /* Contains all the commands currently
163
                                  * registered in the namespace. Indexed by
164
                                  * strings; values have type (Command *).
165
                                  * Commands imported by Tcl_Import have
166
                                  * Command structures that point (via an
167
                                  * ImportedCmdRef structure) to the
168
                                  * Command structure in the source
169
                                  * namespace's command table. */
170
    Tcl_HashTable varTable;      /* Contains all the (global) variables
171
                                  * currently in this namespace. Indexed
172
                                  * by strings; values have type (Var *). */
173
    char **exportArrayPtr;       /* Points to an array of string patterns
174
                                  * specifying which commands are exported.
175
                                  * A pattern may include "string match"
176
                                  * style wildcard characters to specify
177
                                  * multiple commands; however, no namespace
178
                                  * qualifiers are allowed. NULL if no
179
                                  * export patterns are registered. */
180
    int numExportPatterns;       /* Number of export patterns currently
181
                                  * registered using "namespace export". */
182
    int maxExportPatterns;       /* Mumber of export patterns for which
183
                                  * space is currently allocated. */
184
    int cmdRefEpoch;             /* Incremented if a newly added command
185
                                  * shadows a command for which this
186
                                  * namespace has already cached a Command *
187
                                  * pointer; this causes all its cached
188
                                  * Command* pointers to be invalidated. */
189
    int resolverEpoch;           /* Incremented whenever the name resolution
190
                                  * rules change for this namespace; this
191
                                  * invalidates all byte codes compiled in
192
                                  * the namespace, causing the code to be
193
                                  * recompiled under the new rules. */
194
    Tcl_ResolveCmdProc *cmdResProc;
195
                                 /* If non-null, this procedure overrides
196
                                  * the usual command resolution mechanism
197
                                  * in Tcl.  This procedure is invoked
198
                                  * within Tcl_FindCommand to resolve all
199
                                  * command references within the namespace. */
200
    Tcl_ResolveVarProc *varResProc;
201
                                 /* If non-null, this procedure overrides
202
                                  * the usual variable resolution mechanism
203
                                  * in Tcl.  This procedure is invoked
204
                                  * within Tcl_FindNamespaceVar to resolve all
205
                                  * variable references within the namespace
206
                                  * at runtime. */
207
    Tcl_ResolveCompiledVarProc *compiledVarResProc;
208
                                 /* If non-null, this procedure overrides
209
                                  * the usual variable resolution mechanism
210
                                  * in Tcl.  This procedure is invoked
211
                                  * within LookupCompiledLocal to resolve
212
                                  * variable references within the namespace
213
                                  * at compile time. */
214
} Namespace;
215
 
216
/*
217
 * Flags used to represent the status of a namespace:
218
 *
219
 * NS_DYING -   1 means Tcl_DeleteNamespace has been called to delete the
220
 *              namespace but there are still active call frames on the Tcl
221
 *              stack that refer to the namespace. When the last call frame
222
 *              referring to it has been popped, it's variables and command
223
 *              will be destroyed and it will be marked "dead" (NS_DEAD).
224
 *              The namespace can no longer be looked up by name.
225
 * NS_DEAD -    1 means Tcl_DeleteNamespace has been called to delete the
226
 *              namespace and no call frames still refer to it. Its
227
 *              variables and command have already been destroyed. This bit
228
 *              allows the namespace resolution code to recognize that the
229
 *              namespace is "deleted". When the last namespaceName object
230
 *              in any byte code code unit that refers to the namespace has
231
 *              been freed (i.e., when the namespace's refCount is 0), the
232
 *              namespace's storage will be freed.
233
 */
234
 
235
#define NS_DYING        0x01
236
#define NS_DEAD         0x02
237
 
238
/*
239
 * Flag passed to TclGetNamespaceForQualName to have it create all namespace
240
 * components of a namespace-qualified name that cannot be found. The new
241
 * namespaces are created within their specified parent. Note that this
242
 * flag's value must not conflict with the values of the flags
243
 * TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, and FIND_ONLY_NS (defined in
244
 * tclNamesp.c).
245
 */
246
 
247
#define CREATE_NS_IF_UNKNOWN 0x800
248
 
249
/*
250
 *----------------------------------------------------------------
251
 * Data structures related to variables.   These are used primarily
252
 * in tclVar.c
253
 *----------------------------------------------------------------
254
 */
255
 
256
/*
257
 * The following structure defines a variable trace, which is used to
258
 * invoke a specific C procedure whenever certain operations are performed
259
 * on a variable.
260
 */
261
 
262
typedef struct VarTrace {
263
    Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
264
                                 * by flags are performed on variable. */
265
    ClientData clientData;      /* Argument to pass to proc. */
266
    int flags;                  /* What events the trace procedure is
267
                                 * interested in:  OR-ed combination of
268
                                 * TCL_TRACE_READS, TCL_TRACE_WRITES, and
269
                                 * TCL_TRACE_UNSETS. */
270
    struct VarTrace *nextPtr;   /* Next in list of traces associated with
271
                                 * a particular variable. */
272
} VarTrace;
273
 
274
/*
275
 * When a variable trace is active (i.e. its associated procedure is
276
 * executing), one of the following structures is linked into a list
277
 * associated with the variable's interpreter.  The information in
278
 * the structure is needed in order for Tcl to behave reasonably
279
 * if traces are deleted while traces are active.
280
 */
281
 
282
typedef struct ActiveVarTrace {
283
    struct Var *varPtr;         /* Variable that's being traced. */
284
    struct ActiveVarTrace *nextPtr;
285
                                /* Next in list of all active variable
286
                                 * traces for the interpreter, or NULL
287
                                 * if no more. */
288
    VarTrace *nextTracePtr;     /* Next trace to check after current
289
                                 * trace procedure returns;  if this
290
                                 * trace gets deleted, must update pointer
291
                                 * to avoid using free'd memory. */
292
} ActiveVarTrace;
293
 
294
/*
295
 * The following structure describes an enumerative search in progress on
296
 * an array variable;  this are invoked with options to the "array"
297
 * command.
298
 */
299
 
300
typedef struct ArraySearch {
301
    int id;                     /* Integer id used to distinguish among
302
                                 * multiple concurrent searches for the
303
                                 * same array. */
304
    struct Var *varPtr;         /* Pointer to array variable that's being
305
                                 * searched. */
306
    Tcl_HashSearch search;      /* Info kept by the hash module about
307
                                 * progress through the array. */
308
    Tcl_HashEntry *nextEntry;   /* Non-null means this is the next element
309
                                 * to be enumerated (it's leftover from
310
                                 * the Tcl_FirstHashEntry call or from
311
                                 * an "array anymore" command).  NULL
312
                                 * means must call Tcl_NextHashEntry
313
                                 * to get value to return. */
314
    struct ArraySearch *nextPtr;/* Next in list of all active searches
315
                                 * for this variable, or NULL if this is
316
                                 * the last one. */
317
} ArraySearch;
318
 
319
/*
320
 * The structure below defines a variable, which associates a string name
321
 * with a Tcl_Obj value. These structures are kept in procedure call frames
322
 * (for local variables recognized by the compiler) or in the heap (for
323
 * global variables and any variable not known to the compiler). For each
324
 * Var structure in the heap, a hash table entry holds the variable name and
325
 * a pointer to the Var structure.
326
 */
327
 
328
typedef struct Var {
329
    union {
330
        Tcl_Obj *objPtr;        /* The variable's object value. Used for
331
                                 * scalar variables and array elements. */
332
        Tcl_HashTable *tablePtr;/* For array variables, this points to
333
                                 * information about the hash table used
334
                                 * to implement the associative array.
335
                                 * Points to malloc-ed data. */
336
        struct Var *linkPtr;    /* If this is a global variable being
337
                                 * referred to in a procedure, or a variable
338
                                 * created by "upvar", this field points to
339
                                 * the referenced variable's Var struct. */
340
    } value;
341
    char *name;                 /* NULL if the variable is in a hashtable,
342
                                 * otherwise points to the variable's
343
                                 * name. It is used, e.g., by TclLookupVar
344
                                 * and "info locals". The storage for the
345
                                 * characters of the name is not owned by
346
                                 * the Var and must not be freed when
347
                                 * freeing the Var. */
348
    Namespace *nsPtr;           /* Points to the namespace that contains
349
                                 * this variable or NULL if the variable is
350
                                 * a local variable in a Tcl procedure. */
351
    Tcl_HashEntry *hPtr;        /* If variable is in a hashtable, either the
352
                                 * hash table entry that refers to this
353
                                 * variable or NULL if the variable has been
354
                                 * detached from its hash table (e.g. an
355
                                 * array is deleted, but some of its
356
                                 * elements are still referred to in
357
                                 * upvars). NULL if the variable is not in a
358
                                 * hashtable. This is used to delete an
359
                                 * variable from its hashtable if it is no
360
                                 * longer needed. */
361
    int refCount;               /* Counts number of active uses of this
362
                                 * variable, not including its entry in the
363
                                 * call frame or the hash table: 1 for each
364
                                 * additional variable whose linkPtr points
365
                                 * here, 1 for each nested trace active on
366
                                 * variable, and 1 if the variable is a
367
                                 * namespace variable. This record can't be
368
                                 * deleted until refCount becomes 0. */
369
    VarTrace *tracePtr;         /* First in list of all traces set for this
370
                                 * variable. */
371
    ArraySearch *searchPtr;     /* First in list of all searches active
372
                                 * for this variable, or NULL if none. */
373
    int flags;                  /* Miscellaneous bits of information about
374
                                 * variable. See below for definitions. */
375
} Var;
376
 
377
/*
378
 * Flag bits for variables. The first three (VAR_SCALAR, VAR_ARRAY, and
379
 * VAR_LINK) are mutually exclusive and give the "type" of the variable.
380
 * VAR_UNDEFINED is independent of the variable's type.
381
 *
382
 * VAR_SCALAR -                 1 means this is a scalar variable and not
383
 *                              an array or link. The "objPtr" field points
384
 *                              to the variable's value, a Tcl object.
385
 * VAR_ARRAY -                  1 means this is an array variable rather
386
 *                              than a scalar variable or link. The
387
 *                              "tablePtr" field points to the array's
388
 *                              hashtable for its elements.
389
 * VAR_LINK -                   1 means this Var structure contains a
390
 *                              pointer to another Var structure that
391
 *                              either has the real value or is itself
392
 *                              another VAR_LINK pointer. Variables like
393
 *                              this come about through "upvar" and "global"
394
 *                              commands, or through references to variables
395
 *                              in enclosing namespaces.
396
 * VAR_UNDEFINED -              1 means that the variable is in the process
397
 *                              of being deleted. An undefined variable
398
 *                              logically does not exist and survives only
399
 *                              while it has a trace, or if it is a global
400
 *                              variable currently being used by some
401
 *                              procedure.
402
 * VAR_IN_HASHTABLE -           1 means this variable is in a hashtable and
403
 *                              the Var structure is malloced. 0 if it is
404
 *                              a local variable that was assigned a slot
405
 *                              in a procedure frame by the compiler so the
406
 *                              Var storage is part of the call frame.
407
 * VAR_TRACE_ACTIVE -           1 means that trace processing is currently
408
 *                              underway for a read or write access, so
409
 *                              new read or write accesses should not cause
410
 *                              trace procedures to be called and the
411
 *                              variable can't be deleted.
412
 * VAR_ARRAY_ELEMENT -          1 means that this variable is an array
413
 *                              element, so it is not legal for it to be
414
 *                              an array itself (the VAR_ARRAY flag had
415
 *                              better not be set).
416
 * VAR_NAMESPACE_VAR -          1 means that this variable was declared
417
 *                              as a namespace variable. This flag ensures
418
 *                              it persists until its namespace is
419
 *                              destroyed or until the variable is unset;
420
 *                              it will persist even if it has not been
421
 *                              initialized and is marked undefined.
422
 *                              The variable's refCount is incremented to
423
 *                              reflect the "reference" from its namespace.
424
 *
425
 * The following additional flags are used with the CompiledLocal type
426
 * defined below:
427
 *
428
 * VAR_ARGUMENT -               1 means that this variable holds a procedure
429
 *                              argument.
430
 * VAR_TEMPORARY -              1 if the local variable is an anonymous
431
 *                              temporary variable. Temporaries have a NULL
432
 *                              name.
433
 * VAR_RESOLVED -               1 if name resolution has been done for this
434
 *                              variable.
435
 */
436
 
437
#define VAR_SCALAR              0x1
438
#define VAR_ARRAY               0x2
439
#define VAR_LINK                0x4
440
#define VAR_UNDEFINED           0x8
441
#define VAR_IN_HASHTABLE        0x10
442
#define VAR_TRACE_ACTIVE        0x20
443
#define VAR_ARRAY_ELEMENT       0x40
444
#define VAR_NAMESPACE_VAR       0x80
445
 
446
#define VAR_ARGUMENT            0x100
447
#define VAR_TEMPORARY           0x200
448
#define VAR_RESOLVED            0x400   
449
 
450
/*
451
 * Macros to ensure that various flag bits are set properly for variables.
452
 * The ANSI C "prototypes" for these macros are:
453
 *
454
 * EXTERN void  TclSetVarScalar _ANSI_ARGS_((Var *varPtr));
455
 * EXTERN void  TclSetVarArray _ANSI_ARGS_((Var *varPtr));
456
 * EXTERN void  TclSetVarLink _ANSI_ARGS_((Var *varPtr));
457
 * EXTERN void  TclSetVarArrayElement _ANSI_ARGS_((Var *varPtr));
458
 * EXTERN void  TclSetVarUndefined _ANSI_ARGS_((Var *varPtr));
459
 * EXTERN void  TclClearVarUndefined _ANSI_ARGS_((Var *varPtr));
460
 */
461
 
462
#define TclSetVarScalar(varPtr) \
463
    (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK)) | VAR_SCALAR
464
 
465
#define TclSetVarArray(varPtr) \
466
    (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_LINK)) | VAR_ARRAY
467
 
468
#define TclSetVarLink(varPtr) \
469
    (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_ARRAY)) | VAR_LINK
470
 
471
#define TclSetVarArrayElement(varPtr) \
472
    (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
473
 
474
#define TclSetVarUndefined(varPtr) \
475
    (varPtr)->flags |= VAR_UNDEFINED
476
 
477
#define TclClearVarUndefined(varPtr) \
478
    (varPtr)->flags &= ~VAR_UNDEFINED
479
 
480
/*
481
 * Macros to read various flag bits of variables.
482
 * The ANSI C "prototypes" for these macros are:
483
 *
484
 * EXTERN int   TclIsVarScalar _ANSI_ARGS_((Var *varPtr));
485
 * EXTERN int   TclIsVarLink _ANSI_ARGS_((Var *varPtr));
486
 * EXTERN int   TclIsVarArray _ANSI_ARGS_((Var *varPtr));
487
 * EXTERN int   TclIsVarUndefined _ANSI_ARGS_((Var *varPtr));
488
 * EXTERN int   TclIsVarArrayElement _ANSI_ARGS_((Var *varPtr));
489
 * EXTERN int   TclIsVarTemporary _ANSI_ARGS_((Var *varPtr));
490
 * EXTERN int   TclIsVarArgument _ANSI_ARGS_((Var *varPtr));
491
 * EXTERN int   TclIsVarResolved _ANSI_ARGS_((Var *varPtr));
492
 */
493
 
494
#define TclIsVarScalar(varPtr) \
495
    ((varPtr)->flags & VAR_SCALAR)
496
 
497
#define TclIsVarLink(varPtr) \
498
    ((varPtr)->flags & VAR_LINK)
499
 
500
#define TclIsVarArray(varPtr) \
501
    ((varPtr)->flags & VAR_ARRAY)
502
 
503
#define TclIsVarUndefined(varPtr) \
504
    ((varPtr)->flags & VAR_UNDEFINED)
505
 
506
#define TclIsVarArrayElement(varPtr) \
507
    ((varPtr)->flags & VAR_ARRAY_ELEMENT)
508
 
509
#define TclIsVarTemporary(varPtr) \
510
    ((varPtr)->flags & VAR_TEMPORARY)
511
 
512
#define TclIsVarArgument(varPtr) \
513
    ((varPtr)->flags & VAR_ARGUMENT)
514
 
515
#define TclIsVarResolved(varPtr) \
516
    ((varPtr)->flags & VAR_RESOLVED)
517
 
518
/*
519
 *----------------------------------------------------------------
520
 * Data structures related to procedures.  These are used primarily
521
 * in tclProc.c, tclCompile.c, and tclExecute.c.
522
 *----------------------------------------------------------------
523
 */
524
 
525
/*
526
 * Forward declaration to prevent an error when the forward reference to
527
 * Command is encountered in the Proc and ImportRef types declared below.
528
 */
529
 
530
struct Command;
531
 
532
/*
533
 * The variable-length structure below describes a local variable of a
534
 * procedure that was recognized by the compiler. These variables have a
535
 * name, an element in the array of compiler-assigned local variables in the
536
 * procedure's call frame, and various other items of information. If the
537
 * local variable is a formal argument, it may also have a default value.
538
 * The compiler can't recognize local variables whose names are
539
 * expressions (these names are only known at runtime when the expressions
540
 * are evaluated) or local variables that are created as a result of an
541
 * "upvar" or "uplevel" command. These other local variables are kept
542
 * separately in a hash table in the call frame.
543
 */
544
 
545
typedef struct CompiledLocal {
546
    struct CompiledLocal *nextPtr;
547
                                /* Next compiler-recognized local variable
548
                                 * for this procedure, or NULL if this is
549
                                 * the last local. */
550
    int nameLength;             /* The number of characters in local
551
                                 * variable's name. Used to speed up
552
                                 * variable lookups. */
553
    int frameIndex;             /* Index in the array of compiler-assigned
554
                                 * variables in the procedure call frame. */
555
    int flags;                  /* Flag bits for the local variable. Same as
556
                                 * the flags for the Var structure above,
557
                                 * although only VAR_SCALAR, VAR_ARRAY,
558
                                 * VAR_LINK, VAR_ARGUMENT, VAR_TEMPORARY, and
559
                                 * VAR_RESOLVED make sense. */
560
    Tcl_Obj *defValuePtr;       /* Pointer to the default value of an
561
                                 * argument, if any. NULL if not an argument
562
                                 * or, if an argument, no default value. */
563
    Tcl_ResolvedVarInfo *resolveInfo;
564
                                /* Customized variable resolution info
565
                                 * supplied by the Tcl_ResolveCompiledVarProc
566
                                 * associated with a namespace. Each variable
567
                                 * is marked by a unique ClientData tag
568
                                 * during compilation, and that same tag
569
                                 * is used to find the variable at runtime. */
570
    char name[4];               /* Name of the local variable starts here.
571
                                 * If the name is NULL, this will just be
572
                                 * '\0'. The actual size of this field will
573
                                 * be large enough to hold the name. MUST
574
                                 * BE THE LAST FIELD IN THE STRUCTURE! */
575
} CompiledLocal;
576
 
577
/*
578
 * The structure below defines a command procedure, which consists of a
579
 * collection of Tcl commands plus information about arguments and other
580
 * local variables recognized at compile time.
581
 */
582
 
583
typedef struct Proc {
584
    struct Interp *iPtr;          /* Interpreter for which this command
585
                                   * is defined. */
586
    int refCount;                 /* Reference count: 1 if still present
587
                                   * in command table plus 1 for each call
588
                                   * to the procedure that is currently
589
                                   * active. This structure can be freed
590
                                   * when refCount becomes zero. */
591
    struct Command *cmdPtr;       /* Points to the Command structure for
592
                                   * this procedure. This is used to get
593
                                   * the namespace in which to execute
594
                                   * the procedure. */
595
    Tcl_Obj *bodyPtr;             /* Points to the ByteCode object for
596
                                   * procedure's body command. */
597
    int numArgs;                  /* Number of formal parameters. */
598
    int numCompiledLocals;        /* Count of local variables recognized by
599
                                   * the compiler including arguments and
600
                                   * temporaries. */
601
    CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's
602
                                   * compiler-allocated local variables, or
603
                                   * NULL if none. The first numArgs entries
604
                                   * in this list describe the procedure's
605
                                   * formal arguments. */
606
    CompiledLocal *lastLocalPtr;  /* Pointer to the last allocated local
607
                                   * variable or NULL if none. This has
608
                                   * frame index (numCompiledLocals-1). */
609
} Proc;
610
 
611
/*
612
 * The structure below defines a command trace.  This is used to allow Tcl
613
 * clients to find out whenever a command is about to be executed.
614
 */
615
 
616
typedef struct Trace {
617
    int level;                  /* Only trace commands at nesting level
618
                                 * less than or equal to this. */
619
    Tcl_CmdTraceProc *proc;     /* Procedure to call to trace command. */
620
    ClientData clientData;      /* Arbitrary value to pass to proc. */
621
    struct Trace *nextPtr;      /* Next in list of traces for this interp. */
622
} Trace;
623
 
624
/*
625
 * The structure below defines an entry in the assocData hash table which
626
 * is associated with an interpreter. The entry contains a pointer to a
627
 * function to call when the interpreter is deleted, and a pointer to
628
 * a user-defined piece of data.
629
 */
630
 
631
typedef struct AssocData {
632
    Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */
633
    ClientData clientData;      /* Value to pass to proc. */
634
} AssocData;
635
 
636
/*
637
 * The structure below defines a call frame. A call frame defines a naming
638
 * context for a procedure call: its local naming scope (for local
639
 * variables) and its global naming scope (a namespace, perhaps the global
640
 * :: namespace). A call frame can also define the naming context for a
641
 * namespace eval or namespace inscope command: the namespace in which the
642
 * command's code should execute. The Tcl_CallFrame structures exist only
643
 * while procedures or namespace eval/inscope's are being executed, and
644
 * provide a kind of Tcl call stack.
645
 *
646
 * WARNING!! The structure definition must be kept consistent with the
647
 * Tcl_CallFrame structure in tcl.h. If you change one, change the other.
648
 */
649
 
650
typedef struct CallFrame {
651
    Namespace *nsPtr;           /* Points to the namespace used to resolve
652
                                 * commands and global variables. */
653
    int isProcCallFrame;        /* If nonzero, the frame was pushed to
654
                                 * execute a Tcl procedure and may have
655
                                 * local vars. If 0, the frame was pushed
656
                                 * to execute a namespace command and var
657
                                 * references are treated as references to
658
                                 * namespace vars; varTablePtr and
659
                                 * compiledLocals are ignored. */
660
    int objc;                   /* This and objv below describe the
661
                                 * arguments for this procedure call. */
662
    Tcl_Obj *CONST *objv;       /* Array of argument objects. */
663
    struct CallFrame *callerPtr;
664
                                /* Value of interp->framePtr when this
665
                                 * procedure was invoked (i.e. next higher
666
                                 * in stack of all active procedures). */
667
    struct CallFrame *callerVarPtr;
668
                                /* Value of interp->varFramePtr when this
669
                                 * procedure was invoked (i.e. determines
670
                                 * variable scoping within caller). Same
671
                                 * as callerPtr unless an "uplevel" command
672
                                 * or something equivalent was active in
673
                                 * the caller). */
674
    int level;                  /* Level of this procedure, for "uplevel"
675
                                 * purposes (i.e. corresponds to nesting of
676
                                 * callerVarPtr's, not callerPtr's). 1 for
677
                                 * outermost procedure, 0 for top-level. */
678
    Proc *procPtr;              /* Points to the structure defining the
679
                                 * called procedure. Used to get information
680
                                 * such as the number of compiled local
681
                                 * variables (local variables assigned
682
                                 * entries ["slots"] in the compiledLocals
683
                                 * array below). */
684
    Tcl_HashTable *varTablePtr; /* Hash table containing local variables not
685
                                 * recognized by the compiler, or created at
686
                                 * execution time through, e.g., upvar.
687
                                 * Initially NULL and created if needed. */
688
    int numCompiledLocals;      /* Count of local variables recognized by
689
                                 * the compiler including arguments. */
690
    Var* compiledLocals;        /* Points to the array of local variables
691
                                 * recognized by the compiler. The compiler
692
                                 * emits code that refers to these variables
693
                                 * using an index into this array. */
694
} CallFrame;
695
 
696
/*
697
 *----------------------------------------------------------------
698
 * Data structures related to history.   These are used primarily
699
 * in tclHistory.c
700
 *----------------------------------------------------------------
701
 */
702
 
703
/*
704
 * The structure below defines one history event (a previously-executed
705
 * command that can be re-executed in whole or in part).
706
 */
707
 
708
typedef struct {
709
    char *command;              /* String containing previously-executed
710
                                 * command. */
711
    int bytesAvl;               /* Total # of bytes available at *event (not
712
                                 * all are necessarily in use now). */
713
} HistoryEvent;
714
 
715
/*
716
 * The structure below defines a pending revision to the most recent
717
 * history event.  Changes are linked together into a list and applied
718
 * during the next call to Tcl_RecordHistory.  See the comments at the
719
 * beginning of tclHistory.c for information on revisions.
720
 */
721
 
722
typedef struct HistoryRev {
723
    int firstIndex;             /* Index of the first byte to replace in
724
                                 * current history event. */
725
    int lastIndex;              /* Index of last byte to replace in
726
                                 * current history event. */
727
    int newSize;                /* Number of bytes in newBytes. */
728
    char *newBytes;             /* Replacement for the range given by
729
                                 * firstIndex and lastIndex (malloced). */
730
    struct HistoryRev *nextPtr; /* Next in chain of revisions to apply, or
731
                                 * NULL for end of list. */
732
} HistoryRev;
733
 
734
/*
735
 *----------------------------------------------------------------
736
 * Data structures related to expressions.  These are used only in
737
 * tclExpr.c.
738
 *----------------------------------------------------------------
739
 */
740
 
741
/*
742
 * The data structure below defines a math function (e.g. sin or hypot)
743
 * for use in Tcl expressions.
744
 */
745
 
746
#define MAX_MATH_ARGS 5
747
typedef struct MathFunc {
748
    int builtinFuncIndex;       /* If this is a builtin math function, its
749
                                 * index in the array of builtin functions.
750
                                 * (tclCompilation.h lists these indices.)
751
                                 * The value is -1 if this is a new function
752
                                 * defined by Tcl_CreateMathFunc. The value
753
                                 * is also -1 if a builtin function is
754
                                 * replaced by a Tcl_CreateMathFunc call. */
755
    int numArgs;                /* Number of arguments for function. */
756
    Tcl_ValueType argTypes[MAX_MATH_ARGS];
757
                                /* Acceptable types for each argument. */
758
    Tcl_MathProc *proc;         /* Procedure that implements this function.
759
                                 * NULL if isBuiltinFunc is 1. */
760
    ClientData clientData;      /* Additional argument to pass to the
761
                                 * function when invoking it. NULL if
762
                                 * isBuiltinFunc is 1. */
763
} MathFunc;
764
 
765
/*
766
 *----------------------------------------------------------------
767
 * Data structures related to bytecode compilation and execution.
768
 * These are used primarily in tclCompile.c, tclExecute.c, and
769
 * tclBasic.c.
770
 *----------------------------------------------------------------
771
 */
772
 
773
/*
774
 * Forward declaration to prevent an error when the forward reference to
775
 * CompileEnv is encountered in the procedure type CompileProc declared
776
 * below.
777
 */
778
 
779
struct CompileEnv;
780
 
781
/*
782
 * The type of procedures called by the Tcl bytecode compiler to compile
783
 * commands. Pointers to these procedures are kept in the Command structure
784
 * describing each command. When a CompileProc returns, the interpreter's
785
 * result is set to error information, if any. In addition, the CompileProc
786
 * returns an integer value, which is one of the following:
787
 *
788
 * TCL_OK               Compilation completed normally.
789
 * TCL_ERROR            Compilation failed because of an error;
790
 *                      the interpreter's result describes what went wrong.
791
 * TCL_OUT_LINE_COMPILE Compilation failed because, e.g., the command is
792
 *                      too complex for effective inline compilation. The
793
 *                      CompileProc believes the command is legal but
794
 *                      should be compiled "out of line" by emitting code
795
 *                      to invoke its command procedure at runtime.
796
 */
797
 
798
#define TCL_OUT_LINE_COMPILE    (TCL_CONTINUE + 1)
799
 
800
typedef int (CompileProc) _ANSI_ARGS_((Tcl_Interp *interp, char *string,
801
        char *lastChar, int compileFlags, struct CompileEnv *compEnvPtr));
802
 
803
/*
804
 * The data structure defining the execution environment for ByteCode's.
805
 * There is one ExecEnv structure per Tcl interpreter. It holds the
806
 * evaluation stack that holds command operands and results. The stack grows
807
 * towards increasing addresses. The "stackTop" member is cached by
808
 * TclExecuteByteCode in a local variable: it must be set before calling
809
 * TclExecuteByteCode and will be restored by TclExecuteByteCode before it
810
 * returns.
811
 */
812
 
813
typedef union StackItem {
814
    Tcl_Obj *o;                 /* Stack item as a pointer to a Tcl_Obj. */
815
    int      i;                 /* Stack item as an integer. */
816
    VOID    *p;                 /* Stack item as an arbitrary pointer. */
817
} StackItem;
818
 
819
typedef struct ExecEnv {
820
    StackItem *stackPtr;        /* Points to the first item in the
821
                                 * evaluation stack on the heap. */
822
    int stackTop;               /* Index of current top of stack; -1 when
823
                                 * the stack is empty. */
824
    int stackEnd;               /* Index of last usable item in stack. */
825
} ExecEnv;
826
 
827
/*
828
 *----------------------------------------------------------------
829
 * Data structures related to commands.
830
 *----------------------------------------------------------------
831
 */
832
 
833
/*
834
 * An imported command is created in an namespace when it imports a "real"
835
 * command from another namespace. An imported command has a Command
836
 * structure that points (via its ClientData value) to the "real" Command
837
 * structure in the source namespace's command table. The real command
838
 * records all the imported commands that refer to it in a list of ImportRef
839
 * structures so that they can be deleted when the real command is deleted.  */
840
 
841
typedef struct ImportRef {
842
    struct Command *importedCmdPtr;
843
                                /* Points to the imported command created in
844
                                 * an importing namespace; this command
845
                                 * redirects its invocations to the "real"
846
                                 * command. */
847
    struct ImportRef *nextPtr;  /* Next element on the linked list of
848
                                 * imported commands that refer to the
849
                                 * "real" command. The real command deletes
850
                                 * these imported commands on this list when
851
                                 * it is deleted. */
852
} ImportRef;
853
 
854
/*
855
 * Data structure used as the ClientData of imported commands: commands
856
 * created in an namespace when it imports a "real" command from another
857
 * namespace.
858
 */
859
 
860
typedef struct ImportedCmdData {
861
    struct Command *realCmdPtr; /* "Real" command that this imported command
862
                                 * refers to. */
863
    struct Command *selfPtr;    /* Pointer to this imported command. Needed
864
                                 * only when deleting it in order to remove
865
                                 * it from the real command's linked list of
866
                                 * imported commands that refer to it. */
867
} ImportedCmdData;
868
 
869
/*
870
 * A Command structure exists for each command in a namespace. The
871
 * Tcl_Command opaque type actually refers to these structures.
872
 */
873
 
874
typedef struct Command {
875
    Tcl_HashEntry *hPtr;        /* Pointer to the hash table entry that
876
                                 * refers to this command. The hash table is
877
                                 * either a namespace's command table or an
878
                                 * interpreter's hidden command table. This
879
                                 * pointer is used to get a command's name
880
                                 * from its Tcl_Command handle. NULL means
881
                                 * that the hash table entry has been
882
                                 * removed already (this can happen if
883
                                 * deleteProc causes the command to be
884
                                 * deleted or recreated). */
885
    Namespace *nsPtr;           /* Points to the namespace containing this
886
                                 * command. */
887
    int refCount;               /* 1 if in command hashtable plus 1 for each
888
                                 * reference from a CmdName Tcl object
889
                                 * representing a command's name in a
890
                                 * ByteCode instruction sequence. This
891
                                 * structure can be freed when refCount
892
                                 * becomes zero. */
893
    int cmdEpoch;               /* Incremented to invalidate any references
894
                                 * that point to this command when it is
895
                                 * renamed, deleted, hidden, or exposed. */
896
    CompileProc *compileProc;   /* Procedure called to compile command. NULL
897
                                 * if no compile proc exists for command. */
898
    Tcl_ObjCmdProc *objProc;    /* Object-based command procedure. */
899
    ClientData objClientData;   /* Arbitrary value passed to object proc. */
900
    Tcl_CmdProc *proc;          /* String-based command procedure. */
901
    ClientData clientData;      /* Arbitrary value passed to string proc. */
902
    Tcl_CmdDeleteProc *deleteProc;
903
                                /* Procedure invoked when deleting command
904
                                 * to, e.g., free all client data. */
905
    ClientData deleteData;      /* Arbitrary value passed to deleteProc. */
906
    int deleted;                /* Means that the command is in the process
907
                                 * of being deleted (its deleteProc is
908
                                 * currently executing). Other attempts to
909
                                 * delete the command should be ignored. */
910
    ImportRef *importRefPtr;    /* List of each imported Command created in
911
                                 * another namespace when this command is
912
                                 * imported. These imported commands
913
                                 * redirect invocations back to this
914
                                 * command. The list is used to remove all
915
                                 * those imported commands when deleting
916
                                 * this "real" command. */
917
} Command;
918
 
919
/*
920
 *----------------------------------------------------------------
921
 * Data structures related to name resolution procedures.
922
 *----------------------------------------------------------------
923
 */
924
 
925
/*
926
 * The interpreter keeps a linked list of name resolution schemes.
927
 * The scheme for a namespace is consulted first, followed by the
928
 * list of schemes in an interpreter, followed by the default
929
 * name resolution in Tcl.  Schemes are added/removed from the
930
 * interpreter's list by calling Tcl_AddInterpResolver and
931
 * Tcl_RemoveInterpResolver.
932
 */
933
 
934
typedef struct ResolverScheme {
935
    char *name;                 /* Name identifying this scheme. */
936
    Tcl_ResolveCmdProc *cmdResProc;
937
                                /* Procedure handling command name
938
                                 * resolution. */
939
    Tcl_ResolveVarProc *varResProc;
940
                                /* Procedure handling variable name
941
                                 * resolution for variables that
942
                                 * can only be handled at runtime. */
943
    Tcl_ResolveCompiledVarProc *compiledVarResProc;
944
                                /* Procedure handling variable name
945
                                 * resolution at compile time. */
946
 
947
    struct ResolverScheme *nextPtr;
948
                                /* Pointer to next record in linked list. */
949
} ResolverScheme;
950
 
951
/*
952
 *----------------------------------------------------------------
953
 * This structure defines an interpreter, which is a collection of
954
 * commands plus other state information related to interpreting
955
 * commands, such as variable storage. Primary responsibility for
956
 * this data structure is in tclBasic.c, but almost every Tcl
957
 * source file uses something in here.
958
 *----------------------------------------------------------------
959
 */
960
 
961
typedef struct Interp {
962
 
963
    /*
964
     * Note:  the first three fields must match exactly the fields in
965
     * a Tcl_Interp struct (see tcl.h).  If you change one, be sure to
966
     * change the other.
967
     *
968
     * The interpreter's result is held in both the string and the
969
     * objResultPtr fields. These fields hold, respectively, the result's
970
     * string or object value. The interpreter's result is always in the
971
     * result field if that is non-empty, otherwise it is in objResultPtr.
972
     * The two fields are kept consistent unless some C code sets
973
     * interp->result directly. Programs should not access result and
974
     * objResultPtr directly; instead, they should always get and set the
975
     * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult,
976
     * and Tcl_GetStringResult. See the SetResult man page for details.
977
     */
978
 
979
    char *result;               /* If the last command returned a string
980
                                 * result, this points to it. Should not be
981
                                 * accessed directly; see comment above. */
982
    Tcl_FreeProc *freeProc;     /* Zero means a string result is statically
983
                                 * allocated. TCL_DYNAMIC means string
984
                                 * result was allocated with ckalloc and
985
                                 * should be freed with ckfree. Other values
986
                                 * give address of procedure to invoke to
987
                                 * free the string result. Tcl_Eval must
988
                                 * free it before executing next command. */
989
    int errorLine;              /* When TCL_ERROR is returned, this gives
990
                                 * the line number in the command where the
991
                                 * error occurred (1 means first line). */
992
    Tcl_Obj *objResultPtr;      /* If the last command returned an object
993
                                 * result, this points to it. Should not be
994
                                 * accessed directly; see comment above. */
995
    Namespace *globalNsPtr;     /* The interpreter's global namespace. */
996
    Tcl_HashTable mathFuncTable;/* Contains all the math functions currently
997
                                 * defined for the interpreter.  Indexed by
998
                                 * strings (function names); values have
999
                                 * type (MathFunc *). */
1000
 
1001
    /*
1002
     * Information related to procedures and variables. See tclProc.c
1003
     * and tclvar.c for usage.
1004
     */
1005
 
1006
    int numLevels;              /* Keeps track of how many nested calls to
1007
                                 * Tcl_Eval are in progress for this
1008
                                 * interpreter.  It's used to delay deletion
1009
                                 * of the table until all Tcl_Eval
1010
                                 * invocations are completed. */
1011
    int maxNestingDepth;        /* If numLevels exceeds this value then Tcl
1012
                                 * assumes that infinite recursion has
1013
                                 * occurred and it generates an error. */
1014
    CallFrame *framePtr;        /* Points to top-most in stack of all nested
1015
                                 * procedure invocations.  NULL means there
1016
                                 * are no active procedures. */
1017
    CallFrame *varFramePtr;     /* Points to the call frame whose variables
1018
                                 * are currently in use (same as framePtr
1019
                                 * unless an "uplevel" command is
1020
                                 * executing). NULL means no procedure is
1021
                                 * active or "uplevel 0" is executing. */
1022
    ActiveVarTrace *activeTracePtr;
1023
                                /* First in list of active traces for
1024
                                 * interp, or NULL if no active traces. */
1025
    int returnCode;             /* Completion code to return if current
1026
                                 * procedure exits with TCL_RETURN code. */
1027
    char *errorInfo;            /* Value to store in errorInfo if returnCode
1028
                                 * is TCL_ERROR.  Malloc'ed, may be NULL */
1029
    char *errorCode;            /* Value to store in errorCode if returnCode
1030
                                 * is TCL_ERROR.  Malloc'ed, may be NULL */
1031
 
1032
    /*
1033
     * Information used by Tcl_AppendResult to keep track of partial
1034
     * results.  See Tcl_AppendResult code for details.
1035
     */
1036
 
1037
    char *appendResult;         /* Storage space for results generated
1038
                                 * by Tcl_AppendResult.  Malloc-ed.  NULL
1039
                                 * means not yet allocated. */
1040
    int appendAvl;              /* Total amount of space available at
1041
                                 * partialResult. */
1042
    int appendUsed;             /* Number of non-null bytes currently
1043
                                 * stored at partialResult. */
1044
 
1045
    /*
1046
     * A cache of compiled regular expressions.  See Tcl_RegExpCompile
1047
     * in tclUtil.c for details.
1048
     */
1049
 
1050
#define NUM_REGEXPS 5
1051
    char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled
1052
                                 * regular expression patterns.  NULL
1053
                                 * means that this slot isn't used.
1054
                                 * Malloc-ed. */
1055
    int patLengths[NUM_REGEXPS];/* Number of non-null characters in
1056
                                 * corresponding entry in patterns.
1057
                                 * -1 means entry isn't used. */
1058
    regexp *regexps[NUM_REGEXPS];
1059
                                /* Compiled forms of above strings.  Also
1060
                                 * malloc-ed, or NULL if not in use yet. */
1061
 
1062
    /*
1063
     * Information about packages.  Used only in tclPkg.c.
1064
     */
1065
 
1066
    Tcl_HashTable packageTable; /* Describes all of the packages loaded
1067
                                 * in or available to this interpreter.
1068
                                 * Keys are package names, values are
1069
                                 * (Package *) pointers. */
1070
    char *packageUnknown;       /* Command to invoke during "package
1071
                                 * require" commands for packages that
1072
                                 * aren't described in packageTable.
1073
                                 * Malloc'ed, may be NULL. */
1074
 
1075
    /*
1076
     * Miscellaneous information:
1077
     */
1078
 
1079
    int cmdCount;               /* Total number of times a command procedure
1080
                                 * has been called for this interpreter. */
1081
    int evalFlags;              /* Flags to control next call to Tcl_Eval.
1082
                                 * Normally zero, but may be set before
1083
                                 * calling Tcl_Eval.  See below for valid
1084
                                 * values. */
1085
    int termOffset;             /* Offset of character just after last one
1086
                                 * compiled or executed by Tcl_EvalObj. */
1087
    int compileEpoch;           /* Holds the current "compilation epoch"
1088
                                 * for this interpreter. This is
1089
                                 * incremented to invalidate existing
1090
                                 * ByteCodes when, e.g., a command with a
1091
                                 * compile procedure is redefined. */
1092
    Proc *compiledProcPtr;      /* If a procedure is being compiled, a
1093
                                 * pointer to its Proc structure; otherwise,
1094
                                 * this is NULL. Set by ObjInterpProc in
1095
                                 * tclProc.c and used by tclCompile.c to
1096
                                 * process local variables appropriately. */
1097
    ResolverScheme *resolverPtr;
1098
                                /* Linked list of name resolution schemes
1099
                                 * added to this interpreter.  Schemes
1100
                                 * are added/removed by calling
1101
                                 * Tcl_AddInterpResolver and
1102
                                 * Tcl_RemoveInterpResolver. */
1103
    char *scriptFile;           /* NULL means there is no nested source
1104
                                 * command active;  otherwise this points to
1105
                                 * the name of the file being sourced (it's
1106
                                 * not malloc-ed:  it points to an argument
1107
                                 * to Tcl_EvalFile. */
1108
    int flags;                  /* Various flag bits.  See below. */
1109
    long randSeed;              /* Seed used for rand() function. */
1110
    Trace *tracePtr;            /* List of traces for this interpreter. */
1111
    Tcl_HashTable *assocData;   /* Hash table for associating data with
1112
                                 * this interpreter. Cleaned up when
1113
                                 * this interpreter is deleted. */
1114
    struct ExecEnv *execEnvPtr; /* Execution environment for Tcl bytecode
1115
                                 * execution. Contains a pointer to the
1116
                                 * Tcl evaluation stack. */
1117
    Tcl_Obj *emptyObjPtr;       /* Points to an object holding an empty
1118
                                 * string. Returned by Tcl_ObjSetVar2 when
1119
                                 * variable traces change a variable in a
1120
                                 * gross way. */
1121
    char resultSpace[TCL_RESULT_SIZE+1];
1122
                                /* Static space holding small results. */
1123
} Interp;
1124
 
1125
/*
1126
 * EvalFlag bits for Interp structures:
1127
 *
1128
 * TCL_BRACKET_TERM     1 means that the current script is terminated by
1129
 *                      a close bracket rather than the end of the string.
1130
 * TCL_ALLOW_EXCEPTIONS 1 means it's OK for the script to terminate with
1131
 *                      a code other than TCL_OK or TCL_ERROR;  0 means
1132
 *                      codes other than these should be turned into errors.
1133
 */
1134
 
1135
#define TCL_BRACKET_TERM          1
1136
#define TCL_ALLOW_EXCEPTIONS      4
1137
 
1138
/*
1139
 * Flag bits for Interp structures:
1140
 *
1141
 * DELETED:             Non-zero means the interpreter has been deleted:
1142
 *                      don't process any more commands for it, and destroy
1143
 *                      the structure as soon as all nested invocations of
1144
 *                      Tcl_Eval are done.
1145
 * ERR_IN_PROGRESS:     Non-zero means an error unwind is already in
1146
 *                      progress. Zero means a command proc has been
1147
 *                      invoked since last error occured.
1148
 * ERR_ALREADY_LOGGED:  Non-zero means information has already been logged
1149
 *                      in $errorInfo for the current Tcl_Eval instance,
1150
 *                      so Tcl_Eval needn't log it (used to implement the
1151
 *                      "error message log" command).
1152
 * ERROR_CODE_SET:      Non-zero means that Tcl_SetErrorCode has been
1153
 *                      called to record information for the current
1154
 *                      error.  Zero means Tcl_Eval must clear the
1155
 *                      errorCode variable if an error is returned.
1156
 * EXPR_INITIALIZED:    Non-zero means initialization specific to
1157
 *                      expressions has been carried out.
1158
 * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler
1159
 *                      should not compile any commands into an inline
1160
 *                      sequence of instructions. This is set 1, for
1161
 *                      example, when command traces are requested.
1162
 * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the
1163
 *                      interp has not be initialized.  This is set 1
1164
 *                      when we first use the rand() or srand() functions.
1165
 * SAFE_INTERP:         Non zero means that the current interp is a
1166
 *                      safe interp (ie it has only the safe commands
1167
 *                      installed, less priviledge than a regular interp).
1168
 */
1169
 
1170
#define DELETED                  1
1171
#define ERR_IN_PROGRESS          2
1172
#define ERR_ALREADY_LOGGED       4
1173
#define ERROR_CODE_SET           8
1174
#define EXPR_INITIALIZED         0x10
1175
#define DONT_COMPILE_CMDS_INLINE 0x20
1176
#define RAND_SEED_INITIALIZED    0x40
1177
#define SAFE_INTERP              0x80
1178
 
1179
/*
1180
 *----------------------------------------------------------------
1181
 * Data structures related to command parsing. These are used in
1182
 * tclParse.c and its clients.
1183
 *----------------------------------------------------------------
1184
 */
1185
 
1186
/*
1187
 * The following data structure is used by various parsing procedures
1188
 * to hold information about where to store the results of parsing
1189
 * (e.g. the substituted contents of a quoted argument, or the result
1190
 * of a nested command).  At any given time, the space available
1191
 * for output is fixed, but a procedure may be called to expand the
1192
 * space available if the current space runs out.
1193
 */
1194
 
1195
typedef struct ParseValue {
1196
    char *buffer;               /* Address of first character in
1197
                                 * output buffer. */
1198
    char *next;                 /* Place to store next character in
1199
                                 * output buffer. */
1200
    char *end;                  /* Address of the last usable character
1201
                                 * in the buffer. */
1202
    void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed));
1203
                                /* Procedure to call when space runs out;
1204
                                 * it will make more space. */
1205
    ClientData clientData;      /* Arbitrary information for use of
1206
                                 * expandProc. */
1207
} ParseValue;
1208
 
1209
/*
1210
 * A table used to classify input characters to assist in parsing
1211
 * Tcl commands.  The table should be indexed with a signed character
1212
 * using the CHAR_TYPE macro.  The character may have a negative
1213
 * value.  The CHAR_TYPE macro takes a pointer to a signed character
1214
 * and a pointer to the last character in the source string.  If the
1215
 * src pointer is pointing at the terminating null of the string,
1216
 * CHAR_TYPE returns TCL_COMMAND_END.
1217
 */
1218
 
1219
extern unsigned char tclTypeTable[];
1220
#define CHAR_TYPE(src,last) \
1221
        (((src)==(last))?TCL_COMMAND_END:(tclTypeTable)[(int)(*(src) + 128)])
1222
 
1223
/*
1224
 * Possible values returned by CHAR_TYPE. Note that except for TCL_DOLLAR,
1225
 * these are all one byte values with a single bit set 1. This means these
1226
 * values may be bit-or'ed together (except for TCL_DOLLAR) to quickly test
1227
 * whether a character is one of several different kinds of characters.
1228
 *
1229
 * TCL_NORMAL -         All characters that don't have special significance
1230
 *                      to the Tcl language.
1231
 * TCL_SPACE -          Character is space, tab, or return.
1232
 * TCL_COMMAND_END -    Character is newline or semicolon or close-bracket
1233
 *                      or terminating null.
1234
 * TCL_QUOTE -          Character is a double-quote.
1235
 * TCL_OPEN_BRACKET -   Character is a "[".
1236
 * TCL_OPEN_BRACE -     Character is a "{".
1237
 * TCL_CLOSE_BRACE -    Character is a "}".
1238
 * TCL_BACKSLASH -      Character is a "\".
1239
 * TCL_DOLLAR -         Character is a "$".
1240
 */
1241
 
1242
#define TCL_NORMAL              0x01
1243
#define TCL_SPACE               0x02
1244
#define TCL_COMMAND_END         0x04
1245
#define TCL_QUOTE               0x08
1246
#define TCL_OPEN_BRACKET        0x10
1247
#define TCL_OPEN_BRACE          0x20
1248
#define TCL_CLOSE_BRACE         0x40
1249
#define TCL_BACKSLASH           0x80
1250
#define TCL_DOLLAR              0x00
1251
 
1252
/*
1253
 * Maximum number of levels of nesting permitted in Tcl commands (used
1254
 * to catch infinite recursion).
1255
 */
1256
 
1257
#define MAX_NESTING_DEPTH       1000
1258
 
1259
/*
1260
 * The macro below is used to modify a "char" value (e.g. by casting
1261
 * it to an unsigned character) so that it can be used safely with
1262
 * macros such as isspace.
1263
 */
1264
 
1265
#define UCHAR(c) ((unsigned char) (c))
1266
 
1267
/*
1268
 * This macro is used to determine the offset needed to safely allocate any
1269
 * data structure in memory. Given a starting offset or size, it "rounds up"
1270
 * or "aligns" the offset to the next 8-byte boundary so that any data
1271
 * structure can be placed at the resulting offset without fear of an
1272
 * alignment error.
1273
 *
1274
 * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce
1275
 * the wrong result on platforms that allocate addresses that are divisible
1276
 * by 4 or 2. Only use it for offsets or sizes.
1277
 */
1278
 
1279
#define TCL_ALIGN(x) (((int)(x) + 7) & ~7)
1280
 
1281
/*
1282
 * The following macros are used to specify the runtime platform
1283
 * setting of the tclPlatform variable.
1284
 */
1285
 
1286
typedef enum {
1287
    TCL_PLATFORM_UNIX,          /* Any Unix-like OS. */
1288
    TCL_PLATFORM_MAC,           /* MacOS. */
1289
    TCL_PLATFORM_WINDOWS        /* Any Microsoft Windows OS. */
1290
} TclPlatformType;
1291
 
1292
/*
1293
 * Flags for TclInvoke:
1294
 *
1295
 * TCL_INVOKE_HIDDEN            Invoke a hidden command; if not set,
1296
 *                              invokes an exposed command.
1297
 * TCL_INVOKE_NO_UNKNOWN        If set, "unknown" is not invoked if
1298
 *                              the command to be invoked is not found.
1299
 *                              Only has an effect if invoking an exposed
1300
 *                              command, i.e. if TCL_INVOKE_HIDDEN is not
1301
 *                              also set.
1302
 */
1303
 
1304
#define TCL_INVOKE_HIDDEN       (1<<0)
1305
#define TCL_INVOKE_NO_UNKNOWN   (1<<1)
1306
 
1307
/*
1308
 * The structure used as the internal representation of Tcl list
1309
 * objects. This is an array of pointers to the element objects. This array
1310
 * is grown (reallocated and copied) as necessary to hold all the list's
1311
 * element pointers. The array might contain more slots than currently used
1312
 * to hold all element pointers. This is done to make append operations
1313
 * faster.
1314
 */
1315
 
1316
typedef struct List {
1317
    int maxElemCount;           /* Total number of element array slots. */
1318
    int elemCount;              /* Current number of list elements. */
1319
    Tcl_Obj **elements;         /* Array of pointers to element objects. */
1320
} List;
1321
 
1322
/*
1323
 * The following types are used for getting and storing platform-specific
1324
 * file attributes in tclFCmd.c and the various platform-versions of
1325
 * that file. This is done to have as much common code as possible
1326
 * in the file attributes code. For more information about the callbacks,
1327
 * see TclFileAttrsCmd in tclFCmd.c.
1328
 */
1329
 
1330
typedef int (TclGetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
1331
        int objIndex, char *fileName,
1332
        Tcl_Obj **attrObjPtrPtr));
1333
typedef int (TclSetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
1334
        int objIndex, char *fileName,
1335
        Tcl_Obj *attrObjPtr));
1336
 
1337
typedef struct TclFileAttrProcs {
1338
    TclGetFileAttrProc *getProc;        /* The procedure for getting attrs. */
1339
    TclSetFileAttrProc *setProc;        /* The procedure for setting attrs. */
1340
} TclFileAttrProcs;
1341
 
1342
/*
1343
 * Opaque handle used in pipeline routines to encapsulate platform-dependent
1344
 * state.
1345
 */
1346
 
1347
typedef struct TclFile_ *TclFile;
1348
 
1349
/*
1350
 *----------------------------------------------------------------
1351
 * Data structures related to hooking 'TclStat(...)' and
1352
 * 'TclAccess(...)'.
1353
 *----------------------------------------------------------------
1354
 */
1355
 
1356
typedef struct stat TclStat_;
1357
typedef int (TclStatProc_) _ANSI_ARGS_((CONST char *path, TclStat_ *buf));
1358
typedef int (TclAccessProc_) _ANSI_ARGS_((CONST char *path, int mode));
1359
typedef Tcl_Channel (TclOpenFileChannelProc_) _ANSI_ARGS_((Tcl_Interp *interp,
1360
        char *fileName, char *modeString,
1361
        int permissions));
1362
 
1363
typedef int (*TclCmdProcType) _ANSI_ARGS_((ClientData clientData,
1364
        Tcl_Interp *interp, int argc, char *argv[]));
1365
typedef int (*TclObjCmdProcType) _ANSI_ARGS_((ClientData clientData,
1366
        Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST objv[]));
1367
 
1368
/*
1369
 *----------------------------------------------------------------
1370
 * Variables shared among Tcl modules but not used by the outside world.
1371
 *----------------------------------------------------------------
1372
 */
1373
 
1374
extern Tcl_Time                 tclBlockTime;
1375
extern int                      tclBlockTimeSet;
1376
extern char *                   tclExecutableName;
1377
extern Tcl_ChannelType          tclFileChannelType;
1378
extern char *                   tclMemDumpFileName;
1379
extern TclPlatformType          tclPlatform;
1380
extern char *                   tclpFileAttrStrings[];
1381
extern CONST TclFileAttrProcs   tclpFileAttrProcs[];
1382
 
1383
/*
1384
 * Variables denoting the Tcl object types defined in the core.
1385
 */
1386
 
1387
extern Tcl_ObjType      tclBooleanType;
1388
extern Tcl_ObjType      tclByteCodeType;
1389
extern Tcl_ObjType      tclDoubleType;
1390
extern Tcl_ObjType      tclIntType;
1391
extern Tcl_ObjType      tclListType;
1392
extern Tcl_ObjType      tclProcBodyType;
1393
extern Tcl_ObjType      tclStringType;
1394
 
1395
/*
1396
 * The head of the list of free Tcl objects, and the total number of Tcl
1397
 * objects ever allocated and freed.
1398
 */
1399
 
1400
extern Tcl_Obj *        tclFreeObjList;
1401
 
1402
#ifdef TCL_COMPILE_STATS
1403
extern long             tclObjsAlloced;
1404
extern long             tclObjsFreed;
1405
#endif /* TCL_COMPILE_STATS */
1406
 
1407
/*
1408
 * Pointer to a heap-allocated string of length zero that the Tcl core uses
1409
 * as the value of an empty string representation for an object. This value
1410
 * is shared by all new objects allocated by Tcl_NewObj.
1411
 */
1412
 
1413
extern char *           tclEmptyStringRep;
1414
 
1415
/*
1416
 *----------------------------------------------------------------
1417
 * Procedures shared among Tcl modules but not used by the outside
1418
 * world:
1419
 *----------------------------------------------------------------
1420
 */
1421
 
1422
EXTERN void             panic _ANSI_ARGS_(TCL_VARARGS(char *,format));
1423
EXTERN int              TclAccess _ANSI_ARGS_((CONST char *path,
1424
                            int mode));
1425
EXTERN int              TclAccessDeleteProc _ANSI_ARGS_((TclAccessProc_ *proc));
1426
EXTERN int              TclAccessInsertProc _ANSI_ARGS_((TclAccessProc_ *proc));
1427
EXTERN void             TclAllocateFreeObjects _ANSI_ARGS_((void));
1428
EXTERN int              TclChdir _ANSI_ARGS_((Tcl_Interp *interp,
1429
                            char *dirName));
1430
EXTERN int              TclCleanupChildren _ANSI_ARGS_((Tcl_Interp *interp,
1431
                            int numPids, Tcl_Pid *pidPtr,
1432
                            Tcl_Channel errorChan));
1433
EXTERN void             TclCleanupCommand _ANSI_ARGS_((Command *cmdPtr));
1434
EXTERN int              TclCopyAndCollapse _ANSI_ARGS_((int count,
1435
                            char *src, char *dst));
1436
EXTERN int              TclCopyChannel _ANSI_ARGS_((Tcl_Interp *interp,
1437
                            Tcl_Channel inChan, Tcl_Channel outChan,
1438
                            int toRead, Tcl_Obj *cmdPtr));
1439
/*
1440
 * TclCreatePipeline unofficially exported for use by BLT.
1441
 */
1442
EXTERN int              TclCreatePipeline _ANSI_ARGS_((Tcl_Interp *interp,
1443
                            int argc, char **argv, Tcl_Pid **pidArrayPtr,
1444
                            TclFile *inPipePtr, TclFile *outPipePtr,
1445
                            TclFile *errFilePtr));
1446
EXTERN int              TclCreateProc _ANSI_ARGS_((Tcl_Interp *interp,
1447
                            Namespace *nsPtr, char *procName,
1448
                            Tcl_Obj *argsPtr, Tcl_Obj *bodyPtr,
1449
                            Proc **procPtrPtr));
1450
EXTERN void             TclDeleteCompiledLocalVars _ANSI_ARGS_((
1451
                            Interp *iPtr, CallFrame *framePtr));
1452
EXTERN void             TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
1453
                            Tcl_HashTable *tablePtr));
1454
EXTERN int              TclDoGlob _ANSI_ARGS_((Tcl_Interp *interp,
1455
                            char *separators, Tcl_DString *headPtr,
1456
                            char *tail));
1457
EXTERN void             TclDumpMemoryInfo _ANSI_ARGS_((FILE *outFile));
1458
EXTERN void             TclExpandParseValue _ANSI_ARGS_((ParseValue *pvPtr,
1459
                            int needed));
1460
EXTERN void             TclExprFloatError _ANSI_ARGS_((Tcl_Interp *interp,
1461
                            double value));
1462
EXTERN int              TclFileAttrsCmd _ANSI_ARGS_((Tcl_Interp *interp,
1463
                            int objc, Tcl_Obj *CONST objv[]));
1464
EXTERN int              TclFileCopyCmd _ANSI_ARGS_((Tcl_Interp *interp,
1465
                            int argc, char **argv)) ;
1466
EXTERN int              TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp,
1467
                            int argc, char **argv));
1468
EXTERN int              TclFileMakeDirsCmd _ANSI_ARGS_((Tcl_Interp *interp,
1469
                            int argc, char **argv)) ;
1470
EXTERN int              TclFileRenameCmd _ANSI_ARGS_((Tcl_Interp *interp,
1471
                            int argc, char **argv)) ;
1472
EXTERN void             TclFinalizeCompExecEnv _ANSI_ARGS_((void));
1473
EXTERN void             TclFinalizeEnvironment _ANSI_ARGS_((void));
1474
EXTERN void             TclFinalizeExecEnv _ANSI_ARGS_((void));
1475
EXTERN int              TclFindElement _ANSI_ARGS_((Tcl_Interp *interp,
1476
                            char *list, int listLength, char **elementPtr,
1477
                            char **nextPtr, int *sizePtr, int *bracePtr));
1478
EXTERN Proc *           TclFindProc _ANSI_ARGS_((Interp *iPtr,
1479
                            char *procName));
1480
EXTERN int              TclFormatInt _ANSI_ARGS_((char *buffer, long n));
1481
EXTERN void             TclFreePackageInfo _ANSI_ARGS_((Interp *iPtr));
1482
EXTERN void             TclGetAndDetachPids _ANSI_ARGS_((Tcl_Interp *interp,
1483
                            Tcl_Channel chan));
1484
EXTERN char *           TclGetCwd _ANSI_ARGS_((Tcl_Interp *interp));
1485
EXTERN int              TclGetDate _ANSI_ARGS_((char *p,
1486
                            unsigned long now, long zone,
1487
                            unsigned long *timePtr));
1488
EXTERN Tcl_Channel      TclGetDefaultStdChannel _ANSI_ARGS_((int type));
1489
EXTERN Tcl_Obj *        TclGetElementOfIndexedArray _ANSI_ARGS_((
1490
                            Tcl_Interp *interp, int localIndex,
1491
                            Tcl_Obj *elemPtr, int leaveErrorMsg));
1492
EXTERN char *           TclGetEnv _ANSI_ARGS_((CONST char *name));
1493
EXTERN char *           TclGetExtension _ANSI_ARGS_((char *name));
1494
EXTERN int              TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp,
1495
                            char *string, CallFrame **framePtrPtr));
1496
EXTERN TclCmdProcType   TclGetInterpProc _ANSI_ARGS_((void));
1497
EXTERN int              TclGetIntForIndex _ANSI_ARGS_((Tcl_Interp *interp,
1498
                            Tcl_Obj *objPtr, int endValue, int *indexPtr));
1499
EXTERN Tcl_Obj *        TclGetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
1500
                            int localIndex, int leaveErrorMsg));
1501
EXTERN int              TclGetLong _ANSI_ARGS_((Tcl_Interp *interp,
1502
                            char *string, long *longPtr));
1503
EXTERN int              TclGetLoadedPackages _ANSI_ARGS_((
1504
                            Tcl_Interp *interp, char *targetName));
1505
EXTERN int              TclGetNamespaceForQualName _ANSI_ARGS_((
1506
                            Tcl_Interp *interp, char *qualName,
1507
                            Namespace *cxtNsPtr, int flags,
1508
                            Namespace **nsPtrPtr, Namespace **altNsPtrPtr,
1509
                            Namespace **actualCxtPtrPtr,
1510
                            char **simpleNamePtr));
1511
EXTERN TclObjCmdProcType TclGetObjInterpProc _ANSI_ARGS_((void));
1512
EXTERN int              TclGetOpenMode _ANSI_ARGS_((Tcl_Interp *interp,
1513
                            char *string, int *seekFlagPtr));
1514
EXTERN Tcl_Command      TclGetOriginalCommand _ANSI_ARGS_((
1515
                            Tcl_Command command));
1516
EXTERN char *           TclGetUserHome _ANSI_ARGS_((char *name,
1517
                            Tcl_DString *bufferPtr));
1518
EXTERN int              TclGlobalInvoke _ANSI_ARGS_((Tcl_Interp *interp,
1519
                            int argc, char **argv, int flags));
1520
EXTERN int              TclGuessPackageName _ANSI_ARGS_((char *fileName,
1521
                            Tcl_DString *bufPtr));
1522
EXTERN int              TclHasSockets _ANSI_ARGS_((Tcl_Interp *interp));
1523
EXTERN int              TclHideUnsafeCommands _ANSI_ARGS_((
1524
                            Tcl_Interp *interp));
1525
EXTERN int              TclInExit _ANSI_ARGS_((void));
1526
EXTERN Tcl_Obj *        TclIncrElementOfIndexedArray _ANSI_ARGS_((
1527
                            Tcl_Interp *interp, int localIndex,
1528
                            Tcl_Obj *elemPtr, long incrAmount));
1529
EXTERN Tcl_Obj *        TclIncrIndexedScalar _ANSI_ARGS_((
1530
                            Tcl_Interp *interp, int localIndex,
1531
                            long incrAmount));
1532
EXTERN Tcl_Obj *        TclIncrVar2 _ANSI_ARGS_((Tcl_Interp *interp,
1533
                            Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
1534
                            long incrAmount, int part1NotParsed));
1535
EXTERN void             TclInitCompiledLocals _ANSI_ARGS_((
1536
                            Tcl_Interp *interp, CallFrame *framePtr,
1537
                            Namespace *nsPtr));
1538
EXTERN void             TclInitNamespaces _ANSI_ARGS_((void));
1539
EXTERN int              TclInterpInit _ANSI_ARGS_((Tcl_Interp *interp));
1540
EXTERN int              TclInvoke _ANSI_ARGS_((Tcl_Interp *interp,
1541
                            int argc, char **argv, int flags));
1542
EXTERN int              TclInvokeObjectCommand _ANSI_ARGS_((
1543
                            ClientData clientData, Tcl_Interp *interp,
1544
                            int argc, char **argv));
1545
EXTERN int              TclInvokeStringCommand _ANSI_ARGS_((
1546
                            ClientData clientData, Tcl_Interp *interp,
1547
                            int objc, Tcl_Obj *CONST objv[]));
1548
EXTERN Proc *           TclIsProc _ANSI_ARGS_((Command *cmdPtr));
1549
EXTERN int              TclLoadFile _ANSI_ARGS_((Tcl_Interp *interp,
1550
                            char *fileName, char *sym1, char *sym2,
1551
                            Tcl_PackageInitProc **proc1Ptr,
1552
                            Tcl_PackageInitProc **proc2Ptr));
1553
EXTERN int              TclLooksLikeInt _ANSI_ARGS_((char *p));
1554
EXTERN Var *            TclLookupVar _ANSI_ARGS_((Tcl_Interp *interp,
1555
                            char *part1, char *part2, int flags, char *msg,
1556
                            int createPart1, int createPart2,
1557
                            Var **arrayPtrPtr));
1558
EXTERN int              TclMatchFiles _ANSI_ARGS_((Tcl_Interp *interp,
1559
                            char *separators, Tcl_DString *dirPtr,
1560
                            char *pattern, char *tail));
1561
EXTERN int              TclNeedSpace _ANSI_ARGS_((char *start, char *end));
1562
EXTERN Tcl_Obj *        TclNewProcBodyObj _ANSI_ARGS_((Proc *procPtr));
1563
EXTERN int              TclObjCommandComplete _ANSI_ARGS_((Tcl_Obj *cmdPtr));
1564
EXTERN int              TclObjInterpProc _ANSI_ARGS_((ClientData clientData,
1565
                            Tcl_Interp *interp, int objc,
1566
                            Tcl_Obj *CONST objv[]));
1567
EXTERN int              TclObjInvoke _ANSI_ARGS_((Tcl_Interp *interp,
1568
                            int objc, Tcl_Obj *CONST objv[], int flags));
1569
EXTERN int              TclObjInvokeGlobal _ANSI_ARGS_((Tcl_Interp *interp,
1570
                            int objc, Tcl_Obj *CONST objv[], int flags));
1571
EXTERN int              TclOpenFileChannelDeleteProc _ANSI_ARGS_((
1572
                            TclOpenFileChannelProc_ *proc));
1573
EXTERN int              TclOpenFileChannelInsertProc _ANSI_ARGS_((
1574
                            TclOpenFileChannelProc_ *proc));
1575
EXTERN char *           TclpAlloc _ANSI_ARGS_((unsigned int size));
1576
 
1577
/*
1578
 * On a Mac, we can exit gracefully if the stack gets too small.
1579
 */
1580
 
1581
#ifdef MAC_TCL
1582
EXTERN int              TclpCheckStackSpace _ANSI_ARGS_((void));
1583
#else
1584
#define TclpCheckStackSpace() (1)
1585
#endif
1586
 
1587
EXTERN int              TclpCloseFile _ANSI_ARGS_((TclFile file));
1588
EXTERN int              TclpCopyFile _ANSI_ARGS_((char *source, char *dest));
1589
EXTERN int              TclpCopyDirectory _ANSI_ARGS_((char *source,
1590
                            char *dest, Tcl_DString *errorPtr));
1591
EXTERN Tcl_Channel      TclpCreateCommandChannel _ANSI_ARGS_((
1592
                            TclFile readFile, TclFile writeFile,
1593
                            TclFile errorFile, int numPids, Tcl_Pid *pidPtr));
1594
EXTERN int              TclpCreateDirectory _ANSI_ARGS_((char *path));
1595
EXTERN int              TclpCreatePipe _ANSI_ARGS_((TclFile *readPipe,
1596
                            TclFile *writePipe));
1597
EXTERN int              TclpCreateProcess _ANSI_ARGS_((Tcl_Interp *interp,
1598
                            int argc, char **argv, TclFile inputFile,
1599
                            TclFile outputFile, TclFile errorFile,
1600
                            Tcl_Pid *pidPtr));
1601
EXTERN TclFile          TclpCreateTempFile _ANSI_ARGS_((char *contents,
1602
                            Tcl_DString *namePtr));
1603
EXTERN int              TclpDeleteFile _ANSI_ARGS_((char *path));
1604
EXTERN void             TclpFinalize _ANSI_ARGS_((void));
1605
EXTERN void             TclpFree _ANSI_ARGS_((char *ptr));
1606
EXTERN unsigned long    TclpGetClicks _ANSI_ARGS_((void));
1607
EXTERN unsigned long    TclpGetSeconds _ANSI_ARGS_((void));
1608
EXTERN void             TclpGetTime _ANSI_ARGS_((Tcl_Time *time));
1609
EXTERN int              TclpGetTimeZone _ANSI_ARGS_((unsigned long time));
1610
EXTERN char *           TclpGetTZName _ANSI_ARGS_((void));
1611
EXTERN int              TclpListVolumes _ANSI_ARGS_((Tcl_Interp *interp));
1612
EXTERN TclFile          TclpMakeFile _ANSI_ARGS_((Tcl_Channel channel,
1613
                            int direction));
1614
EXTERN TclFile          TclpOpenFile _ANSI_ARGS_((char *fname, int mode));
1615
EXTERN Tcl_Channel      TclpOpenFileChannel _ANSI_ARGS_((Tcl_Interp *interp,
1616
                            char *fileName, char *modeString,
1617
                            int permissions));
1618
EXTERN char *           TclpRealloc _ANSI_ARGS_((char *ptr,
1619
                            unsigned int size));
1620
EXTERN int              TclpRemoveDirectory _ANSI_ARGS_((char *path,
1621
                            int recursive, Tcl_DString *errorPtr));
1622
EXTERN int              TclpRenameFile _ANSI_ARGS_((char *source, char *dest));
1623
#ifndef TclpSysAlloc
1624
EXTERN VOID *           TclpSysAlloc _ANSI_ARGS_((long size, int isBin));
1625
#endif
1626
#ifndef TclpSysFree
1627
EXTERN void             TclpSysFree _ANSI_ARGS_((VOID *ptr));
1628
#endif
1629
#ifndef TclpSysRealloc
1630
EXTERN VOID *           TclpSysRealloc _ANSI_ARGS_((VOID *cp,
1631
                            unsigned int size));
1632
#endif
1633
EXTERN int              TclParseBraces _ANSI_ARGS_((Tcl_Interp *interp,
1634
                            char *string, char **termPtr, ParseValue *pvPtr));
1635
EXTERN int              TclParseNestedCmd _ANSI_ARGS_((Tcl_Interp *interp,
1636
                            char *string, int flags, char **termPtr,
1637
                            ParseValue *pvPtr));
1638
EXTERN int              TclParseQuotes _ANSI_ARGS_((Tcl_Interp *interp,
1639
                            char *string, int termChar, int flags,
1640
                            char **termPtr, ParseValue *pvPtr));
1641
EXTERN void             TclPlatformExit _ANSI_ARGS_((int status));
1642
EXTERN void             TclPlatformInit _ANSI_ARGS_((Tcl_Interp *interp));
1643
EXTERN char *           TclPrecTraceProc _ANSI_ARGS_((ClientData clientData,
1644
                            Tcl_Interp *interp, char *name1, char *name2,
1645
                            int flags));
1646
EXTERN int              TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp,
1647
                            Tcl_Interp *cmdInterp, Tcl_Command cmd));
1648
EXTERN void             TclPrintByteCodeObj _ANSI_ARGS_((Tcl_Interp *interp,
1649
                            Tcl_Obj *objPtr));
1650
EXTERN void             TclProcCleanupProc _ANSI_ARGS_((Proc *procPtr));
1651
EXTERN int              TclProcCompileProc _ANSI_ARGS_((Tcl_Interp *interp,
1652
                            Proc *procPtr, Tcl_Obj *bodyPtr, Namespace *nsPtr,
1653
                            CONST char *description, CONST char *procName));
1654
EXTERN void             TclProcDeleteProc _ANSI_ARGS_((ClientData clientData));
1655
EXTERN int              TclProcInterpProc _ANSI_ARGS_((ClientData clientData,
1656
                            Tcl_Interp *interp, int argc, char **argv));
1657
EXTERN int              TclRenameCommand _ANSI_ARGS_((Tcl_Interp *interp,
1658
                            char *oldName, char *newName)) ;
1659
EXTERN void             TclResetShadowedCmdRefs _ANSI_ARGS_((
1660
                            Tcl_Interp *interp, Command *newCmdPtr));
1661
EXTERN int              TclServiceIdle _ANSI_ARGS_((void));
1662
EXTERN Tcl_Obj *        TclSetElementOfIndexedArray _ANSI_ARGS_((
1663
                            Tcl_Interp *interp, int localIndex,
1664
                            Tcl_Obj *elemPtr, Tcl_Obj *objPtr,
1665
                            int leaveErrorMsg));
1666
EXTERN Tcl_Obj *        TclSetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
1667
                            int localIndex, Tcl_Obj *objPtr,
1668
                            int leaveErrorMsg));
1669
EXTERN char *           TclSetPreInitScript _ANSI_ARGS_((char *string));
1670
EXTERN void             TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
1671
EXTERN int              TclSockGetPort _ANSI_ARGS_((Tcl_Interp *interp,
1672
                            char *string, char *proto, int *portPtr));
1673
EXTERN int              TclSockMinimumBuffers _ANSI_ARGS_((int sock,
1674
                            int size));
1675
EXTERN int              TclStat _ANSI_ARGS_((CONST char *path,
1676
                            TclStat_ *buf));
1677
EXTERN int              TclStatDeleteProc _ANSI_ARGS_((TclStatProc_ *proc));
1678
EXTERN int              TclStatInsertProc _ANSI_ARGS_((TclStatProc_ *proc));
1679
EXTERN void             TclTeardownNamespace _ANSI_ARGS_((Namespace *nsPtr));
1680
EXTERN int              TclTestChannelCmd _ANSI_ARGS_((ClientData clientData,
1681
                            Tcl_Interp *interp, int argc, char **argv));
1682
EXTERN int              TclTestChannelEventCmd _ANSI_ARGS_((
1683
                            ClientData clientData, Tcl_Interp *interp,
1684
                            int argc, char **argv));
1685
EXTERN int              TclUpdateReturnInfo _ANSI_ARGS_((Interp *iPtr));
1686
EXTERN char *           TclWordEnd _ANSI_ARGS_((char *start, char *lastChar,
1687
                            int nested, int *semiPtr));
1688
 
1689
/*
1690
 *----------------------------------------------------------------
1691
 * Command procedures in the generic core:
1692
 *----------------------------------------------------------------
1693
 */
1694
 
1695
EXTERN int      Tcl_AfterObjCmd _ANSI_ARGS_((ClientData clientData,
1696
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1697
EXTERN int      Tcl_AppendObjCmd _ANSI_ARGS_((ClientData clientData,
1698
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1699
EXTERN int      Tcl_ArrayObjCmd _ANSI_ARGS_((ClientData clientData,
1700
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1701
EXTERN int      Tcl_BinaryObjCmd _ANSI_ARGS_((ClientData clientData,
1702
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1703
EXTERN int      Tcl_BreakCmd _ANSI_ARGS_((ClientData clientData,
1704
                    Tcl_Interp *interp, int argc, char **argv));
1705
EXTERN int      Tcl_CaseObjCmd _ANSI_ARGS_((ClientData clientData,
1706
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1707
EXTERN int      Tcl_CatchObjCmd _ANSI_ARGS_((ClientData clientData,
1708
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1709
EXTERN int      Tcl_CdObjCmd _ANSI_ARGS_((ClientData clientData,
1710
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1711
EXTERN int      Tcl_ClockObjCmd _ANSI_ARGS_((ClientData clientData,
1712
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1713
EXTERN int      Tcl_CloseObjCmd _ANSI_ARGS_((ClientData clientData,
1714
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1715
EXTERN int      Tcl_ConcatObjCmd _ANSI_ARGS_((ClientData clientData,
1716
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1717
EXTERN int      Tcl_ContinueCmd _ANSI_ARGS_((ClientData clientData,
1718
                    Tcl_Interp *interp, int argc, char **argv));
1719
EXTERN int      Tcl_EofObjCmd _ANSI_ARGS_((ClientData clientData,
1720
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1721
EXTERN int      Tcl_ErrorObjCmd _ANSI_ARGS_((ClientData clientData,
1722
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1723
EXTERN int      Tcl_EvalObjCmd _ANSI_ARGS_((ClientData clientData,
1724
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1725
EXTERN int      Tcl_ExecCmd _ANSI_ARGS_((ClientData clientData,
1726
                    Tcl_Interp *interp, int argc, char **argv));
1727
EXTERN int      Tcl_ExitObjCmd _ANSI_ARGS_((ClientData clientData,
1728
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1729
EXTERN int      Tcl_ExprObjCmd _ANSI_ARGS_((ClientData clientData,
1730
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1731
EXTERN int      Tcl_FblockedObjCmd _ANSI_ARGS_((ClientData clientData,
1732
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1733
EXTERN int      Tcl_FconfigureCmd _ANSI_ARGS_((ClientData clientData,
1734
                    Tcl_Interp *interp, int argc, char **argv));
1735
EXTERN int      Tcl_FcopyObjCmd _ANSI_ARGS_((ClientData dummy,
1736
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1737
EXTERN int      Tcl_FileObjCmd _ANSI_ARGS_((ClientData dummy,
1738
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1739
EXTERN int      Tcl_FileEventCmd _ANSI_ARGS_((ClientData clientData,
1740
                    Tcl_Interp *interp, int argc, char **argv));
1741
EXTERN int      Tcl_FlushObjCmd _ANSI_ARGS_((ClientData clientData,
1742
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1743
EXTERN int      Tcl_ForCmd _ANSI_ARGS_((ClientData clientData,
1744
                    Tcl_Interp *interp, int argc, char **argv));
1745
EXTERN int      Tcl_ForeachObjCmd _ANSI_ARGS_((ClientData clientData,
1746
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1747
EXTERN int      Tcl_FormatObjCmd _ANSI_ARGS_((ClientData dummy,
1748
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1749
EXTERN int      Tcl_GetsObjCmd _ANSI_ARGS_((ClientData clientData,
1750
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1751
EXTERN int      Tcl_GlobalObjCmd _ANSI_ARGS_((ClientData clientData,
1752
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1753
EXTERN int      Tcl_GlobCmd _ANSI_ARGS_((ClientData clientData,
1754
                    Tcl_Interp *interp, int argc, char **argv));
1755
EXTERN int      Tcl_IfCmd _ANSI_ARGS_((ClientData clientData,
1756
                    Tcl_Interp *interp, int argc, char **argv));
1757
EXTERN int      Tcl_IncrCmd _ANSI_ARGS_((ClientData clientData,
1758
                    Tcl_Interp *interp, int argc, char **argv));
1759
EXTERN int      Tcl_InfoObjCmd _ANSI_ARGS_((ClientData clientData,
1760
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1761
EXTERN int      Tcl_InterpObjCmd _ANSI_ARGS_((ClientData clientData,
1762
                    Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[]));
1763
EXTERN int      Tcl_JoinObjCmd _ANSI_ARGS_((ClientData clientData,
1764
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1765
EXTERN int      Tcl_LappendObjCmd _ANSI_ARGS_((ClientData clientData,
1766
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1767
EXTERN int      Tcl_LindexObjCmd _ANSI_ARGS_((ClientData clientData,
1768
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1769
EXTERN int      Tcl_LinsertObjCmd _ANSI_ARGS_((ClientData clientData,
1770
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1771
EXTERN int      Tcl_LlengthObjCmd _ANSI_ARGS_((ClientData clientData,
1772
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1773
EXTERN int      Tcl_ListObjCmd _ANSI_ARGS_((ClientData clientData,
1774
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1775
EXTERN int      Tcl_LoadCmd _ANSI_ARGS_((ClientData clientData,
1776
                    Tcl_Interp *interp, int argc, char **argv));
1777
EXTERN int      Tcl_LrangeObjCmd _ANSI_ARGS_((ClientData clientData,
1778
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1779
EXTERN int      Tcl_LreplaceObjCmd _ANSI_ARGS_((ClientData clientData,
1780
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1781
EXTERN int      Tcl_LsearchObjCmd _ANSI_ARGS_((ClientData clientData,
1782
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1783
EXTERN int      Tcl_LsortObjCmd _ANSI_ARGS_((ClientData clientData,
1784
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1785
EXTERN int      Tcl_NamespaceObjCmd _ANSI_ARGS_((ClientData clientData,
1786
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1787
EXTERN int      Tcl_OpenCmd _ANSI_ARGS_((ClientData clientData,
1788
                    Tcl_Interp *interp, int argc, char **argv));
1789
EXTERN int      Tcl_PackageCmd _ANSI_ARGS_((ClientData clientData,
1790
                    Tcl_Interp *interp, int argc, char **argv));
1791
EXTERN int      Tcl_PidObjCmd _ANSI_ARGS_((ClientData clientData,
1792
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1793
EXTERN int      Tcl_ProcObjCmd _ANSI_ARGS_((ClientData clientData,
1794
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1795
EXTERN int      Tcl_PutsObjCmd _ANSI_ARGS_((ClientData clientData,
1796
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1797
EXTERN int      Tcl_PwdCmd _ANSI_ARGS_((ClientData clientData,
1798
                    Tcl_Interp *interp, int argc, char **argv));
1799
EXTERN int      Tcl_ReadObjCmd _ANSI_ARGS_((ClientData clientData,
1800
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1801
EXTERN int      Tcl_RegexpCmd _ANSI_ARGS_((ClientData clientData,
1802
                    Tcl_Interp *interp, int argc, char **argv));
1803
EXTERN int      Tcl_RegsubCmd _ANSI_ARGS_((ClientData clientData,
1804
                    Tcl_Interp *interp, int argc, char **argv));
1805
EXTERN int      Tcl_RenameObjCmd _ANSI_ARGS_((ClientData clientData,
1806
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1807
EXTERN int      Tcl_ReturnObjCmd _ANSI_ARGS_((ClientData clientData,
1808
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1809
EXTERN int      Tcl_ScanCmd _ANSI_ARGS_((ClientData clientData,
1810
                    Tcl_Interp *interp, int argc, char **argv));
1811
EXTERN int      Tcl_SeekCmd _ANSI_ARGS_((ClientData clientData,
1812
                    Tcl_Interp *interp, int argc, char **argv));
1813
EXTERN int      Tcl_SetCmd _ANSI_ARGS_((ClientData clientData,
1814
                    Tcl_Interp *interp, int argc, char **argv));
1815
EXTERN int      Tcl_SplitObjCmd _ANSI_ARGS_((ClientData clientData,
1816
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1817
EXTERN int      Tcl_SocketCmd _ANSI_ARGS_((ClientData clientData,
1818
                    Tcl_Interp *interp, int argc, char **argv));
1819
EXTERN int      Tcl_SourceObjCmd _ANSI_ARGS_((ClientData clientData,
1820
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1821
EXTERN int      Tcl_StringObjCmd _ANSI_ARGS_((ClientData clientData,
1822
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1823
EXTERN int      Tcl_SubstCmd _ANSI_ARGS_((ClientData clientData,
1824
                    Tcl_Interp *interp, int argc, char **argv));
1825
EXTERN int      Tcl_SwitchObjCmd _ANSI_ARGS_((ClientData clientData,
1826
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1827
EXTERN int      Tcl_TellCmd _ANSI_ARGS_((ClientData clientData,
1828
                    Tcl_Interp *interp, int argc, char **argv));
1829
EXTERN int      Tcl_TimeObjCmd _ANSI_ARGS_((ClientData clientData,
1830
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1831
EXTERN int      Tcl_TraceCmd _ANSI_ARGS_((ClientData clientData,
1832
                    Tcl_Interp *interp, int argc, char **argv));
1833
EXTERN int      Tcl_UnsetObjCmd _ANSI_ARGS_((ClientData clientData,
1834
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1835
EXTERN int      Tcl_UpdateCmd _ANSI_ARGS_((ClientData clientData,
1836
                    Tcl_Interp *interp, int argc, char **argv));
1837
EXTERN int      Tcl_UplevelObjCmd _ANSI_ARGS_((ClientData clientData,
1838
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1839
EXTERN int      Tcl_UpvarObjCmd _ANSI_ARGS_((ClientData clientData,
1840
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1841
EXTERN int      Tcl_VariableObjCmd _ANSI_ARGS_((ClientData clientData,
1842
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1843
EXTERN int      Tcl_VwaitCmd _ANSI_ARGS_((ClientData clientData,
1844
                    Tcl_Interp *interp, int argc, char **argv));
1845
EXTERN int      Tcl_WhileCmd _ANSI_ARGS_((ClientData clientData,
1846
                    Tcl_Interp *interp, int argc, char **argv));
1847
 
1848
/*
1849
 *----------------------------------------------------------------
1850
 * Command procedures found only in the Mac version of the core:
1851
 *----------------------------------------------------------------
1852
 */
1853
 
1854
#ifdef MAC_TCL
1855
EXTERN int      Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData,
1856
                    Tcl_Interp *interp, int argc, char **argv));
1857
EXTERN int      Tcl_LsCmd _ANSI_ARGS_((ClientData clientData,
1858
                    Tcl_Interp *interp, int argc, char **argv));
1859
EXTERN int      Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData,
1860
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1861
EXTERN int      Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData,
1862
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1863
EXTERN int      Tcl_ResourceObjCmd _ANSI_ARGS_((ClientData clientData,
1864
                    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
1865
#endif
1866
 
1867
/*
1868
 *----------------------------------------------------------------
1869
 * Compilation procedures for commands in the generic core:
1870
 *----------------------------------------------------------------
1871
 */
1872
 
1873
EXTERN int      TclCompileBreakCmd _ANSI_ARGS_((Tcl_Interp *interp,
1874
                    char *string, char *lastChar, int compileFlags,
1875
                    struct CompileEnv *compileEnvPtr));
1876
EXTERN int      TclCompileCatchCmd _ANSI_ARGS_((Tcl_Interp *interp,
1877
                    char *string, char *lastChar, int compileFlags,
1878
                    struct CompileEnv *compileEnvPtr));
1879
EXTERN int      TclCompileContinueCmd _ANSI_ARGS_((Tcl_Interp *interp,
1880
                    char *string, char *lastChar, int compileFlags,
1881
                    struct CompileEnv *compileEnvPtr));
1882
EXTERN int      TclCompileExprCmd _ANSI_ARGS_((Tcl_Interp *interp,
1883
                    char *string, char *lastChar, int compileFlags,
1884
                    struct CompileEnv *compileEnvPtr));
1885
EXTERN int      TclCompileForCmd _ANSI_ARGS_((Tcl_Interp *interp,
1886
                    char *string, char *lastChar, int compileFlags,
1887
                    struct CompileEnv *compileEnvPtr));
1888
EXTERN int      TclCompileForeachCmd _ANSI_ARGS_((Tcl_Interp *interp,
1889
                    char *string, char *lastChar, int compileFlags,
1890
                    struct CompileEnv *compileEnvPtr));
1891
EXTERN int      TclCompileIfCmd _ANSI_ARGS_((Tcl_Interp *interp,
1892
                    char *string, char *lastChar, int compileFlags,
1893
                    struct CompileEnv *compileEnvPtr));
1894
EXTERN int      TclCompileIncrCmd _ANSI_ARGS_((Tcl_Interp *interp,
1895
                    char *string, char *lastChar, int compileFlags,
1896
                    struct CompileEnv *compileEnvPtr));
1897
EXTERN int      TclCompileSetCmd _ANSI_ARGS_((Tcl_Interp *interp,
1898
                    char *string, char *lastChar, int compileFlags,
1899
                    struct CompileEnv *compileEnvPtr));
1900
EXTERN int      TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp,
1901
                    char *string, char *lastChar, int compileFlags,
1902
                    struct CompileEnv *compileEnvPtr));
1903
 
1904
/*
1905
 *----------------------------------------------------------------
1906
 * Macros used by the Tcl core to create and release Tcl objects.
1907
 * TclNewObj(objPtr) creates a new object denoting an empty string.
1908
 * TclDecrRefCount(objPtr) decrements the object's reference count,
1909
 * and frees the object if its reference count is zero.
1910
 * These macros are inline versions of Tcl_NewObj() and
1911
 * Tcl_DecrRefCount(). Notice that the names differ in not having
1912
 * a "_" after the "Tcl". Notice also that these macros reference
1913
 * their argument more than once, so you should avoid calling them
1914
 * with an expression that is expensive to compute or has
1915
 * side effects. The ANSI C "prototypes" for these macros are:
1916
 *
1917
 * EXTERN void  TclNewObj _ANSI_ARGS_((Tcl_Obj *objPtr));
1918
 * EXTERN void  TclDecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
1919
 *----------------------------------------------------------------
1920
 */
1921
 
1922
#ifdef TCL_COMPILE_STATS
1923
#  define TclIncrObjsAllocated() \
1924
    tclObjsAlloced++
1925
#  define TclIncrObjsFreed() \
1926
    tclObjsFreed++
1927
#else
1928
#  define TclIncrObjsAllocated()
1929
#  define TclIncrObjsFreed()
1930
#endif /* TCL_COMPILE_STATS */
1931
 
1932
#ifdef TCL_MEM_DEBUG
1933
#  define TclNewObj(objPtr) \
1934
    (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__); \
1935
    (objPtr)->refCount = 0; \
1936
    (objPtr)->bytes    = tclEmptyStringRep; \
1937
    (objPtr)->length   = 0; \
1938
    (objPtr)->typePtr  = NULL; \
1939
    TclIncrObjsAllocated()
1940
#  define TclDbNewObj(objPtr, file, line) \
1941
    (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
1942
    (objPtr)->refCount = 0; \
1943
    (objPtr)->bytes    = tclEmptyStringRep; \
1944
    (objPtr)->length   = 0; \
1945
    (objPtr)->typePtr  = NULL; \
1946
    TclIncrObjsAllocated()
1947
#  define TclDecrRefCount(objPtr) \
1948
    if (--(objPtr)->refCount <= 0) { \
1949
        if ((objPtr)->refCount < -1) \
1950
            panic("Reference count for %lx was negative: %s line %d", \
1951
                  (objPtr), __FILE__, __LINE__); \
1952
        if (((objPtr)->bytes != NULL) \
1953
                && ((objPtr)->bytes != tclEmptyStringRep)) { \
1954
            ckfree((char *) (objPtr)->bytes); \
1955
        } \
1956
        if (((objPtr)->typePtr != NULL) \
1957
                && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
1958
            (objPtr)->typePtr->freeIntRepProc(objPtr); \
1959
        } \
1960
        ckfree((char *) (objPtr)); \
1961
        TclIncrObjsFreed(); \
1962
    }
1963
#else /* not TCL_MEM_DEBUG */
1964
#  define TclNewObj(objPtr) \
1965
    if (tclFreeObjList == NULL) { \
1966
        TclAllocateFreeObjects(); \
1967
    } \
1968
    (objPtr) = tclFreeObjList; \
1969
    tclFreeObjList = (Tcl_Obj *) \
1970
        tclFreeObjList->internalRep.otherValuePtr; \
1971
    (objPtr)->refCount = 0; \
1972
    (objPtr)->bytes    = tclEmptyStringRep; \
1973
    (objPtr)->length   = 0; \
1974
    (objPtr)->typePtr  = NULL; \
1975
    TclIncrObjsAllocated()
1976
#  define TclDecrRefCount(objPtr) \
1977
    if (--(objPtr)->refCount <= 0) { \
1978
        if (((objPtr)->bytes != NULL) \
1979
                && ((objPtr)->bytes != tclEmptyStringRep)) { \
1980
            ckfree((char *) (objPtr)->bytes); \
1981
        } \
1982
        if (((objPtr)->typePtr != NULL) \
1983
                && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
1984
            (objPtr)->typePtr->freeIntRepProc(objPtr); \
1985
        } \
1986
        (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
1987
        tclFreeObjList = (objPtr); \
1988
        TclIncrObjsFreed(); \
1989
    }
1990
#endif /* TCL_MEM_DEBUG */
1991
 
1992
/*
1993
 *----------------------------------------------------------------
1994
 * Macro used by the Tcl core to set a Tcl_Obj's string representation
1995
 * to a copy of the "len" bytes starting at "bytePtr". This code
1996
 * works even if the byte array contains NULLs as long as the length
1997
 * is correct. Because "len" is referenced multiple times, it should
1998
 * be as simple an expression as possible. The ANSI C "prototype" for
1999
 * this macro is:
2000
 *
2001
 * EXTERN void  TclInitStringRep _ANSI_ARGS_((Tcl_Obj *objPtr,
2002
 *                  char *bytePtr, int len));
2003
 *----------------------------------------------------------------
2004
 */
2005
 
2006
#define TclInitStringRep(objPtr, bytePtr, len) \
2007
    if ((len) == 0) { \
2008
        (objPtr)->bytes  = tclEmptyStringRep; \
2009
        (objPtr)->length = 0; \
2010
    } else { \
2011
        (objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \
2012
        memcpy((VOID *) (objPtr)->bytes, (VOID *) (bytePtr), \
2013
                (unsigned) (len)); \
2014
        (objPtr)->bytes[len] = '\0'; \
2015
        (objPtr)->length = (len); \
2016
    }
2017
 
2018
/*
2019
 *----------------------------------------------------------------
2020
 * Macro used by the Tcl core to get the string representation's
2021
 * byte array pointer and length from a Tcl_Obj. This is an inline
2022
 * version of Tcl_GetStringFromObj(). "lengthPtr" must be the
2023
 * address of an integer variable or NULL; If non-NULL, that variable
2024
 * will be set to the string rep's length. The macro's expression
2025
 * result is the string rep's byte pointer which might be NULL.
2026
 * Note that the bytes referenced by this pointer must not be modified
2027
 * by the caller. The ANSI C "prototype" for this macro is:
2028
 *
2029
 * EXTERN char *  TclGetStringFromObj _ANSI_ARGS_((Tcl_Obj *objPtr,
2030
 *                     int *lengthPtr));
2031
 *----------------------------------------------------------------
2032
 */
2033
 
2034
#define TclGetStringFromObj(objPtr, lengthPtr) \
2035
    ((objPtr)->bytes? \
2036
        ((lengthPtr)? \
2037
            ((*(lengthPtr) = (objPtr)->length), (objPtr)->bytes) : \
2038
            (objPtr)->bytes) : \
2039
        Tcl_GetStringFromObj((objPtr), (lengthPtr)))
2040
 
2041
/*
2042
 *----------------------------------------------------------------
2043
 * Macro used by the Tcl core to reset an interpreter's Tcl object
2044
 * result to an unshared empty string object with ref count one.
2045
 * This does not clear any error information for the interpreter.
2046
 * The ANSI C "prototype" for this macro is:
2047
 *
2048
 * EXTERN void  TclResetObjResult _ANSI_ARGS_((Tcl_Interp *interp));
2049
 *---------------------------------------------------------------
2050
 */
2051
 
2052
#define TclResetObjResult(interp) \
2053
    { \
2054
        register Tcl_Obj *objResultPtr = ((Interp *) interp)->objResultPtr; \
2055
        if (Tcl_IsShared(objResultPtr)) { \
2056
            TclDecrRefCount(objResultPtr); \
2057
            TclNewObj(objResultPtr); \
2058
            Tcl_IncrRefCount(objResultPtr); \
2059
            ((Interp *) interp)->objResultPtr = objResultPtr; \
2060
        } else { \
2061
            if ((objResultPtr->bytes != NULL) \
2062
                    && (objResultPtr->bytes != tclEmptyStringRep)) { \
2063
                ckfree((char *) objResultPtr->bytes); \
2064
            } \
2065
            objResultPtr->bytes  = tclEmptyStringRep; \
2066
            objResultPtr->length = 0; \
2067
            if ((objResultPtr->typePtr != NULL) \
2068
                    && (objResultPtr->typePtr->freeIntRepProc != NULL)) { \
2069
                objResultPtr->typePtr->freeIntRepProc(objResultPtr); \
2070
            } \
2071
            objResultPtr->typePtr = (Tcl_ObjType *) NULL; \
2072
        } \
2073
    }
2074
 
2075
/*
2076
 *----------------------------------------------------------------
2077
 * Procedures used in conjunction with Tcl namespaces. They are
2078
 * defined here instead of in tcl.h since they are not stable yet.
2079
 *----------------------------------------------------------------
2080
 */
2081
 
2082
EXTERN void             Tcl_AddInterpResolvers _ANSI_ARGS_((Tcl_Interp *interp,
2083
                            char *name, Tcl_ResolveCmdProc *cmdProc,
2084
                            Tcl_ResolveVarProc *varProc,
2085
                            Tcl_ResolveCompiledVarProc *compiledVarProc));
2086
EXTERN int              Tcl_AppendExportList _ANSI_ARGS_((
2087
                            Tcl_Interp *interp, Tcl_Namespace *nsPtr,
2088
                            Tcl_Obj *objPtr));
2089
EXTERN Tcl_Namespace *  Tcl_CreateNamespace _ANSI_ARGS_((Tcl_Interp *interp,
2090
                            char *name, ClientData clientData,
2091
                            Tcl_NamespaceDeleteProc *deleteProc));
2092
EXTERN void             Tcl_DeleteNamespace _ANSI_ARGS_((
2093
                            Tcl_Namespace *nsPtr));
2094
EXTERN int              Tcl_Export _ANSI_ARGS_((Tcl_Interp *interp,
2095
                            Tcl_Namespace *nsPtr, char *pattern,
2096
                            int resetListFirst));
2097
EXTERN Tcl_Command      Tcl_FindCommand _ANSI_ARGS_((Tcl_Interp *interp,
2098
                            char *name, Tcl_Namespace *contextNsPtr,
2099
                            int flags));
2100
EXTERN Tcl_Namespace *  Tcl_FindNamespace _ANSI_ARGS_((Tcl_Interp *interp,
2101
                            char *name, Tcl_Namespace *contextNsPtr,
2102
                            int flags));
2103
EXTERN int              Tcl_GetInterpResolvers _ANSI_ARGS_((Tcl_Interp *interp,
2104
                            char *name, Tcl_ResolverInfo *resInfo));
2105
EXTERN int              Tcl_GetNamespaceResolvers _ANSI_ARGS_((
2106
                            Tcl_Namespace *namespacePtr,
2107
                            Tcl_ResolverInfo *resInfo));
2108
EXTERN void             Tcl_GetVariableFullName _ANSI_ARGS_((
2109
                            Tcl_Interp *interp, Tcl_Var variable,
2110
                            Tcl_Obj *objPtr));
2111
EXTERN Tcl_Var          Tcl_FindNamespaceVar _ANSI_ARGS_((
2112
                            Tcl_Interp *interp, char *name,
2113
                            Tcl_Namespace *contextNsPtr, int flags));
2114
EXTERN int              Tcl_ForgetImport _ANSI_ARGS_((Tcl_Interp *interp,
2115
                            Tcl_Namespace *nsPtr, char *pattern));
2116
EXTERN Tcl_Command      Tcl_GetCommandFromObj _ANSI_ARGS_((
2117
                            Tcl_Interp *interp, Tcl_Obj *objPtr));
2118
EXTERN void             Tcl_GetCommandFullName _ANSI_ARGS_((
2119
                            Tcl_Interp *interp, Tcl_Command command,
2120
                            Tcl_Obj *objPtr));
2121
EXTERN Tcl_Namespace *  Tcl_GetCurrentNamespace _ANSI_ARGS_((
2122
                            Tcl_Interp *interp));
2123
EXTERN Tcl_Namespace *  Tcl_GetGlobalNamespace _ANSI_ARGS_((
2124
                            Tcl_Interp *interp));
2125
EXTERN void             Tcl_GetVariableFullName _ANSI_ARGS_((
2126
                            Tcl_Interp *interp, Tcl_Var variable,
2127
                            Tcl_Obj *objPtr));
2128
EXTERN int              Tcl_Import _ANSI_ARGS_((Tcl_Interp *interp,
2129
                            Tcl_Namespace *nsPtr, char *pattern,
2130
                            int allowOverwrite));
2131
EXTERN void             Tcl_PopCallFrame _ANSI_ARGS_((Tcl_Interp* interp));
2132
EXTERN int              Tcl_PushCallFrame _ANSI_ARGS_((Tcl_Interp* interp,
2133
                            Tcl_CallFrame *framePtr, Tcl_Namespace *nsPtr,
2134
                            int isProcCallFrame));
2135
EXTERN int              Tcl_RemoveInterpResolvers _ANSI_ARGS_((
2136
                            Tcl_Interp *interp, char *name));
2137
EXTERN void             Tcl_SetNamespaceResolvers _ANSI_ARGS_((
2138
                            Tcl_Namespace *namespacePtr,
2139
                            Tcl_ResolveCmdProc *cmdProc,
2140
                            Tcl_ResolveVarProc *varProc,
2141
                            Tcl_ResolveCompiledVarProc *compiledVarProc));
2142
 
2143
# undef TCL_STORAGE_CLASS
2144
# define TCL_STORAGE_CLASS DLLIMPORT
2145
 
2146
#endif /* _TCLINT */
2147
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.