1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
-
+
|
/*
* tclProc.c --
*
* This file contains routines that implement Tcl procedures,
* including the "proc" and "uplevel" commands.
*
* Copyright (c) 1987-1993 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: %Z% $Id: tclProc.c,v 1.5 1998/07/06 14:38:20 escoffon Exp $
* SCCS: %Z% $Id: tclProc.c,v 1.6 1998/07/14 10:34:43 escoffon Exp $
*/
#include "tclInt.h"
#include "tclCompile.h"
/*
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
-
-
-
-
-
-
-
-
-
-
-
-
-
|
* in a context that includes the number of compiler-allocated "slots"
* for local variables. Each formal parameter is given a local variable
* slot (the "procPtr->numCompiledLocals = numArgs" assignment
* below). This means that the same code can not be shared by two
* procedures that have a different number of arguments, even if their
* bodies are identical. Note that we don't use Tcl_DuplicateObj since
* we would not want any bytecode internal representation.
*
* But if this is a precompiled bytecode object, then do not duplicate it;
* precompiled bytecodes are immutable, and there is no source to
* recompile anyway.
*/
bodyPtr = objv[3];
if (Tcl_IsShared(bodyPtr)) {
if (bodyPtr->typePtr == &tclByteCodeType) {
ByteCode *codePtr
= (ByteCode *) bodyPtr->internalRep.otherValuePtr;
if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
goto skip_unshare;
}
}
bytes = Tcl_GetStringFromObj(bodyPtr, &length);
bodyPtr = Tcl_NewStringObj(bytes, length);
}
skip_unshare:
/*
* Create and initialize a Proc structure for the procedure. Note that
* we initialize its cmdPtr field below after we've created the command
* for the procedure. We increment the ref count of the procedure's
* body object since there will be a reference to it in the Proc
* structure.
|