1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/*
* 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-1998 Sun Microsystems, Inc.
* Copyright (c) 2004-2006 Miguel Sofer
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclProc.c,v 1.86.2.6 2006/09/30 22:41:03 dkf Exp $
*/
#include "tclInt.h"
#include "tclCompile.h"
#include "tclOO.h"
/*
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/*
* 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-1998 Sun Microsystems, Inc.
* Copyright (c) 2004-2006 Miguel Sofer
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclProc.c,v 1.86.2.7 2006/10/08 15:39:59 dkf Exp $
*/
#include "tclInt.h"
#include "tclCompile.h"
#include "tclOO.h"
/*
|
| ︙ | | | ︙ | |
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
|
InitCompiledLocals(interp, codePtr, localPtr, varPtr, nsPtr);
}
/*
*----------------------------------------------------------------------
*
* TclObjInterpProc --
*
* When a Tcl procedure gets invoked during bytecode evaluation, this
* object-based routine gets invoked to interpret the procedure.
*
* Results:
* A standard Tcl object result value.
*
|
|
|
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
|
InitCompiledLocals(interp, codePtr, localPtr, varPtr, nsPtr);
}
/*
*----------------------------------------------------------------------
*
* TclObjInterpProc, ObjInterpProcEx --
*
* When a Tcl procedure gets invoked during bytecode evaluation, this
* object-based routine gets invoked to interpret the procedure.
*
* Results:
* A standard Tcl object result value.
*
|
| ︙ | | | ︙ | |
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
|
framePtr->objc = objc;
framePtr->objv = objv; /* ref counts for args are incremented below */
framePtr->procPtr = procPtr;
return TclObjInterpProcCore(interp, framePtr, objv[0], skip);
}
int
TclObjInterpProcCore(
register Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
CallFrame *framePtr, /* The context to execute. The procPtr field
* must be non-NULL. */
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
|
framePtr->objc = objc;
framePtr->objv = objv; /* ref counts for args are incremented below */
framePtr->procPtr = procPtr;
return TclObjInterpProcCore(interp, framePtr, objv[0], skip);
}
/*
*----------------------------------------------------------------------
*
* TclObjInterpProcCore --
*
* When a Tcl procedure, procedure-like method or lambda term gets
* invoked during bytecode evaluation, this object-based routine gets
* invoked to interpret the body.
*
* Results:
* A standard Tcl object result value.
*
* Side effects:
* Depends on the commands in the procedure body.
*
*----------------------------------------------------------------------
*/
int
TclObjInterpProcCore(
register Tcl_Interp *interp,/* Interpreter in which procedure was
* invoked. */
CallFrame *framePtr, /* The context to execute. The procPtr field
* must be non-NULL. */
|
| ︙ | | | ︙ | |
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
|
objPtr->typePtr->freeIntRepProc(objPtr);
objPtr->internalRep.twoPtrValue.ptr1 = procPtr;
objPtr->internalRep.twoPtrValue.ptr2 = nsObjPtr;
objPtr->typePtr = &lambdaType;
return TCL_OK;
}
int
Tcl_ApplyObjCmd(
ClientData dummy, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
|
objPtr->typePtr->freeIntRepProc(objPtr);
objPtr->internalRep.twoPtrValue.ptr1 = procPtr;
objPtr->internalRep.twoPtrValue.ptr2 = nsObjPtr;
objPtr->typePtr = &lambdaType;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tcl_ApplyObjCmd --
*
* This object-based function is invoked to process the "apply" Tcl
* command. See the user documentation for details on what it does.
*
* Results:
* A standard Tcl object result value.
*
* Side effects:
* Depends on the content of the lambda term (i.e., objv[1]).
*
*----------------------------------------------------------------------
*/
int
Tcl_ApplyObjCmd(
ClientData dummy, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
|
| ︙ | | | ︙ | |