Compare commits
148
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c44a55411 | ||
|
|
a33a94ec85 | ||
|
|
f36f801d24 | ||
|
|
55b0c17067 | ||
|
|
272b2008ad | ||
|
|
f7cf1b2bae | ||
|
|
8173bccfd9 | ||
|
|
a5b75dfa9a | ||
|
|
52b97dd00b | ||
|
|
f632850eb8 | ||
|
|
ed72e77b7d | ||
|
|
83d427e824 | ||
|
|
f18c1126d5 | ||
|
|
62e1b3723e | ||
|
|
4d6aaa2e8b | ||
|
|
4bf79aef9b | ||
|
|
a6f2dee7fb | ||
|
|
c084f0ea75 | ||
|
|
5cdaf0e05b | ||
|
|
fe60431f53 | ||
|
|
058f0df44d | ||
|
|
bee5c35f44 | ||
|
|
8971b5cdea | ||
|
|
0c1e275cdf | ||
|
|
a2400fbe30 | ||
|
|
211f7d6466 | ||
|
|
6dee5b3e07 | ||
|
|
9d1f38c3e3 | ||
|
|
33647e79c8 | ||
|
|
f440a6ef41 | ||
|
|
c086de021c | ||
|
|
97eb71a629 | ||
|
|
e62b40c808 | ||
|
|
234fb04984 | ||
|
|
1b7d424507 | ||
|
|
5797625e42 | ||
|
|
987422a01f | ||
|
|
5f6b71f3f2 | ||
|
|
f6f0891fff | ||
|
|
27c5ada57e | ||
|
|
5f2f5b63c3 | ||
|
|
59f7320bdd | ||
|
|
00546e5e21 | ||
|
|
a63563bd9a | ||
|
|
1d99884b08 | ||
|
|
8bd533d76e | ||
|
|
23d61a10c2 | ||
|
|
0ee8df700b | ||
|
|
50a950f2b1 | ||
|
|
c74640849e | ||
|
|
861b34625c | ||
|
|
0958b92b37 | ||
|
|
6d9ae4aa16 | ||
|
|
965128fe34 | ||
|
|
ebc5b27c8c | ||
|
|
3916ce9d4c | ||
|
|
4bd227bc12 | ||
|
|
84e92af6dc | ||
|
|
15ca940ca7 | ||
|
|
525bc7c9b5 | ||
|
|
6adf3b8c6c | ||
|
|
3d14dd6bc9 | ||
|
|
41afeeec2b | ||
|
|
623c1cbe5b | ||
|
|
60ef39d24a | ||
|
|
889454ec06 | ||
|
|
752ab085d6 | ||
|
|
c019848148 | ||
|
|
fd1c7c2fb3 | ||
|
|
8f2d19b951 | ||
|
|
f2bea640bb | ||
|
|
d818803502 | ||
|
|
e0437fdf58 | ||
|
|
8163234efd | ||
|
|
f796ad762c | ||
|
|
0185dd6477 | ||
|
|
07d10b8a58 | ||
|
|
bc28cd1ac8 | ||
|
|
9350513d16 | ||
|
|
4fb5d04b2f | ||
|
|
f287d8cb0f | ||
|
|
0c2e553e8f | ||
|
|
915c6abe66 | ||
|
|
0070244914 | ||
|
|
17ebc3cd20 | ||
|
|
5e9e003379 | ||
|
|
2aed1acbd1 | ||
|
|
81a1a91361 | ||
|
|
9a19e4cba0 | ||
|
|
c2d6c48dd9 | ||
|
|
d383707870 | ||
|
|
c33f97005c | ||
|
|
3f126895fb | ||
|
|
d848f30c45 | ||
|
|
d860a2c3a4 | ||
|
|
009f2adf3d | ||
|
|
774c402365 | ||
|
|
740d1811bc | ||
|
|
451ab6927c | ||
|
|
f302557ad5 | ||
|
|
d061b31460 | ||
|
|
783aea7d3a | ||
|
|
34c17bad36 | ||
|
|
f0992177e4 | ||
|
|
6f4f296706 | ||
|
|
75bc23d59c | ||
|
|
9d91a3db0b | ||
|
|
1dc19d8370 | ||
|
|
458197828b | ||
|
|
c079ab076f | ||
|
|
d69c39d52e | ||
|
|
7a53c36e3a | ||
|
|
ee74db1cbf | ||
|
|
1e62f5ac76 | ||
|
|
afad6ffbb4 | ||
|
|
d72d5f8b7a | ||
|
|
c46c774126 | ||
|
|
ba3bf9b61f | ||
|
|
82bddf4dca | ||
|
|
e10479f3d7 | ||
|
|
7183692271 | ||
|
|
b7fbf3c433 | ||
|
|
c10c796a46 | ||
|
|
582824087d | ||
|
|
da4296c06f | ||
|
|
0dec640514 | ||
|
|
d2b490f552 | ||
|
|
4cfafc3002 | ||
|
|
fb3fc7d5d3 | ||
|
|
de31df63e7 | ||
|
|
191c6d2137 | ||
|
|
7eab500306 | ||
|
|
88731d9d93 | ||
|
|
aec5846c12 | ||
|
|
05fb0c0810 | ||
|
|
a47b03577b | ||
|
|
fda71d6d4c | ||
|
|
7070acfea1 | ||
|
|
ddd130e532 | ||
|
|
324ca57f3d | ||
|
|
ae7b32a706 | ||
|
|
5eecd400b7 | ||
|
|
3f19b90244 | ||
|
|
11f1a88c12 | ||
|
|
9fd3e86565 | ||
|
|
dc4782f595 | ||
|
|
b6b0d1b8dd | ||
|
|
1ddb66bfda |
@@ -1,3 +1,19 @@
|
||||
2013-08-03 Donal Fellows <dkf@users.sf.net>
|
||||
|
||||
* library/auto.tcl: [Patch 3611643]: Allow TclOO classes to be found
|
||||
by the autoloading mechanism.
|
||||
|
||||
2013-08-02 Donal Fellows <dkf@users.sf.net>
|
||||
|
||||
* generic/tclOODefineCmds.c (ClassSuperSet): Bug [9d61624b3d]: Stop
|
||||
crashes when emptying the superclass slot, even when doing elaborate
|
||||
things with metaclasses.
|
||||
|
||||
2013-08-01 Harald Oehlmann <oehhar@users.sf.net>
|
||||
|
||||
* tclUnixNotify.c (Tcl_InitNotifier): Bug [a0bc856dcd]: Start notifier
|
||||
thread again if we were forked, to solve Rivet bug 55153.
|
||||
|
||||
2013-07-05 Kevin B. Kenny <kennykb@acm.org>
|
||||
|
||||
* library/tzdata/Africa/Casablanca:
|
||||
|
||||
+6
-6
@@ -176,16 +176,16 @@ these return options.
|
||||
The \fB\-errorinfo\fR option holds a stack trace of the
|
||||
operations that were in progress when an error occurred,
|
||||
and is intended to be human-readable.
|
||||
The \fB\-errorcode\fR option holds a list of items that
|
||||
The \fB\-errorcode\fR option holds a Tcl list of items that
|
||||
are intended to be machine-readable.
|
||||
The first item in the \fB\-errorcode\fR value identifies the class of
|
||||
error that occurred
|
||||
(e.g. POSIX means an error occurred in a POSIX system call)
|
||||
(e.g., POSIX means an error occurred in a POSIX system call)
|
||||
and additional elements hold additional pieces
|
||||
of information that depend on the class.
|
||||
See the \fBtclvars\fR manual entry for details on the various
|
||||
formats for the \fB\-errorcode\fR option used by
|
||||
Tcl's built-in commands.
|
||||
See the manual entry on the \fBerrorCode\fR variable for details on the
|
||||
various formats for the \fB\-errorcode\fR option used by Tcl's built-in
|
||||
commands.
|
||||
.PP
|
||||
The \fB\-errorinfo\fR option value is gradually built up as an
|
||||
error unwinds through the nested operations.
|
||||
@@ -307,6 +307,6 @@ so they continue to hold a record of information about the
|
||||
most recent error seen in an interpreter.
|
||||
.SH "SEE ALSO"
|
||||
Tcl_DecrRefCount(3), Tcl_IncrRefCount(3), Tcl_Interp(3), Tcl_ResetResult(3),
|
||||
Tcl_SetErrno(3), tclvars(n)
|
||||
Tcl_SetErrno(3), errorCode(n), errorInfo(n)
|
||||
.SH KEYWORDS
|
||||
error, value, value result, stack, trace, variable
|
||||
|
||||
+4
-3
@@ -41,8 +41,9 @@ may only be passed to Tcl routines called from the same thread as
|
||||
the original \fBTcl_CreateInterp\fR call. It is not safe for multiple
|
||||
threads to pass the same token to Tcl's routines.
|
||||
The new interpreter is initialized with the built-in Tcl commands
|
||||
and with the variables documented in the \fBtclvars\fR manual page. To bind in
|
||||
additional commands, call \fBTcl_CreateCommand\fR.
|
||||
and with standard variables like \fBtcl_platform\fR and \fBenv\fR. To
|
||||
bind in additional commands, call \fBTcl_CreateCommand\fR, and to
|
||||
create additional variables, call \fBTcl_SetVar\fR.
|
||||
.PP
|
||||
\fBTcl_DeleteInterp\fR marks an interpreter as deleted; the interpreter
|
||||
will eventually be deleted when all calls to \fBTcl_Preserve\fR for it have
|
||||
@@ -144,6 +145,6 @@ should be used to determine when an interpreter is a candidate for deletion
|
||||
due to inactivity.
|
||||
.VE 8.6
|
||||
.SH "SEE ALSO"
|
||||
Tcl_Preserve(3), Tcl_Release(3), tclvars(n)
|
||||
Tcl_Preserve(3), Tcl_Release(3)
|
||||
.SH KEYWORDS
|
||||
command, create, delete, interpreter
|
||||
|
||||
+1
-1
@@ -33,6 +33,6 @@ Tcl-based applications using \fBputenv\fR should redefine it to
|
||||
\fBTcl_PutEnv\fR so that they will interface properly to the Tcl
|
||||
runtime.
|
||||
.SH "SEE ALSO"
|
||||
tclvars(n)
|
||||
env(n)
|
||||
.SH KEYWORDS
|
||||
environment, variable
|
||||
|
||||
+3
-2
@@ -172,8 +172,9 @@ typedef struct {
|
||||
.PP
|
||||
The \fIversion\fR field allows for future expansion of the structure, and
|
||||
should always be declared equal to TCL_OO_METHOD_VERSION_CURRENT. The
|
||||
\fIname\fR field provides a human-readable name for the type, and is reserved
|
||||
for debugging.
|
||||
\fIname\fR field provides a human-readable name for the type, and is the value
|
||||
that is exposed via the \fBinfo class methodtype\fR and
|
||||
\fBinfo object methodtype\fR Tcl commands.
|
||||
.PP
|
||||
The \fIcallProc\fR field gives a function that is called when the method is
|
||||
invoked; it must never be NULL.
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
.TH NRE 3 8.6 Tcl "Tcl Library Procedures"
|
||||
.BS
|
||||
.SH NAME
|
||||
Tcl_NRCreateCommand, Tcl_NRCallObjProc, Tcl_NREvalObj, Tcl_NREvalObjv, Tcl_NRCmdSwap, Tcl_NRAddCallback \- Non-Recursive (stackless) evaluation of Tcl scripts.
|
||||
Tcl_NRCreateCommand, Tcl_NRCallObjProc, Tcl_NREvalObj, Tcl_NREvalObjv,
|
||||
Tcl_NRCmdSwap, Tcl_NRExprObj, Tcl_NRAddCallback \- Non-Recursive (stackless) evaluation of Tcl scripts.
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fB#include <tcl.h>\fR
|
||||
@@ -207,7 +208,7 @@ is something like:
|
||||
.PP
|
||||
.CS
|
||||
int
|
||||
\fITheCmdObjProc\fR(
|
||||
\fITheCmdOldObjProc\fR(
|
||||
ClientData clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
@@ -225,7 +226,7 @@ int
|
||||
return result;
|
||||
}
|
||||
\fBTcl_CreateObjCommand\fR(interp, "theCommand",
|
||||
\fITheCmdObjProc\fR, clientData, TheCmdDeleteProc);
|
||||
\fITheCmdOldObjProc\fR, clientData, TheCmdDeleteProc);
|
||||
.CE
|
||||
.PP
|
||||
To enable a command like this one for trampoline-based evaluation,
|
||||
@@ -255,8 +256,8 @@ int
|
||||
int objc,
|
||||
Tcl_Obj *const objv[])
|
||||
{
|
||||
return \fBTcl_NRCallObjProc\fR(interp, name,
|
||||
\fITheCmdNRObjProc\fR, clientData, objc, objv);
|
||||
return \fBTcl_NRCallObjProc\fR(interp, \fITheCmdNRObjProc\fR,
|
||||
clientData, objc, objv);
|
||||
}
|
||||
.CE
|
||||
.PP
|
||||
@@ -317,7 +318,7 @@ and the second is for use when there is already a trampoline in place.
|
||||
.PP
|
||||
.CS
|
||||
\fBTcl_NRCreateCommand\fR(interp, "theCommand",
|
||||
\fITheCmdObjProc\fR, \fITheCmdNRObjProc\fR, clientData,
|
||||
\fITheCmdNewObjProc\fR, \fITheCmdNRObjProc\fR, clientData,
|
||||
TheCmdDeleteProc);
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
|
||||
+4
-1
@@ -85,6 +85,9 @@ proc bgerror {message} {
|
||||
}
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
after(n), interp(n), tclvars(n)
|
||||
after(n), errorCode(n), errorInfo(n), interp(n)
|
||||
.SH KEYWORDS
|
||||
background error, reporting
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" End:
|
||||
|
||||
+1
-1
@@ -884,7 +884,7 @@ close $f
|
||||
puts [\fBbinary encode\fR base64 \-maxlen 64 $data]
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
format(n), scan(n), tclvars(n)
|
||||
format(n), scan(n), tcl_platform(n)
|
||||
.SH KEYWORDS
|
||||
binary, format, scan
|
||||
'\" Local Variables:
|
||||
|
||||
+2
-1
@@ -115,7 +115,8 @@ if { [\fBcatch\fR {open $someFile w} fid] } {
|
||||
There are more complex examples of \fBcatch\fR usage in the
|
||||
documentation for the \fBreturn\fR command.
|
||||
.SH "SEE ALSO"
|
||||
break(n), continue(n), dict(n), error(n), info(n), return(n), tclvars(n)
|
||||
break(n), continue(n), dict(n), error(n), errorCode(n), errorInfo(n), info(n),
|
||||
return(n)
|
||||
.SH KEYWORDS
|
||||
catch, error, exception
|
||||
'\" Local Variables:
|
||||
|
||||
+2
-1
@@ -75,7 +75,8 @@ However, the last line would now normally be written without
|
||||
set var [linsert $var 0 {*}$args]
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
catch(n), concat(n), error(n), interp(n), list(n), namespace(n), subst(n), tclvars(n), uplevel(n)
|
||||
catch(n), concat(n), error(n), errorCode(n), errorInfo(n), interp(n), list(n),
|
||||
namespace(n), subst(n), uplevel(n)
|
||||
.SH KEYWORDS
|
||||
concatenate, evaluate, script
|
||||
'\" Local Variables:
|
||||
|
||||
+6
-6
@@ -296,7 +296,6 @@ Returns the name of the library directory in which standard Tcl
|
||||
scripts are stored.
|
||||
This is actually the value of the \fBtcl_library\fR
|
||||
variable and may be changed by setting \fBtcl_library\fR.
|
||||
See the \fBtclvars\fR manual entry for more information.
|
||||
.TP
|
||||
\fBinfo loaded \fR?\fIinterp\fR?
|
||||
.
|
||||
@@ -336,8 +335,8 @@ described in \fBOBJECT INTROSPECTION\fR below.
|
||||
.TP
|
||||
\fBinfo patchlevel\fR
|
||||
.
|
||||
Returns the value of the global variable \fBtcl_patchLevel\fR; see
|
||||
the \fBtclvars\fR manual entry for more information.
|
||||
Returns the value of the global variable \fBtcl_patchLevel\fR, which holds
|
||||
the exact version of the Tcl library by default.
|
||||
.TP
|
||||
\fBinfo procs \fR?\fIpattern\fR?
|
||||
.
|
||||
@@ -374,8 +373,8 @@ string is returned.
|
||||
.TP
|
||||
\fBinfo tclversion\fR
|
||||
.
|
||||
Returns the value of the global variable \fBtcl_version\fR; see
|
||||
the \fBtclvars\fR manual entry for more information.
|
||||
Returns the value of the global variable \fBtcl_version\fR, which holds the
|
||||
major and minor version of the Tcl library by default.
|
||||
.TP
|
||||
\fBinfo vars\fR ?\fIpattern\fR?
|
||||
.
|
||||
@@ -763,8 +762,9 @@ proc getDef {obj method} {
|
||||
.VE 8.6
|
||||
.SH "SEE ALSO"
|
||||
.VS 8.6
|
||||
global(n), oo::class(n), oo::define(n), oo::object(n), proc(n), self(n)
|
||||
global(n), oo::class(n), oo::define(n), oo::object(n), proc(n), self(n),
|
||||
.VE 8.6
|
||||
tcl_library(n), tcl_patchLevel(n), tcl_version(n)
|
||||
.SH KEYWORDS
|
||||
command, information, interpreter, introspection, level, namespace,
|
||||
.VS 8.6
|
||||
|
||||
+7
-3
@@ -262,13 +262,17 @@ If set to any value, then \fBunknown\fR will not attempt to auto-load
|
||||
any commands.
|
||||
.TP
|
||||
\fBauto_path\fR
|
||||
.
|
||||
If set, then it must contain a valid Tcl list giving directories to
|
||||
search during auto-load operations.
|
||||
search during auto-load operations (including for package index
|
||||
files when using the default \fBpackage unknown\fR handler).
|
||||
This variable is initialized during startup to contain, in order:
|
||||
the directories listed in the \fBTCLLIBPATH\fR environment variable,
|
||||
the directory named by the \fBtcl_library\fR variable,
|
||||
the directory named by the \fBtcl_library\fR global variable,
|
||||
the parent directory of \fBtcl_library\fR,
|
||||
the directories listed in the \fBtcl_pkgPath\fR variable.
|
||||
Additional locations to look for files and package indices should
|
||||
normally be added to this variable using \fBlappend\fR.
|
||||
.TP
|
||||
\fBenv(TCL_LIBRARY)\fR
|
||||
If set, then it specifies the location of the directory containing
|
||||
@@ -306,7 +310,7 @@ considered to be a word character. On Windows platforms, words are
|
||||
comprised of any character that is not a space, tab, or newline. Under
|
||||
Unix, words are comprised of numbers, letters or underscores.
|
||||
.SH "SEE ALSO"
|
||||
info(n), re_syntax(n), tclvars(n)
|
||||
env(n), info(n), re_syntax(n)
|
||||
.SH KEYWORDS
|
||||
auto-exec, auto-load, library, unknown, word, whitespace
|
||||
'\"Local Variables:
|
||||
|
||||
+2
-2
@@ -317,8 +317,8 @@ proc myReturn {args} {
|
||||
}
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
break(n), catch(n), continue(n), dict(n), error(n), proc(n),
|
||||
source(n), tclvars(n), throw(n), try(n)
|
||||
break(n), catch(n), continue(n), dict(n), error(n), errorCode(n),
|
||||
errorInfo(n), proc(n), source(n), throw(n), try(n)
|
||||
.SH KEYWORDS
|
||||
break, catch, continue, error, exception, procedure, result, return
|
||||
.\" Local Variables:
|
||||
|
||||
+5
-3
@@ -102,7 +102,9 @@ but also the disadvantage of making it harder to write scripts that
|
||||
start up uniformly across different versions of Tcl.
|
||||
.SH "VARIABLES"
|
||||
.PP
|
||||
\fBTclsh\fR sets the following Tcl variables:
|
||||
\fBTclsh\fR sets the following global Tcl variables in addition to those
|
||||
created by the Tcl library itself (such as \fBenv\fR, which maps
|
||||
environment variables such as \fBPATH\fR into Tcl):
|
||||
.TP 15
|
||||
\fBargc\fR
|
||||
.
|
||||
@@ -129,7 +131,7 @@ device), 0 otherwise.
|
||||
When \fBtclsh\fR is invoked interactively it normally prompts for each
|
||||
command with
|
||||
.QW "\fB% \fR" .
|
||||
You can change the prompt by setting the
|
||||
You can change the prompt by setting the global
|
||||
variables \fBtcl_prompt1\fR and \fBtcl_prompt2\fR. If variable
|
||||
\fBtcl_prompt1\fR exists then it must consist of a Tcl script
|
||||
to output a prompt; instead of outputting a prompt \fBtclsh\fR
|
||||
@@ -142,6 +144,6 @@ incomplete commands.
|
||||
.PP
|
||||
See \fBTcl_StandardChannels\fR for more explanations.
|
||||
.SH "SEE ALSO"
|
||||
encoding(n), fconfigure(n), tclvars(n)
|
||||
auto_path(n), encoding(n), env(n), fconfigure(n)
|
||||
.SH KEYWORDS
|
||||
application, argument, interpreter, prompt, script file, shell
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ The following produces an error that is identical to that produced by
|
||||
\fBthrow\fR {ARITH DIVZERO {divide by zero}} {divide by zero}
|
||||
.CE
|
||||
.SH "SEE ALSO"
|
||||
catch(n), error(n), return(n), tclvars(n), try(n)
|
||||
catch(n), error(n), errorCode(n), errorInfo(n), return(n), try(n)
|
||||
.SH "KEYWORDS"
|
||||
error, exception
|
||||
'\" Local Variables:
|
||||
|
||||
+1
-1
@@ -824,7 +824,7 @@ duptraverse(
|
||||
* make all normal tests (not reg-33.14) pass.
|
||||
*/
|
||||
#ifndef DUPTRAVERSE_MAX_DEPTH
|
||||
#define DUPTRAVERSE_MAX_DEPTH 700
|
||||
#define DUPTRAVERSE_MAX_DEPTH 15000
|
||||
#endif
|
||||
|
||||
if (depth++ > DUPTRAVERSE_MAX_DEPTH) {
|
||||
|
||||
+1
-6
@@ -504,12 +504,7 @@ complicatedFindLoop(
|
||||
return er;
|
||||
}
|
||||
if ((shorter) ? end == estop : end == begin) {
|
||||
/*
|
||||
* No point in trying again.
|
||||
*/
|
||||
|
||||
*coldp = cold;
|
||||
return REG_NOMATCH;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+29
-11
@@ -930,6 +930,10 @@ TclCompileAssembleCmd(
|
||||
{
|
||||
Tcl_Token *tokenPtr; /* Token in the input script */
|
||||
|
||||
int numCommands = envPtr->numCommands;
|
||||
int offset = envPtr->codeNext - envPtr->codeStart;
|
||||
int depth = envPtr->currStackDepth;
|
||||
|
||||
/*
|
||||
* Make sure that the command has a single arg that is a simple word.
|
||||
*/
|
||||
@@ -943,10 +947,23 @@ TclCompileAssembleCmd(
|
||||
}
|
||||
|
||||
/*
|
||||
* Compile the code and return any error from the compilation.
|
||||
* Compile the code and convert any error from the compilation into
|
||||
* bytecode reporting the error;
|
||||
*/
|
||||
|
||||
return TclAssembleCode(envPtr, tokenPtr[1].start, tokenPtr[1].size, 0);
|
||||
if (TCL_ERROR == TclAssembleCode(envPtr, tokenPtr[1].start,
|
||||
tokenPtr[1].size, TCL_EVAL_DIRECT)) {
|
||||
|
||||
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
|
||||
"\n (\"%.*s\" body, line %d)",
|
||||
parsePtr->tokenPtr->size, parsePtr->tokenPtr->start,
|
||||
Tcl_GetErrorLine(interp)));
|
||||
envPtr->numCommands = numCommands;
|
||||
envPtr->codeNext = envPtr->codeStart + offset;
|
||||
envPtr->currStackDepth = depth;
|
||||
TclCompileSyntaxError(interp, envPtr);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -985,8 +1002,6 @@ TclAssembleCode(
|
||||
|
||||
const char* instPtr = codePtr;
|
||||
/* Where to start looking for a line of code */
|
||||
int instLen; /* Length in bytes of the current line of
|
||||
* code */
|
||||
const char* nextPtr; /* Pointer to the end of the line of code */
|
||||
int bytesLeft = codeLen; /* Number of bytes of source code remaining to
|
||||
* be parsed */
|
||||
@@ -1000,10 +1015,6 @@ TclAssembleCode(
|
||||
*/
|
||||
|
||||
status = Tcl_ParseCommand(interp, instPtr, bytesLeft, 0, parsePtr);
|
||||
instLen = parsePtr->commandSize;
|
||||
if (parsePtr->term == parsePtr->commandStart + instLen - 1) {
|
||||
--instLen;
|
||||
}
|
||||
|
||||
/*
|
||||
* Report errors in the parse.
|
||||
@@ -1012,7 +1023,7 @@ TclAssembleCode(
|
||||
if (status != TCL_OK) {
|
||||
if (flags & TCL_EVAL_DIRECT) {
|
||||
Tcl_LogCommandInfo(interp, codePtr, parsePtr->commandStart,
|
||||
instLen);
|
||||
parsePtr->term + 1 - parsePtr->commandStart);
|
||||
}
|
||||
FreeAssemblyEnv(assemEnvPtr);
|
||||
return TCL_ERROR;
|
||||
@@ -1032,6 +1043,13 @@ TclAssembleCode(
|
||||
*/
|
||||
|
||||
if (parsePtr->numWords > 0) {
|
||||
int instLen = parsePtr->commandSize;
|
||||
/* Length in bytes of the current command */
|
||||
|
||||
if (parsePtr->term == parsePtr->commandStart + instLen - 1) {
|
||||
--instLen;
|
||||
}
|
||||
|
||||
/*
|
||||
* If tracing, show each line assembled as it happens.
|
||||
*/
|
||||
@@ -1107,7 +1125,7 @@ NewAssemblyEnv(
|
||||
|
||||
assemEnvPtr->envPtr = envPtr;
|
||||
assemEnvPtr->parsePtr = parsePtr;
|
||||
assemEnvPtr->cmdLine = envPtr->line;
|
||||
assemEnvPtr->cmdLine = 1;
|
||||
assemEnvPtr->clNext = envPtr->clNext;
|
||||
|
||||
/*
|
||||
@@ -3029,7 +3047,7 @@ ResolveJumpTableTargets(
|
||||
auxDataIndex = TclGetInt4AtPtr(envPtr->codeStart + bbPtr->jumpOffset + 1);
|
||||
DEBUG_PRINT("bbPtr = %p jumpOffset = %d auxDataIndex = %d\n",
|
||||
bbPtr, bbPtr->jumpOffset, auxDataIndex);
|
||||
realJumpTablePtr = envPtr->auxDataArrayPtr[auxDataIndex].clientData;
|
||||
realJumpTablePtr = TclFetchAuxData(envPtr, auxDataIndex);
|
||||
realJumpHashPtr = &realJumpTablePtr->hashTable;
|
||||
|
||||
/*
|
||||
|
||||
+197
-383
@@ -127,15 +127,12 @@ static Tcl_ObjCmdProc ExprSqrtFunc;
|
||||
static Tcl_ObjCmdProc ExprSrandFunc;
|
||||
static Tcl_ObjCmdProc ExprUnaryFunc;
|
||||
static Tcl_ObjCmdProc ExprWideFunc;
|
||||
static Tcl_Obj * GetCommandSource(Interp *iPtr, int objc,
|
||||
Tcl_Obj *const objv[], int lookup);
|
||||
static void MathFuncWrongNumArgs(Tcl_Interp *interp, int expected,
|
||||
int actual, Tcl_Obj *const *objv);
|
||||
static Tcl_NRPostProc NRCoroutineCallerCallback;
|
||||
static Tcl_NRPostProc NRCoroutineExitCallback;
|
||||
static int NRCommand(ClientData data[], Tcl_Interp *interp, int result);
|
||||
|
||||
static Tcl_NRPostProc NRRunObjProc;
|
||||
static Tcl_ObjCmdProc OldMathFuncProc;
|
||||
static void OldMathFuncDeleteProc(ClientData clientData);
|
||||
static void ProcessUnexpectedResult(Tcl_Interp *interp,
|
||||
@@ -149,7 +146,7 @@ static inline Command * TEOV_LookupCmdFromObj(Tcl_Interp *interp,
|
||||
static int TEOV_NotFound(Tcl_Interp *interp, int objc,
|
||||
Tcl_Obj *const objv[], Namespace *lookupNsPtr);
|
||||
static int TEOV_RunEnterTraces(Tcl_Interp *interp,
|
||||
Command **cmdPtrPtr, int objc,
|
||||
Command **cmdPtrPtr, Tcl_Obj *commandPtr, int objc,
|
||||
Tcl_Obj *const objv[], Namespace *lookupNsPtr);
|
||||
static Tcl_NRPostProc RewindCoroutineCallback;
|
||||
static Tcl_NRPostProc TailcallCleanup;
|
||||
@@ -160,6 +157,8 @@ static Tcl_NRPostProc TEOV_Exception;
|
||||
static Tcl_NRPostProc TEOV_NotFoundCallback;
|
||||
static Tcl_NRPostProc TEOV_RestoreVarFrame;
|
||||
static Tcl_NRPostProc TEOV_RunLeaveTraces;
|
||||
static Tcl_NRPostProc EvalObjvCore;
|
||||
static Tcl_NRPostProc Dispatch;
|
||||
|
||||
static Tcl_ObjCmdProc NRCoroInjectObjCmd;
|
||||
|
||||
@@ -1609,8 +1608,6 @@ DeleteInterpProc(
|
||||
ckfree(eclPtr->loc);
|
||||
}
|
||||
|
||||
Tcl_DeleteHashTable(&eclPtr->litInfo);
|
||||
|
||||
ckfree(eclPtr);
|
||||
Tcl_DeleteHashEntry(hPtr);
|
||||
}
|
||||
@@ -2176,12 +2173,8 @@ Tcl_CreateCommand(
|
||||
* future calls to Tcl_GetCommandName.
|
||||
*
|
||||
* Side effects:
|
||||
* If no command named "cmdName" already exists for interp, one is
|
||||
* created. Otherwise, if a command does exist, then if the object-based
|
||||
* Tcl_ObjCmdProc is TclInvokeStringCommand, we assume Tcl_CreateCommand
|
||||
* was called previously for the same command and just set its
|
||||
* Tcl_ObjCmdProc to the argument "proc"; otherwise, we delete the old
|
||||
* command.
|
||||
* If a command named "cmdName" already exists for interp, it is
|
||||
* first deleted. Then the new command is created from the arguments.
|
||||
*
|
||||
* In the future, during bytecode evaluation when "cmdName" is seen as
|
||||
* the name of a command by Tcl_EvalObj or Tcl_Eval, the object-based
|
||||
@@ -2249,21 +2242,7 @@ Tcl_CreateObjCommand(
|
||||
cmdPtr = Tcl_GetHashValue(hPtr);
|
||||
|
||||
/*
|
||||
* Command already exists. If its object-based Tcl_ObjCmdProc is
|
||||
* TclInvokeStringCommand, we just set its Tcl_ObjCmdProc to the
|
||||
* argument "proc". Otherwise, we delete the old command.
|
||||
*/
|
||||
|
||||
if (cmdPtr->objProc == TclInvokeStringCommand) {
|
||||
cmdPtr->objProc = proc;
|
||||
cmdPtr->objClientData = clientData;
|
||||
cmdPtr->deleteProc = deleteProc;
|
||||
cmdPtr->deleteData = clientData;
|
||||
return (Tcl_Command) cmdPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise, we delete the old command. Be careful to preserve any
|
||||
* Command already exists; delete it. Be careful to preserve any
|
||||
* existing import links so we can restore them down below. That way,
|
||||
* you can redefine a command and its import status will remain
|
||||
* intact.
|
||||
@@ -2411,8 +2390,8 @@ TclInvokeStringCommand(
|
||||
* A standard Tcl string result value.
|
||||
*
|
||||
* Side effects:
|
||||
* Besides those side effects of the called Tcl_CmdProc,
|
||||
* TclInvokeStringCommand allocates and frees storage.
|
||||
* Besides those side effects of the called Tcl_ObjCmdProc,
|
||||
* TclInvokeObjectCommand allocates and frees storage.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
@@ -3352,66 +3331,6 @@ CancelEvalProc(
|
||||
return code;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* GetCommandSource --
|
||||
*
|
||||
* This function returns a Tcl_Obj with the full source string for the
|
||||
* command. This insures that traces get a correct NUL-terminated command
|
||||
* string. The Tcl_Obj has refCount==1.
|
||||
*
|
||||
* *** MAINTAINER WARNING ***
|
||||
* The returned Tcl_Obj is all wrong for any purpose but getting the
|
||||
* source string for an objc/objv command line in the stringRep (no
|
||||
* stringRep if no source is available) and the corresponding substituted
|
||||
* version in the List intrep.
|
||||
* This means that the intRep and stringRep DO NOT COINCIDE! Using these
|
||||
* Tcl_Objs normally is likely to break things.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static Tcl_Obj *
|
||||
GetCommandSource(
|
||||
Interp *iPtr,
|
||||
int objc,
|
||||
Tcl_Obj *const objv[],
|
||||
int lookup)
|
||||
{
|
||||
Tcl_Obj *objPtr, *obj2Ptr;
|
||||
CmdFrame *cfPtr = iPtr->cmdFramePtr;
|
||||
const char *command = NULL;
|
||||
int numChars;
|
||||
|
||||
objPtr = Tcl_NewListObj(objc, objv);
|
||||
if (lookup && cfPtr && (cfPtr->numLevels == iPtr->numLevels-1)) {
|
||||
switch (cfPtr->type) {
|
||||
case TCL_LOCATION_EVAL:
|
||||
case TCL_LOCATION_SOURCE:
|
||||
command = cfPtr->cmd.str.cmd;
|
||||
numChars = cfPtr->cmd.str.len;
|
||||
break;
|
||||
case TCL_LOCATION_BC:
|
||||
case TCL_LOCATION_PREBC:
|
||||
command = TclGetSrcInfoForCmd(iPtr, &numChars);
|
||||
break;
|
||||
case TCL_LOCATION_EVAL_LIST:
|
||||
/* Got it already */
|
||||
break;
|
||||
}
|
||||
if (command) {
|
||||
obj2Ptr = Tcl_NewStringObj(command, numChars);
|
||||
objPtr->bytes = obj2Ptr->bytes;
|
||||
objPtr->length = numChars;
|
||||
obj2Ptr->bytes = NULL;
|
||||
Tcl_DecrRefCount(obj2Ptr);
|
||||
}
|
||||
}
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
return objPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
@@ -4175,39 +4094,52 @@ TclNREvalObjv(
|
||||
* requested Command struct to be invoked. */
|
||||
{
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
int result;
|
||||
Namespace *lookupNsPtr = iPtr->lookupNsPtr;
|
||||
Command **cmdPtrPtr;
|
||||
NRE_callback *callbackPtr;
|
||||
|
||||
iPtr->lookupNsPtr = NULL;
|
||||
|
||||
/*
|
||||
* Push a callback with cleanup tasks for commands; the cmdPtr at data[0]
|
||||
* will be filled later when the command is found: save its address at
|
||||
* objProcPtr.
|
||||
*
|
||||
* data[1] stores a marker for use by tailcalls; it will be set to 1 by
|
||||
* command redirectors (imports, alias, ensembles) so that tailcalls
|
||||
* finishes the source command and not just the target.
|
||||
*/
|
||||
|
||||
if (iPtr->deferredCallbacks) {
|
||||
callbackPtr = iPtr->deferredCallbacks;
|
||||
iPtr->deferredCallbacks = NULL;
|
||||
} else {
|
||||
TclNRAddCallback(interp, NRCommand, NULL, NULL, NULL, NULL);
|
||||
callbackPtr = TOP_CB(interp);
|
||||
}
|
||||
cmdPtrPtr = (Command **) &(callbackPtr->data[0]);
|
||||
|
||||
iPtr->numLevels++;
|
||||
result = TclInterpReady(interp);
|
||||
TclNRAddCallback(interp, EvalObjvCore, cmdPtr, INT2PTR(flags),
|
||||
INT2PTR(objc), objv);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
if ((result != TCL_OK) || (objc == 0)) {
|
||||
return result;
|
||||
static int
|
||||
EvalObjvCore(
|
||||
ClientData data[],
|
||||
Tcl_Interp *interp,
|
||||
int result)
|
||||
{
|
||||
Command *cmdPtr = data[0];
|
||||
int flags = PTR2INT(data[1]);
|
||||
int objc = PTR2INT(data[2]);
|
||||
Tcl_Obj **objv = data[3];
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
Namespace *lookupNsPtr = iPtr->lookupNsPtr;
|
||||
|
||||
if (TCL_OK != TclInterpReady(interp)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (objc == 0) {
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
if (TclLimitExceeded(iPtr->limit)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
iPtr->lookupNsPtr = NULL;
|
||||
|
||||
if (cmdPtr) {
|
||||
goto commandFound;
|
||||
}
|
||||
@@ -4251,11 +4183,6 @@ TclNREvalObjv(
|
||||
return TEOV_NotFound(interp, objc, objv, lookupNsPtr);
|
||||
}
|
||||
|
||||
iPtr->cmdCount++;
|
||||
if (TclLimitExceeded(iPtr->limit)) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Found a command! The real work begins now ...
|
||||
*/
|
||||
@@ -4267,15 +4194,34 @@ TclNREvalObjv(
|
||||
* necessary.
|
||||
*/
|
||||
|
||||
result = TEOV_RunEnterTraces(interp, &cmdPtr, objc, objv, lookupNsPtr);
|
||||
if (!cmdPtr) {
|
||||
return TEOV_NotFound(interp, objc, objv, lookupNsPtr);
|
||||
}
|
||||
result = TEOV_RunEnterTraces(interp, &cmdPtr, TclGetSourceFromFrame(
|
||||
flags & TCL_EVAL_SOURCE_IN_FRAME ? iPtr->cmdFramePtr : NULL,
|
||||
objc, objv), objc, objv, lookupNsPtr);
|
||||
if (result != TCL_OK) {
|
||||
return result;
|
||||
}
|
||||
if (!cmdPtr) {
|
||||
return TEOV_NotFound(interp, objc, objv, lookupNsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
TclNRAddCallback(interp, Dispatch,
|
||||
cmdPtr->nreProc ? cmdPtr->nreProc : cmdPtr->objProc,
|
||||
cmdPtr->objClientData, INT2PTR(objc), objv);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
Dispatch(
|
||||
ClientData data[],
|
||||
Tcl_Interp *interp,
|
||||
int result)
|
||||
{
|
||||
Tcl_ObjCmdProc *objProc = data[0];
|
||||
ClientData clientData = data[1];
|
||||
int objc = PTR2INT(data[2]);
|
||||
Tcl_Obj **objv = data[3];
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
|
||||
#ifdef USE_DTRACE
|
||||
if (TCL_DTRACE_CMD_ARGS_ENABLED()) {
|
||||
@@ -4296,34 +4242,18 @@ TclNREvalObjv(
|
||||
TCL_DTRACE_CMD_INFO(a[0], a[1], a[2], a[3], i[0], i[1], a[4], a[5]);
|
||||
TclDecrRefCount(info);
|
||||
}
|
||||
if (TCL_DTRACE_CMD_RETURN_ENABLED() || TCL_DTRACE_CMD_RESULT_ENABLED()) {
|
||||
if ((TCL_DTRACE_CMD_RETURN_ENABLED() || TCL_DTRACE_CMD_RESULT_ENABLED())
|
||||
&& objc) {
|
||||
TclNRAddCallback(interp, DTraceCmdReturn, objv[0], NULL, NULL, NULL);
|
||||
}
|
||||
if (TCL_DTRACE_CMD_ENTRY_ENABLED()) {
|
||||
if (TCL_DTRACE_CMD_ENTRY_ENABLED() && objc) {
|
||||
TCL_DTRACE_CMD_ENTRY(TclGetString(objv[0]), objc - 1,
|
||||
(Tcl_Obj **)(objv + 1));
|
||||
}
|
||||
#endif /* USE_DTRACE */
|
||||
/*
|
||||
* Fix the original callback to point to the now known cmdPtr. Insure that
|
||||
* the Command struct lives until the command returns.
|
||||
*/
|
||||
|
||||
*cmdPtrPtr = cmdPtr;
|
||||
cmdPtr->refCount++;
|
||||
|
||||
/*
|
||||
* Find the objProc to call: nreProc if available, objProc otherwise. Push
|
||||
* a callback to do the actual running.
|
||||
*/
|
||||
|
||||
if (cmdPtr->nreProc) {
|
||||
TclNRAddCallback(interp, NRRunObjProc, cmdPtr,
|
||||
INT2PTR(objc), (ClientData) objv, NULL);
|
||||
return TCL_OK;
|
||||
} else {
|
||||
return cmdPtr->objProc(cmdPtr->objClientData, interp, objc, objv);
|
||||
}
|
||||
iPtr->cmdCount++;
|
||||
return objProc(clientData, interp, objc, objv);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -4352,6 +4282,7 @@ TclNRRunCallbacks(
|
||||
(void) Tcl_GetObjResult(interp);
|
||||
}
|
||||
|
||||
iPtr->execEnvPtr->stackLevel++;
|
||||
while (TOP_CB(interp) != rootPtr) {
|
||||
callbackPtr = TOP_CB(interp);
|
||||
procPtr = callbackPtr->procPtr;
|
||||
@@ -4359,6 +4290,7 @@ TclNRRunCallbacks(
|
||||
result = procPtr(callbackPtr->data, interp, result);
|
||||
TCLNR_FREE(interp, callbackPtr);
|
||||
}
|
||||
iPtr->execEnvPtr->stackLevel--;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -4369,13 +4301,8 @@ NRCommand(
|
||||
int result)
|
||||
{
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
Command *cmdPtr = data[0];
|
||||
/* int cmdStart = PTR2INT(data[1]); NOT USED HERE */
|
||||
|
||||
if (cmdPtr) {
|
||||
TclCleanupCommandMacro(cmdPtr);
|
||||
}
|
||||
((Interp *)interp)->numLevels--;
|
||||
iPtr->numLevels--;
|
||||
|
||||
/*
|
||||
* If there is a tailcall, schedule it
|
||||
@@ -4402,22 +4329,6 @@ NRCommand(
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
NRRunObjProc(
|
||||
ClientData data[],
|
||||
Tcl_Interp *interp,
|
||||
int result)
|
||||
{
|
||||
/* OPT: do not call? */
|
||||
|
||||
Command* cmdPtr = data[0];
|
||||
int objc = PTR2INT(data[1]);
|
||||
Tcl_Obj **objv = data[2];
|
||||
|
||||
return cmdPtr->nreProc(cmdPtr->objClientData, interp, objc, objv);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -4681,6 +4592,7 @@ static int
|
||||
TEOV_RunEnterTraces(
|
||||
Tcl_Interp *interp,
|
||||
Command **cmdPtrPtr,
|
||||
Tcl_Obj *commandPtr,
|
||||
int objc,
|
||||
Tcl_Obj *const objv[],
|
||||
Namespace *lookupNsPtr)
|
||||
@@ -4692,9 +4604,8 @@ TEOV_RunEnterTraces(
|
||||
int newEpoch;
|
||||
const char *command;
|
||||
int length;
|
||||
Tcl_Obj *commandPtr;
|
||||
|
||||
commandPtr = GetCommandSource(iPtr, objc, objv, 1);
|
||||
Tcl_IncrRefCount(commandPtr);
|
||||
command = Tcl_GetStringFromObj(commandPtr, &length);
|
||||
|
||||
/*
|
||||
@@ -4727,13 +4638,13 @@ TEOV_RunEnterTraces(
|
||||
*cmdPtrPtr = cmdPtr;
|
||||
}
|
||||
|
||||
if (cmdPtr) {
|
||||
if (cmdPtr && (traceCode == TCL_OK)) {
|
||||
/*
|
||||
* Command was found: push a record to schedule the leave traces.
|
||||
*/
|
||||
|
||||
TclNRAddCallback(interp, TEOV_RunLeaveTraces, INT2PTR(traceCode),
|
||||
commandPtr, cmdPtr, NULL);
|
||||
TclNRAddCallback(interp, TEOV_RunLeaveTraces, INT2PTR(objc),
|
||||
commandPtr, cmdPtr, objv);
|
||||
cmdPtr->refCount++;
|
||||
} else {
|
||||
Tcl_DecrRefCount(commandPtr);
|
||||
@@ -4748,20 +4659,18 @@ TEOV_RunLeaveTraces(
|
||||
int result)
|
||||
{
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
const char *command;
|
||||
int length, objc;
|
||||
Tcl_Obj **objv;
|
||||
int traceCode = PTR2INT(data[0]);
|
||||
int traceCode = TCL_OK;
|
||||
int objc = PTR2INT(data[0]);
|
||||
Tcl_Obj *commandPtr = data[1];
|
||||
Command *cmdPtr = data[2];
|
||||
Tcl_Obj **objv = data[3];
|
||||
|
||||
command = Tcl_GetStringFromObj(commandPtr, &length);
|
||||
if (TCL_OK != Tcl_ListObjGetElements(interp, commandPtr, &objc, &objv)) {
|
||||
Tcl_Panic("Who messed with commandPtr?");
|
||||
}
|
||||
|
||||
if (!(cmdPtr->flags & CMD_IS_DELETED)) {
|
||||
if ((cmdPtr->flags & CMD_HAS_EXEC_TRACES) && traceCode == TCL_OK){
|
||||
int length;
|
||||
const char *command = Tcl_GetStringFromObj(commandPtr, &length);
|
||||
|
||||
if (cmdPtr->flags & CMD_HAS_EXEC_TRACES){
|
||||
traceCode = TclCheckExecutionTraces(interp, command, length,
|
||||
cmdPtr, result, TCL_TRACE_LEAVE_EXEC, objc, objv);
|
||||
}
|
||||
@@ -5017,31 +4926,22 @@ TclEvalEx(
|
||||
/*
|
||||
* TIP #280 Initialize tracking. Do not push on the frame stack yet.
|
||||
*
|
||||
* We may continue counting based on a specific context (CTX), or open a
|
||||
* new context, either for a sourced script, or 'eval'. For sourced files
|
||||
* we always have a path object, even if nothing was specified in the
|
||||
* interp itself. That makes code using it simpler as NULL checks can be
|
||||
* left out. Sourced file without path in the 'scriptFile' is possible
|
||||
* during Tcl initialization.
|
||||
* We open a new context, either for a sourced script, or 'eval'.
|
||||
* For sourced files we always have a path object, even if nothing was
|
||||
* specified in the interp itself. That makes code using it simpler as
|
||||
* NULL checks can be left out. Sourced file without path in the
|
||||
* 'scriptFile' is possible during Tcl initialization.
|
||||
*/
|
||||
|
||||
eeFramePtr->level = iPtr->cmdFramePtr ? iPtr->cmdFramePtr->level + 1 : 1;
|
||||
eeFramePtr->numLevels = iPtr->numLevels;
|
||||
eeFramePtr->framePtr = iPtr->framePtr;
|
||||
eeFramePtr->nextPtr = iPtr->cmdFramePtr;
|
||||
eeFramePtr->nline = 0;
|
||||
eeFramePtr->line = NULL;
|
||||
eeFramePtr->cmdObj = NULL;
|
||||
|
||||
iPtr->cmdFramePtr = eeFramePtr;
|
||||
if (iPtr->evalFlags & TCL_EVAL_CTX) {
|
||||
/*
|
||||
* Path information comes out of the context.
|
||||
*/
|
||||
|
||||
eeFramePtr->type = TCL_LOCATION_SOURCE;
|
||||
eeFramePtr->data.eval.path = iPtr->invokeCmdFramePtr->data.eval.path;
|
||||
Tcl_IncrRefCount(eeFramePtr->data.eval.path);
|
||||
} else if (iPtr->evalFlags & TCL_EVAL_FILE) {
|
||||
if (iPtr->evalFlags & TCL_EVAL_FILE) {
|
||||
/*
|
||||
* Set up for a sourced file.
|
||||
*/
|
||||
@@ -5084,7 +4984,9 @@ TclEvalEx(
|
||||
do {
|
||||
if (Tcl_ParseCommand(interp, p, bytesLeft, 0, parsePtr) != TCL_OK) {
|
||||
code = TCL_ERROR;
|
||||
goto error;
|
||||
Tcl_LogCommandInfo(interp, script, parsePtr->commandStart,
|
||||
parsePtr->term + 1 - parsePtr->commandStart);
|
||||
goto posterror;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5250,23 +5152,28 @@ TclEvalEx(
|
||||
* have been executed.
|
||||
*/
|
||||
|
||||
eeFramePtr->cmd.str.cmd = parsePtr->commandStart;
|
||||
eeFramePtr->cmd.str.len = parsePtr->commandSize;
|
||||
eeFramePtr->cmd = parsePtr->commandStart;
|
||||
eeFramePtr->len = parsePtr->commandSize;
|
||||
|
||||
if (parsePtr->term ==
|
||||
parsePtr->commandStart + parsePtr->commandSize - 1) {
|
||||
eeFramePtr->cmd.str.len--;
|
||||
eeFramePtr->len--;
|
||||
}
|
||||
|
||||
eeFramePtr->nline = objectsUsed;
|
||||
eeFramePtr->line = lines;
|
||||
|
||||
TclArgumentEnter(interp, objv, objectsUsed, eeFramePtr);
|
||||
code = Tcl_EvalObjv(interp, objectsUsed, objv, TCL_EVAL_NOERR);
|
||||
code = Tcl_EvalObjv(interp, objectsUsed, objv,
|
||||
TCL_EVAL_NOERR | TCL_EVAL_SOURCE_IN_FRAME);
|
||||
TclArgumentRelease(interp, objv, objectsUsed);
|
||||
|
||||
eeFramePtr->line = NULL;
|
||||
eeFramePtr->nline = 0;
|
||||
if (eeFramePtr->cmdObj) {
|
||||
Tcl_DecrRefCount(eeFramePtr->cmdObj);
|
||||
eeFramePtr->cmdObj = NULL;
|
||||
}
|
||||
|
||||
if (code != TCL_OK) {
|
||||
goto error;
|
||||
@@ -5340,6 +5247,7 @@ TclEvalEx(
|
||||
Tcl_LogCommandInfo(interp, script, parsePtr->commandStart,
|
||||
commandLength);
|
||||
}
|
||||
posterror:
|
||||
iPtr->flags &= ~ERR_ALREADY_LOGGED;
|
||||
|
||||
/*
|
||||
@@ -5614,76 +5522,88 @@ TclArgumentBCEnter(
|
||||
int objc,
|
||||
void *codePtr,
|
||||
CmdFrame *cfPtr,
|
||||
int cmd,
|
||||
int pc)
|
||||
{
|
||||
ExtCmdLoc *eclPtr;
|
||||
int word;
|
||||
ECL *ePtr;
|
||||
CFWordBC *lastPtr = NULL;
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
Tcl_HashEntry *hePtr =
|
||||
Tcl_FindHashEntry(iPtr->lineBCPtr, (char *) codePtr);
|
||||
ExtCmdLoc *eclPtr;
|
||||
|
||||
if (!hePtr) {
|
||||
return;
|
||||
}
|
||||
eclPtr = Tcl_GetHashValue(hePtr);
|
||||
hePtr = Tcl_FindHashEntry(&eclPtr->litInfo, INT2PTR(pc));
|
||||
if (hePtr) {
|
||||
int word;
|
||||
int cmd = PTR2INT(Tcl_GetHashValue(hePtr));
|
||||
ECL *ePtr = &eclPtr->loc[cmd];
|
||||
CFWordBC *lastPtr = NULL;
|
||||
ePtr = &eclPtr->loc[cmd];
|
||||
|
||||
/*
|
||||
* A few truths ...
|
||||
* (1) ePtr->nline == objc
|
||||
* (2) (ePtr->line[word] < 0) => !literal, for all words
|
||||
* (3) (word == 0) => !literal
|
||||
*
|
||||
* Item (2) is why we can use objv to get the literals, and do not
|
||||
* have to save them at compile time.
|
||||
*/
|
||||
/*
|
||||
* ePtr->nline is the number of words originally parsed.
|
||||
*
|
||||
* objc is the number of elements getting invoked.
|
||||
*
|
||||
* If they are not the same, we arrived here by compiling an
|
||||
* ensemble dispatch. Ensemble subcommands that lead to script
|
||||
* evaluation are not supposed to get compiled, because a command
|
||||
* such as [info level] in the script can expose some of the dispatch
|
||||
* shenanigans. This means that we don't have to tend to the
|
||||
* housekeeping, and can escape now.
|
||||
*/
|
||||
|
||||
if (ePtr->nline != objc) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ePtr->nline != objc) {
|
||||
Tcl_Panic ("TIP 280 data structure inconsistency");
|
||||
}
|
||||
/*
|
||||
* Having disposed of the ensemble cases, we can state...
|
||||
* A few truths ...
|
||||
* (1) ePtr->nline == objc
|
||||
* (2) (ePtr->line[word] < 0) => !literal, for all words
|
||||
* (3) (word == 0) => !literal
|
||||
*
|
||||
* Item (2) is why we can use objv to get the literals, and do not
|
||||
* have to save them at compile time.
|
||||
*/
|
||||
|
||||
for (word = 1; word < objc; word++) {
|
||||
if (ePtr->line[word] >= 0) {
|
||||
int isnew;
|
||||
Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(iPtr->lineLABCPtr,
|
||||
objv[word], &isnew);
|
||||
CFWordBC *cfwPtr = ckalloc(sizeof(CFWordBC));
|
||||
for (word = 1; word < objc; word++) {
|
||||
if (ePtr->line[word] >= 0) {
|
||||
int isnew;
|
||||
Tcl_HashEntry *hPtr = Tcl_CreateHashEntry(iPtr->lineLABCPtr,
|
||||
objv[word], &isnew);
|
||||
CFWordBC *cfwPtr = ckalloc(sizeof(CFWordBC));
|
||||
|
||||
cfwPtr->framePtr = cfPtr;
|
||||
cfwPtr->obj = objv[word];
|
||||
cfwPtr->pc = pc;
|
||||
cfwPtr->word = word;
|
||||
cfwPtr->nextPtr = lastPtr;
|
||||
lastPtr = cfwPtr;
|
||||
cfwPtr->framePtr = cfPtr;
|
||||
cfwPtr->obj = objv[word];
|
||||
cfwPtr->pc = pc;
|
||||
cfwPtr->word = word;
|
||||
cfwPtr->nextPtr = lastPtr;
|
||||
lastPtr = cfwPtr;
|
||||
|
||||
if (isnew) {
|
||||
/*
|
||||
* The word is not on the stack yet, remember the current
|
||||
* location and initialize references.
|
||||
*/
|
||||
if (isnew) {
|
||||
/*
|
||||
* The word is not on the stack yet, remember the current
|
||||
* location and initialize references.
|
||||
*/
|
||||
|
||||
cfwPtr->prevPtr = NULL;
|
||||
} else {
|
||||
/*
|
||||
* The object is already on the stack, however it may have
|
||||
* a different location now (literal sharing may map
|
||||
* multiple location to a single Tcl_Obj*. Save the old
|
||||
* information in the new structure.
|
||||
*/
|
||||
cfwPtr->prevPtr = NULL;
|
||||
} else {
|
||||
/*
|
||||
* The object is already on the stack, however it may have
|
||||
* a different location now (literal sharing may map
|
||||
* multiple location to a single Tcl_Obj*. Save the old
|
||||
* information in the new structure.
|
||||
*/
|
||||
|
||||
cfwPtr->prevPtr = Tcl_GetHashValue(hPtr);
|
||||
}
|
||||
|
||||
Tcl_SetHashValue(hPtr, cfwPtr);
|
||||
cfwPtr->prevPtr = Tcl_GetHashValue(hPtr);
|
||||
}
|
||||
} /* for */
|
||||
|
||||
cfPtr->litarg = lastPtr;
|
||||
} /* if */
|
||||
Tcl_SetHashValue(hPtr, cfwPtr);
|
||||
}
|
||||
} /* for */
|
||||
|
||||
cfPtr->litarg = lastPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5893,6 +5813,11 @@ Tcl_GlobalEvalObj(
|
||||
* compiled into bytecodes if necessary, unless TCL_EVAL_DIRECT is
|
||||
* specified.
|
||||
*
|
||||
* If the flag TCL_EVAL_DIRECT is passed in, the value of invoker
|
||||
* must be NULL. Support for non-NULL invokers in that mode has
|
||||
* been removed since it was unused and untested. Failure to
|
||||
* follow this limitation will lead to an assertion panic.
|
||||
*
|
||||
* Results:
|
||||
* The return value is one of the return codes defined in tcl.h (such as
|
||||
* TCL_OK), and the interpreter's result contains a value to supplement
|
||||
@@ -5961,13 +5886,12 @@ TclNREvalObjEx(
|
||||
*/
|
||||
|
||||
if (TclListObjIsCanonical(objPtr)) {
|
||||
Tcl_Obj *listPtr = objPtr;
|
||||
CmdFrame *eoFramePtr = NULL;
|
||||
int objc;
|
||||
Tcl_Obj **objv;
|
||||
Tcl_Obj *listPtr, **objv;
|
||||
|
||||
/*
|
||||
* Pure List Optimization (no string representation). In this case, we
|
||||
* Canonical List Optimization: In this case, we
|
||||
* can safely use Tcl_EvalObjv instead and get an appreciable
|
||||
* improvement in execution speed. This is because it allows us to
|
||||
* avoid a setFromAny step that would just pack everything into a
|
||||
@@ -5975,11 +5899,6 @@ TclNREvalObjEx(
|
||||
*
|
||||
* This also preserves any associations between list elements and
|
||||
* location information for such elements.
|
||||
*
|
||||
* This restriction has been relaxed a bit by storing in lists whether
|
||||
* they are "canonical" or not (a canonical list being one that is
|
||||
* either pure or that has its string rep derived by
|
||||
* UpdateStringOfList from the internal rep).
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -5988,13 +5907,13 @@ TclNREvalObjEx(
|
||||
* we always make a copy. The callback takes care od the refCounts for
|
||||
* both listPtr and objPtr.
|
||||
*
|
||||
* TODO: Create a test to demo this need, or eliminate it.
|
||||
* FIXME OPT: preserve just the internal rep?
|
||||
*/
|
||||
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
listPtr = TclListObjCopy(interp, objPtr);
|
||||
Tcl_IncrRefCount(listPtr);
|
||||
TclDecrRefCount(objPtr);
|
||||
|
||||
if (word != INT_MIN) {
|
||||
/*
|
||||
@@ -6017,22 +5936,25 @@ TclNREvalObjEx(
|
||||
eoFramePtr->nline = 0;
|
||||
eoFramePtr->line = NULL;
|
||||
|
||||
eoFramePtr->type = TCL_LOCATION_EVAL_LIST;
|
||||
eoFramePtr->type = TCL_LOCATION_EVAL;
|
||||
eoFramePtr->level = (iPtr->cmdFramePtr == NULL?
|
||||
1 : iPtr->cmdFramePtr->level + 1);
|
||||
eoFramePtr->numLevels = iPtr->numLevels;
|
||||
eoFramePtr->framePtr = iPtr->framePtr;
|
||||
eoFramePtr->nextPtr = iPtr->cmdFramePtr;
|
||||
|
||||
eoFramePtr->cmd.listPtr = listPtr;
|
||||
eoFramePtr->cmdObj = objPtr;
|
||||
eoFramePtr->cmd = NULL;
|
||||
eoFramePtr->len = 0;
|
||||
eoFramePtr->data.eval.path = NULL;
|
||||
|
||||
iPtr->cmdFramePtr = eoFramePtr;
|
||||
|
||||
flags |= TCL_EVAL_SOURCE_IN_FRAME;
|
||||
}
|
||||
|
||||
TclMarkTailcall(interp);
|
||||
TclNRAddCallback(interp, TEOEx_ListCallback, listPtr, eoFramePtr,
|
||||
NULL, NULL);
|
||||
objPtr, NULL);
|
||||
|
||||
ListObjGetElements(listPtr, objc, objv);
|
||||
return TclNREvalObjv(interp, objc, objv, flags, NULL);
|
||||
@@ -6072,14 +5994,6 @@ TclNREvalObjEx(
|
||||
* We're not supposed to use the compiler or byte-code
|
||||
* interpreter. Let Tcl_EvalEx evaluate the command directly (and
|
||||
* probably more slowly).
|
||||
*
|
||||
* TIP #280. Propagate context as much as we can. Especially if the
|
||||
* script to evaluate is a single literal it makes sense to look if
|
||||
* our context is one with absolute line numbers we can then track
|
||||
* into the literal itself too.
|
||||
*
|
||||
* See also tclCompile.c, TclInitCompileEnv, for the equivalent code
|
||||
* in the bytecode compiler.
|
||||
*/
|
||||
|
||||
const char *script;
|
||||
@@ -6103,92 +6017,19 @@ TclNREvalObjEx(
|
||||
*/
|
||||
|
||||
ContLineLoc *saveCLLocPtr = iPtr->scriptCLLocPtr;
|
||||
ContLineLoc *clLocPtr = TclContinuationsGet(objPtr);
|
||||
|
||||
if (clLocPtr) {
|
||||
iPtr->scriptCLLocPtr = clLocPtr;
|
||||
Tcl_Preserve(iPtr->scriptCLLocPtr);
|
||||
} else {
|
||||
iPtr->scriptCLLocPtr = NULL;
|
||||
}
|
||||
assert(invoker == NULL);
|
||||
|
||||
iPtr->scriptCLLocPtr = TclContinuationsGet(objPtr);
|
||||
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
if (invoker == NULL) {
|
||||
/*
|
||||
* No context, force opening of our own.
|
||||
*/
|
||||
|
||||
script = Tcl_GetStringFromObj(objPtr, &numSrcBytes);
|
||||
result = Tcl_EvalEx(interp, script, numSrcBytes, flags);
|
||||
} else {
|
||||
/*
|
||||
* We have an invoker, describing the command asking for the
|
||||
* evaluation of a subordinate script. This script may originate
|
||||
* in a literal word, or from a variable, etc. Using the line
|
||||
* array we now check if we have good line information for the
|
||||
* relevant word. The type of context is relevant as well. In a
|
||||
* non-'source' context we don't have to try tracking lines.
|
||||
*
|
||||
* First see if the word exists and is a literal. If not we go
|
||||
* through the easy dynamic branch. No need to perform more
|
||||
* complex invokations.
|
||||
*/
|
||||
script = Tcl_GetStringFromObj(objPtr, &numSrcBytes);
|
||||
result = Tcl_EvalEx(interp, script, numSrcBytes, flags);
|
||||
|
||||
int pc = 0;
|
||||
CmdFrame *ctxPtr = TclStackAlloc(interp, sizeof(CmdFrame));
|
||||
|
||||
*ctxPtr = *invoker;
|
||||
if (invoker->type == TCL_LOCATION_BC) {
|
||||
/*
|
||||
* Note: Type BC => ctxPtr->data.eval.path is not used.
|
||||
* ctxPtr->data.tebc.codePtr is used instead.
|
||||
*/
|
||||
|
||||
TclGetSrcInfoForPc(ctxPtr);
|
||||
pc = 1;
|
||||
}
|
||||
|
||||
script = Tcl_GetStringFromObj(objPtr, &numSrcBytes);
|
||||
|
||||
if ((invoker->nline <= word) ||
|
||||
(invoker->line[word] < 0) ||
|
||||
(ctxPtr->type != TCL_LOCATION_SOURCE)) {
|
||||
/*
|
||||
* Dynamic script, or dynamic context, force our own context.
|
||||
*/
|
||||
|
||||
result = Tcl_EvalEx(interp, script, numSrcBytes, flags);
|
||||
} else {
|
||||
/*
|
||||
* Absolute context to reuse.
|
||||
*/
|
||||
|
||||
iPtr->invokeCmdFramePtr = ctxPtr;
|
||||
iPtr->evalFlags |= TCL_EVAL_CTX;
|
||||
|
||||
result = TclEvalEx(interp, script, numSrcBytes, flags,
|
||||
ctxPtr->line[word], NULL, script);
|
||||
}
|
||||
if (pc && (ctxPtr->type == TCL_LOCATION_SOURCE)) {
|
||||
/*
|
||||
* Death of SrcInfo reference.
|
||||
*/
|
||||
|
||||
Tcl_DecrRefCount(ctxPtr->data.eval.path);
|
||||
}
|
||||
TclStackFree(interp, ctxPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now release the lock on the continuation line information, if any,
|
||||
* and restore the caller's settings.
|
||||
*/
|
||||
|
||||
if (iPtr->scriptCLLocPtr) {
|
||||
Tcl_Release(iPtr->scriptCLLocPtr);
|
||||
}
|
||||
iPtr->scriptCLLocPtr = saveCLLocPtr;
|
||||
TclDecrRefCount(objPtr);
|
||||
|
||||
iPtr->scriptCLLocPtr = saveCLLocPtr;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -6248,6 +6089,7 @@ TEOEx_ListCallback(
|
||||
Interp *iPtr = (Interp *) interp;
|
||||
Tcl_Obj *listPtr = data[0];
|
||||
CmdFrame *eoFramePtr = data[1];
|
||||
Tcl_Obj *objPtr = data[2];
|
||||
|
||||
/*
|
||||
* Remove the cmdFrame
|
||||
@@ -6257,6 +6099,7 @@ TEOEx_ListCallback(
|
||||
iPtr->cmdFramePtr = eoFramePtr->nextPtr;
|
||||
TclStackFree(interp, eoFramePtr);
|
||||
}
|
||||
TclDecrRefCount(objPtr);
|
||||
TclDecrRefCount(listPtr);
|
||||
|
||||
return result;
|
||||
@@ -8138,39 +7981,11 @@ Tcl_NRCallObjProc(
|
||||
int objc,
|
||||
Tcl_Obj *const objv[])
|
||||
{
|
||||
int result = TCL_OK;
|
||||
NRE_callback *rootPtr = TOP_CB(interp);
|
||||
|
||||
#ifdef USE_DTRACE
|
||||
if (TCL_DTRACE_CMD_ARGS_ENABLED()) {
|
||||
const char *a[10];
|
||||
int i = 0;
|
||||
|
||||
while (i < 10) {
|
||||
a[i] = i < objc ? TclGetString(objv[i]) : NULL; i++;
|
||||
}
|
||||
TCL_DTRACE_CMD_ARGS(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7],
|
||||
a[8], a[9]);
|
||||
}
|
||||
if (TCL_DTRACE_CMD_INFO_ENABLED() && ((Interp *) interp)->cmdFramePtr) {
|
||||
Tcl_Obj *info = TclInfoFrame(interp, ((Interp *) interp)->cmdFramePtr);
|
||||
const char *a[6]; int i[2];
|
||||
|
||||
TclDTraceInfo(info, a, i);
|
||||
TCL_DTRACE_CMD_INFO(a[0], a[1], a[2], a[3], i[0], i[1], a[4], a[5]);
|
||||
TclDecrRefCount(info);
|
||||
}
|
||||
if ((TCL_DTRACE_CMD_RETURN_ENABLED() || TCL_DTRACE_CMD_RESULT_ENABLED())
|
||||
&& objc) {
|
||||
TclNRAddCallback(interp, DTraceCmdReturn, objv[0], NULL, NULL, NULL);
|
||||
}
|
||||
if (TCL_DTRACE_CMD_ENTRY_ENABLED() && objc) {
|
||||
TCL_DTRACE_CMD_ENTRY(TclGetString(objv[0]), objc - 1,
|
||||
(Tcl_Obj **)(objv + 1));
|
||||
}
|
||||
#endif /* USE_DTRACE */
|
||||
result = objProc(clientData, interp, objc, objv);
|
||||
return TclNRRunCallbacks(interp, result, rootPtr);
|
||||
TclNRAddCallback(interp, Dispatch, objProc, clientData,
|
||||
INT2PTR(objc), objv);
|
||||
return TclNRRunCallbacks(interp, TCL_OK, rootPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -8697,7 +8512,7 @@ NRCoroutineExitCallback(
|
||||
TclDeleteExecEnv(corPtr->eePtr);
|
||||
corPtr->eePtr = NULL;
|
||||
|
||||
corPtr->stackLevel = NULL;
|
||||
corPtr->stackLevel = -1;
|
||||
|
||||
/*
|
||||
* #280.
|
||||
@@ -8741,10 +8556,9 @@ TclNRCoroutineActivateCallback(
|
||||
{
|
||||
CoroutineData *corPtr = data[0];
|
||||
int type = PTR2INT(data[1]);
|
||||
int numLevels, unused;
|
||||
int *stackLevel = &unused;
|
||||
int numLevels;
|
||||
|
||||
if (!corPtr->stackLevel) {
|
||||
if (COR_IS_SUSPENDED(corPtr)) {
|
||||
/*
|
||||
* -- Coroutine is suspended --
|
||||
* Push the callback to restore the caller's context on yield or
|
||||
@@ -8759,7 +8573,7 @@ TclNRCoroutineActivateCallback(
|
||||
* the interp's environment to make it suitable to run this coroutine.
|
||||
*/
|
||||
|
||||
corPtr->stackLevel = stackLevel;
|
||||
corPtr->stackLevel = corPtr->eePtr->stackLevel;
|
||||
numLevels = corPtr->auxNumLevels;
|
||||
corPtr->auxNumLevels = iPtr->numLevels;
|
||||
|
||||
@@ -8773,7 +8587,7 @@ TclNRCoroutineActivateCallback(
|
||||
* Coroutine is active: yield
|
||||
*/
|
||||
|
||||
if (corPtr->stackLevel != stackLevel) {
|
||||
if (corPtr->stackLevel != corPtr->eePtr->stackLevel) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"cannot yield: C stack busy", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "CANT_YIELD",
|
||||
@@ -8789,7 +8603,7 @@ TclNRCoroutineActivateCallback(
|
||||
Tcl_Panic("Yield received an option which is not implemented");
|
||||
}
|
||||
|
||||
corPtr->stackLevel = NULL;
|
||||
corPtr->stackLevel = -1;
|
||||
|
||||
numLevels = iPtr->numLevels;
|
||||
iPtr->numLevels = corPtr->auxNumLevels;
|
||||
@@ -9033,7 +8847,7 @@ TclNRCoroutineObjCmd(
|
||||
corPtr->running.varFramePtr = iPtr->rootFramePtr;
|
||||
corPtr->running.cmdFramePtr = NULL;
|
||||
corPtr->running.lineLABCPtr = corPtr->lineLABCPtr;
|
||||
corPtr->stackLevel = NULL;
|
||||
corPtr->stackLevel = -1;
|
||||
corPtr->auxNumLevels = 0;
|
||||
|
||||
/*
|
||||
|
||||
+8
-26
@@ -1302,28 +1302,12 @@ TclInfoFrame(
|
||||
*/
|
||||
|
||||
ADD_PAIR("type", Tcl_NewStringObj(typeString[framePtr->type], -1));
|
||||
ADD_PAIR("line", Tcl_NewIntObj(framePtr->line[0]));
|
||||
ADD_PAIR("cmd", Tcl_NewStringObj(framePtr->cmd.str.cmd,
|
||||
framePtr->cmd.str.len));
|
||||
break;
|
||||
|
||||
case TCL_LOCATION_EVAL_LIST:
|
||||
/*
|
||||
* List optimized evaluation. Type, line, cmd, the latter through
|
||||
* listPtr, possibly a frame.
|
||||
*/
|
||||
|
||||
ADD_PAIR("type", Tcl_NewStringObj(typeString[framePtr->type], -1));
|
||||
ADD_PAIR("line", Tcl_NewIntObj(1));
|
||||
|
||||
/*
|
||||
* We put a duplicate of the command list obj into the result to
|
||||
* ensure that the 'pure List'-property of the command itself is not
|
||||
* destroyed. Otherwise the query here would disable the list
|
||||
* optimization path in Tcl_EvalObjEx.
|
||||
*/
|
||||
|
||||
ADD_PAIR("cmd", Tcl_DuplicateObj(framePtr->cmd.listPtr));
|
||||
if (framePtr->line) {
|
||||
ADD_PAIR("line", Tcl_NewIntObj(framePtr->line[0]));
|
||||
} else {
|
||||
ADD_PAIR("line", Tcl_NewIntObj(1));
|
||||
}
|
||||
ADD_PAIR("cmd", TclGetSourceFromFrame(framePtr, 0, NULL));
|
||||
break;
|
||||
|
||||
case TCL_LOCATION_PREBC:
|
||||
@@ -1371,8 +1355,7 @@ TclInfoFrame(
|
||||
Tcl_DecrRefCount(fPtr->data.eval.path);
|
||||
}
|
||||
|
||||
ADD_PAIR("cmd",
|
||||
Tcl_NewStringObj(fPtr->cmd.str.cmd, fPtr->cmd.str.len));
|
||||
ADD_PAIR("cmd", TclGetSourceFromFrame(fPtr, 0, NULL));
|
||||
TclStackFree(interp, fPtr);
|
||||
break;
|
||||
}
|
||||
@@ -1391,8 +1374,7 @@ TclInfoFrame(
|
||||
* the result list object.
|
||||
*/
|
||||
|
||||
ADD_PAIR("cmd", Tcl_NewStringObj(framePtr->cmd.str.cmd,
|
||||
framePtr->cmd.str.len));
|
||||
ADD_PAIR("cmd", TclGetSourceFromFrame(framePtr, 0, NULL));
|
||||
break;
|
||||
|
||||
case TCL_LOCATION_PROC:
|
||||
|
||||
+24
-41
@@ -87,6 +87,7 @@ TclCompileAppendCmd(
|
||||
int isScalar, localIndex, numWords, i;
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
numWords = parsePtr->numWords;
|
||||
if (numWords == 1) {
|
||||
return TCL_ERROR;
|
||||
@@ -544,7 +545,6 @@ TclCompileCatchCmd(
|
||||
JumpFixup jumpFixup;
|
||||
Tcl_Token *cmdTokenPtr, *resultNameTokenPtr, *optsNameTokenPtr;
|
||||
int resultIndex, optsIndex, range;
|
||||
int initStackDepth = envPtr->currStackDepth;
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
|
||||
/*
|
||||
@@ -610,12 +610,12 @@ TclCompileCatchCmd(
|
||||
* begin by undeflowing the stack below the mark set by BEGIN_CATCH4.
|
||||
*/
|
||||
|
||||
SetLineInformation(1);
|
||||
if (cmdTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
|
||||
TclEmitInstInt4( INST_BEGIN_CATCH4, range, envPtr);
|
||||
ExceptionRangeStarts(envPtr, range);
|
||||
CompileBody(envPtr, cmdTokenPtr, interp);
|
||||
BODY(cmdTokenPtr, 1);
|
||||
} else {
|
||||
SetLineInformation(1);
|
||||
CompileTokens(envPtr, cmdTokenPtr, interp);
|
||||
TclEmitInstInt4( INST_BEGIN_CATCH4, range, envPtr);
|
||||
ExceptionRangeStarts(envPtr, range);
|
||||
@@ -742,15 +742,6 @@ TclCompileCatchCmd(
|
||||
TclEmitOpcode( INST_POP, envPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Result of all this, on either branch, should have been to leave one
|
||||
* operand -- the return code -- on the stack.
|
||||
*/
|
||||
|
||||
if (envPtr->currStackDepth != initStackDepth + 1) {
|
||||
Tcl_Panic("in TclCompileCatchCmd, currStackDepth = %d should be %d",
|
||||
envPtr->currStackDepth, initStackDepth+1);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -983,6 +974,7 @@ TclCompileDictGetCmd(
|
||||
* case is legal, but too special and magic for us to deal with here).
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords < 3) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -1020,6 +1012,7 @@ TclCompileDictExistsCmd(
|
||||
* case is legal, but too special and magic for us to deal with here).
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords < 3) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -1057,6 +1050,7 @@ TclCompileDictUnsetCmd(
|
||||
* compile to bytecode.
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords < 3) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -1202,6 +1196,7 @@ TclCompileDictMergeCmd(
|
||||
* argument, the only thing to do is to verify the dict-ness.
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. (less likely) */
|
||||
if (parsePtr->numWords < 2) {
|
||||
PushStringLiteral(envPtr, "");
|
||||
return TCL_OK;
|
||||
@@ -1467,8 +1462,7 @@ CompileDictEachCmd(
|
||||
* Compile the loop body itself. It should be stack-neutral.
|
||||
*/
|
||||
|
||||
SetLineInformation(3);
|
||||
CompileBody(envPtr, bodyTokenPtr, interp);
|
||||
BODY(bodyTokenPtr, 3);
|
||||
if (collect == TCL_EACH_COLLECT) {
|
||||
Emit14Inst( INST_LOAD_SCALAR, keyVarIndex, envPtr);
|
||||
TclEmitInstInt4(INST_OVER, 1, envPtr);
|
||||
@@ -1651,8 +1645,7 @@ TclCompileDictUpdateCmd(
|
||||
TclEmitInstInt4( INST_BEGIN_CATCH4, range, envPtr);
|
||||
|
||||
ExceptionRangeStarts(envPtr, range);
|
||||
SetLineInformation(parsePtr->numWords - 1);
|
||||
CompileBody(envPtr, bodyTokenPtr, interp);
|
||||
BODY(bodyTokenPtr, parsePtr->numWords - 1);
|
||||
ExceptionRangeEnds(envPtr, range);
|
||||
|
||||
/*
|
||||
@@ -1724,6 +1717,7 @@ TclCompileDictAppendCmd(
|
||||
* speed quite so much. ;-)
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords<4 || parsePtr->numWords>100) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -1776,6 +1770,8 @@ TclCompileDictLappendCmd(
|
||||
* There must be three arguments after the command.
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
/* Probably not. Why is INST_DICT_LAPPEND limited to one value? */
|
||||
if (parsePtr->numWords != 4) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -1822,6 +1818,7 @@ TclCompileDictWithCmd(
|
||||
* There must be at least one argument after the command.
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords < 3) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -1992,8 +1989,7 @@ TclCompileDictWithCmd(
|
||||
TclEmitInstInt4( INST_BEGIN_CATCH4, range, envPtr);
|
||||
|
||||
ExceptionRangeStarts(envPtr, range);
|
||||
SetLineInformation(parsePtr->numWords-1);
|
||||
CompileBody(envPtr, tokenPtr, interp);
|
||||
BODY(tokenPtr, parsePtr->numWords - 1);
|
||||
ExceptionRangeEnds(envPtr, range);
|
||||
|
||||
/*
|
||||
@@ -2268,8 +2264,7 @@ TclCompileForCmd(
|
||||
* Inline compile the initial command.
|
||||
*/
|
||||
|
||||
SetLineInformation(1);
|
||||
CompileBody(envPtr, startTokenPtr, interp);
|
||||
BODY(startTokenPtr, 1);
|
||||
TclEmitOpcode(INST_POP, envPtr);
|
||||
|
||||
/*
|
||||
@@ -2292,8 +2287,7 @@ TclCompileForCmd(
|
||||
|
||||
bodyRange = TclCreateExceptRange(LOOP_EXCEPTION_RANGE, envPtr);
|
||||
bodyCodeOffset = ExceptionRangeStarts(envPtr, bodyRange);
|
||||
SetLineInformation(4);
|
||||
CompileBody(envPtr, bodyTokenPtr, interp);
|
||||
BODY(bodyTokenPtr, 4);
|
||||
ExceptionRangeEnds(envPtr, bodyRange);
|
||||
TclEmitOpcode(INST_POP, envPtr);
|
||||
|
||||
@@ -2306,8 +2300,7 @@ TclCompileForCmd(
|
||||
nextRange = TclCreateExceptRange(LOOP_EXCEPTION_RANGE, envPtr);
|
||||
envPtr->exceptAuxArrayPtr[nextRange].supportsContinue = 0;
|
||||
nextCodeOffset = ExceptionRangeStarts(envPtr, nextRange);
|
||||
SetLineInformation(3);
|
||||
CompileBody(envPtr, nextTokenPtr, interp);
|
||||
BODY(nextTokenPtr, 3);
|
||||
ExceptionRangeEnds(envPtr, nextRange);
|
||||
TclEmitOpcode(INST_POP, envPtr);
|
||||
|
||||
@@ -2464,7 +2457,7 @@ CompileEachloopCmd(
|
||||
Tcl_Token *tokenPtr, *bodyTokenPtr;
|
||||
unsigned char *jumpPc;
|
||||
JumpFixup jumpFalseFixup;
|
||||
int jumpBackDist, jumpBackOffset, infoIndex, range, bodyIndex;
|
||||
int jumpBackDist, jumpBackOffset, infoIndex, range;
|
||||
int numWords, numLists, numVars, loopIndex, tempVar, i, j, code;
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
|
||||
@@ -2504,8 +2497,6 @@ CompileEachloopCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
bodyIndex = i-1;
|
||||
|
||||
/*
|
||||
* Allocate storage for the varcList and varvList arrays if necessary.
|
||||
*/
|
||||
@@ -2544,7 +2535,7 @@ CompileEachloopCmd(
|
||||
|
||||
Tcl_DStringInit(&varList);
|
||||
TclDStringAppendToken(&varList, &tokenPtr[1]);
|
||||
code = Tcl_SplitList(interp, Tcl_DStringValue(&varList),
|
||||
code = Tcl_SplitList(NULL, Tcl_DStringValue(&varList),
|
||||
&varcList[loopIndex], &varvList[loopIndex]);
|
||||
Tcl_DStringFree(&varList);
|
||||
if (code != TCL_OK) {
|
||||
@@ -2646,8 +2637,7 @@ CompileEachloopCmd(
|
||||
i < numWords-1;
|
||||
i++, tokenPtr = TokenAfter(tokenPtr)) {
|
||||
if ((i%2 == 0) && (i > 0)) {
|
||||
SetLineInformation(i);
|
||||
CompileTokens(envPtr, tokenPtr, interp);
|
||||
CompileWord(envPtr, tokenPtr, interp, i);
|
||||
tempVar = (firstValueTemp + loopIndex);
|
||||
Emit14Inst( INST_STORE_SCALAR, tempVar, envPtr);
|
||||
TclEmitOpcode( INST_POP, envPtr);
|
||||
@@ -2684,9 +2674,8 @@ CompileEachloopCmd(
|
||||
* Inline compile the loop body.
|
||||
*/
|
||||
|
||||
SetLineInformation(bodyIndex);
|
||||
ExceptionRangeStarts(envPtr, range);
|
||||
CompileBody(envPtr, bodyTokenPtr, interp);
|
||||
BODY(bodyTokenPtr, numWords - 1);
|
||||
ExceptionRangeEnds(envPtr, range);
|
||||
|
||||
if (collect == TCL_EACH_COLLECT) {
|
||||
@@ -2988,7 +2977,8 @@ TclCompileFormatCmd(
|
||||
ckfree(objv);
|
||||
Tcl_DecrRefCount(formatObj);
|
||||
if (tmpObj == NULL) {
|
||||
return TCL_ERROR;
|
||||
TclCompileSyntaxError(interp, envPtr);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3166,10 +3156,7 @@ TclPushVarName(
|
||||
CompileEnv *envPtr, /* Holds resulting instructions. */
|
||||
int flags, /* TCL_NO_LARGE_INDEX | TCL_NO_ELEMENT. */
|
||||
int *localIndexPtr, /* Must not be NULL. */
|
||||
int *isScalarPtr, /* Must not be NULL. */
|
||||
int line, /* Line the token starts on. */
|
||||
int *clNext) /* Reference to offset of next hidden cont.
|
||||
* line. */
|
||||
int *isScalarPtr) /* Must not be NULL. */
|
||||
{
|
||||
register const char *p;
|
||||
const char *name, *elName;
|
||||
@@ -3349,8 +3336,6 @@ TclPushVarName(
|
||||
|
||||
if (elName != NULL && !(flags & TCL_NO_ELEMENT)) {
|
||||
if (elNameChars) {
|
||||
envPtr->line = line;
|
||||
envPtr->clNext = clNext;
|
||||
TclCompileTokens(interp, elemTokenPtr, elemTokenCount,
|
||||
envPtr);
|
||||
} else {
|
||||
@@ -3362,8 +3347,6 @@ TclPushVarName(
|
||||
* The var name isn't simple: compile and push it.
|
||||
*/
|
||||
|
||||
envPtr->line = line;
|
||||
envPtr->clNext = clNext;
|
||||
CompileTokens(envPtr, varTokenPtr, interp);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ TclCompileGlobalCmd(
|
||||
int localIndex, numWords, i;
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
numWords = parsePtr->numWords;
|
||||
if (numWords < 2) {
|
||||
return TCL_ERROR;
|
||||
@@ -264,8 +265,7 @@ TclCompileIfCmd(
|
||||
*/
|
||||
|
||||
if (compileScripts) {
|
||||
SetLineInformation(wordIdx);
|
||||
CompileBody(envPtr, tokenPtr, interp);
|
||||
BODY(tokenPtr, wordIdx);
|
||||
}
|
||||
|
||||
if (realCond) {
|
||||
@@ -345,8 +345,7 @@ TclCompileIfCmd(
|
||||
* Compile the else command body.
|
||||
*/
|
||||
|
||||
SetLineInformation(wordIdx);
|
||||
CompileBody(envPtr, tokenPtr, interp);
|
||||
BODY(tokenPtr, wordIdx);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -701,8 +700,7 @@ TclCompileInfoLevelCmd(
|
||||
* list of arguments.
|
||||
*/
|
||||
|
||||
SetLineInformation(1);
|
||||
CompileTokens(envPtr, TokenAfter(parsePtr->tokenPtr), interp);
|
||||
CompileWord(envPtr, TokenAfter(parsePtr->tokenPtr), interp, 1);
|
||||
TclEmitOpcode( INST_INFO_LEVEL_ARGS, envPtr);
|
||||
}
|
||||
return TCL_OK;
|
||||
@@ -823,6 +821,7 @@ TclCompileLappendCmd(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
numWords = parsePtr->numWords;
|
||||
if (numWords == 1) {
|
||||
return TCL_ERROR;
|
||||
@@ -1064,6 +1063,7 @@ TclCompileLindexCmd(
|
||||
* Quit if too few args.
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (numWords <= 1) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@@ -1586,6 +1586,7 @@ TclCompileLsetCmd(
|
||||
* Check argument count.
|
||||
*/
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords < 3) {
|
||||
/*
|
||||
* Fail at run time, not in compilation.
|
||||
@@ -2534,6 +2535,7 @@ TclCompileSyntaxError(
|
||||
TclEmitPush(TclRegisterNewLiteral(envPtr, bytes, numBytes), envPtr);
|
||||
CompileReturnInternal(envPtr, INST_SYNTAX, TCL_ERROR, 0,
|
||||
TclNoErrorStack(interp, Tcl_GetReturnOptions(interp, TCL_ERROR)));
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+25
-47
@@ -40,17 +40,14 @@ static int CompileUnaryOpCmd(Tcl_Interp *interp,
|
||||
Tcl_Parse *parsePtr, int instruction,
|
||||
CompileEnv *envPtr);
|
||||
static void IssueSwitchChainedTests(Tcl_Interp *interp,
|
||||
CompileEnv *envPtr, ExtCmdLoc *mapPtr,
|
||||
int eclIndex, int mode, int noCase,
|
||||
int valueIndex, Tcl_Token *valueTokenPtr,
|
||||
int numWords, Tcl_Token **bodyToken,
|
||||
int *bodyLines, int **bodyNext);
|
||||
static void IssueSwitchJumpTable(Tcl_Interp *interp,
|
||||
CompileEnv *envPtr, ExtCmdLoc *mapPtr,
|
||||
int eclIndex, int valueIndex,
|
||||
Tcl_Token *valueTokenPtr, int numWords,
|
||||
CompileEnv *envPtr, int mode, int noCase,
|
||||
int valueIndex, int numWords,
|
||||
Tcl_Token **bodyToken, int *bodyLines,
|
||||
int **bodyContLines);
|
||||
int **bodyNext);
|
||||
static void IssueSwitchJumpTable(Tcl_Interp *interp,
|
||||
CompileEnv *envPtr, int valueIndex,
|
||||
int numWords, Tcl_Token **bodyToken,
|
||||
int *bodyLines, int **bodyContLines);
|
||||
static int IssueTryClausesInstructions(Tcl_Interp *interp,
|
||||
CompileEnv *envPtr, Tcl_Token *bodyToken,
|
||||
int numHandlers, int *matchCodes,
|
||||
@@ -88,8 +85,6 @@ const AuxDataType tclJumptableInfoType = {
|
||||
TclEmitInstInt1(INST_##name,(val1),envPtr);TclEmitInt4((val2),envPtr)
|
||||
#define OP44(name,val1,val2) \
|
||||
TclEmitInstInt4(INST_##name,(val1),envPtr);TclEmitInt4((val2),envPtr)
|
||||
#define BODY(token,index) \
|
||||
SetLineInformation((index));CompileBody(envPtr,(token),interp)
|
||||
#define PUSH(str) \
|
||||
PushStringLiteral(envPtr, str)
|
||||
#define JUMP4(name,var) \
|
||||
@@ -748,6 +743,9 @@ TclSubstCompile(
|
||||
Tcl_InterpState state = NULL;
|
||||
|
||||
TclSubstParse(interp, bytes, numBytes, flags, &parse, &state);
|
||||
if (state != NULL) {
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tricky point! If the first token does not result in a *guaranteed* push
|
||||
@@ -993,9 +991,6 @@ TclSubstCompile(
|
||||
* Instructions are added to envPtr to execute the "switch" command at
|
||||
* runtime.
|
||||
*
|
||||
* FIXME:
|
||||
* Stack depths are probably not calculated correctly.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -1286,13 +1281,15 @@ TclCompileSwitchCmd(
|
||||
* but it handles the most common case well enough.
|
||||
*/
|
||||
|
||||
/* Both methods push the value to match against onto the stack. */
|
||||
CompileWord(envPtr, valueTokenPtr, interp, valueIndex);
|
||||
|
||||
if (mode == Switch_Exact) {
|
||||
IssueSwitchJumpTable(interp, envPtr, mapPtr, eclIndex, valueIndex,
|
||||
valueTokenPtr, numWords, bodyToken, bodyLines, bodyContLines);
|
||||
IssueSwitchJumpTable(interp, envPtr, valueIndex, numWords, bodyToken,
|
||||
bodyLines, bodyContLines);
|
||||
} else {
|
||||
IssueSwitchChainedTests(interp, envPtr, mapPtr, eclIndex, mode,noCase,
|
||||
valueIndex, valueTokenPtr, numWords, bodyToken, bodyLines,
|
||||
bodyContLines);
|
||||
IssueSwitchChainedTests(interp, envPtr, mode, noCase, valueIndex,
|
||||
numWords, bodyToken, bodyLines, bodyContLines);
|
||||
}
|
||||
result = TCL_OK;
|
||||
|
||||
@@ -1330,13 +1327,9 @@ static void
|
||||
IssueSwitchChainedTests(
|
||||
Tcl_Interp *interp, /* Context for compiling script bodies. */
|
||||
CompileEnv *envPtr, /* Holds resulting instructions. */
|
||||
ExtCmdLoc *mapPtr, /* For mapping tokens to their source code
|
||||
* location. */
|
||||
int eclIndex,
|
||||
int mode, /* Exact, Glob or Regexp */
|
||||
int noCase, /* Case-insensitivity flag. */
|
||||
int valueIndex, /* The value to match against. */
|
||||
Tcl_Token *valueTokenPtr,
|
||||
int numBodyTokens, /* Number of tokens describing things the
|
||||
* switch can match against and bodies to
|
||||
* execute when the match succeeds. */
|
||||
@@ -1360,13 +1353,6 @@ IssueSwitchChainedTests(
|
||||
int simple, exact; /* For extracting the type of regexp. */
|
||||
int i;
|
||||
|
||||
/*
|
||||
* First, we push the value we're matching against on the stack.
|
||||
*/
|
||||
|
||||
SetLineInformation(valueIndex);
|
||||
CompileTokens(envPtr, valueTokenPtr, interp);
|
||||
|
||||
/*
|
||||
* Generate a test for each arm.
|
||||
*/
|
||||
@@ -1510,7 +1496,7 @@ IssueSwitchChainedTests(
|
||||
}
|
||||
|
||||
/*
|
||||
* Now do the actual compilation. Note that we do not use CompileBody
|
||||
* Now do the actual compilation. Note that we do not use BODY()
|
||||
* because we may have synthesized the tokens in a non-standard
|
||||
* pattern.
|
||||
*/
|
||||
@@ -1592,11 +1578,7 @@ static void
|
||||
IssueSwitchJumpTable(
|
||||
Tcl_Interp *interp, /* Context for compiling script bodies. */
|
||||
CompileEnv *envPtr, /* Holds resulting instructions. */
|
||||
ExtCmdLoc *mapPtr, /* For mapping tokens to their source code
|
||||
* location. */
|
||||
int eclIndex,
|
||||
int valueIndex, /* The value to match against. */
|
||||
Tcl_Token *valueTokenPtr,
|
||||
int numBodyTokens, /* Number of tokens describing things the
|
||||
* switch can match against and bodies to
|
||||
* execute when the match succeeds. */
|
||||
@@ -1611,13 +1593,6 @@ IssueSwitchJumpTable(
|
||||
Tcl_DString buffer;
|
||||
Tcl_HashEntry *hPtr;
|
||||
|
||||
/*
|
||||
* First, we push the value we're matching against on the stack.
|
||||
*/
|
||||
|
||||
SetLineInformation(valueIndex);
|
||||
CompileTokens(envPtr, valueTokenPtr, interp);
|
||||
|
||||
/*
|
||||
* Compile the switch by using a jump table, which is basically a
|
||||
* hashtable that maps from literal values to match against to the offset
|
||||
@@ -2048,8 +2023,7 @@ TclCompileTryCmd(
|
||||
*/
|
||||
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
SetLineInformation(1);
|
||||
CompileBody(envPtr, bodyToken, interp);
|
||||
BODY(bodyToken, 1);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -2844,6 +2818,7 @@ TclCompileUnsetCmd(
|
||||
Tcl_Obj *leadingWord;
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
numWords = parsePtr->numWords-1;
|
||||
flags = 1;
|
||||
varTokenPtr = TokenAfter(parsePtr->tokenPtr);
|
||||
@@ -3028,13 +3003,12 @@ TclCompileWhileCmd(
|
||||
* Compile the loop body.
|
||||
*/
|
||||
|
||||
SetLineInformation(2);
|
||||
bodyCodeOffset = ExceptionRangeStarts(envPtr, range);
|
||||
if (!loopMayEnd) {
|
||||
envPtr->exceptArrayPtr[range].continueOffset = testCodeOffset;
|
||||
envPtr->exceptArrayPtr[range].codeOffset = bodyCodeOffset;
|
||||
}
|
||||
CompileBody(envPtr, bodyTokenPtr, interp);
|
||||
BODY(bodyTokenPtr, 2);
|
||||
ExceptionRangeEnds(envPtr, range);
|
||||
OP( POP);
|
||||
|
||||
@@ -3200,6 +3174,7 @@ CompileAssociativeBinaryOpCmd(
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
int words;
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
for (words=1 ; words<parsePtr->numWords ; words++) {
|
||||
tokenPtr = TokenAfter(tokenPtr);
|
||||
CompileWord(envPtr, tokenPtr, interp, words);
|
||||
@@ -3283,6 +3258,7 @@ CompileComparisonOpCmd(
|
||||
Tcl_Token *tokenPtr;
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords < 3) {
|
||||
PUSH("1");
|
||||
} else if (parsePtr->numWords == 3) {
|
||||
@@ -3620,6 +3596,7 @@ TclCompileMinusOpCmd(
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
int words;
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords == 1) {
|
||||
/*
|
||||
* Fallback to direct eval to report syntax error.
|
||||
@@ -3665,6 +3642,7 @@ TclCompileDivOpCmd(
|
||||
DefineLineInformation; /* TIP #280 */
|
||||
int words;
|
||||
|
||||
/* TODO: Consider support for compiling expanded args. */
|
||||
if (parsePtr->numWords == 1) {
|
||||
/*
|
||||
* Fallback to direct eval to report syntax error.
|
||||
|
||||
+416
-547
File diff suppressed because it is too large
Load Diff
+28
-28
@@ -193,13 +193,6 @@ typedef struct ExtCmdLoc {
|
||||
ECL *loc; /* Command word locations (lines). */
|
||||
int nloc; /* Number of allocated entries in 'loc'. */
|
||||
int nuloc; /* Number of used entries in 'loc'. */
|
||||
Tcl_HashTable litInfo; /* Indexed by bytecode 'PC', to have the
|
||||
* information accessible per command and
|
||||
* argument, not per whole bytecode. Value is
|
||||
* index of command in 'loc', giving us the
|
||||
* literals to associate with line information
|
||||
* as command argument, see
|
||||
* TclArgumentBCEnter() */
|
||||
} ExtCmdLoc;
|
||||
|
||||
/*
|
||||
@@ -372,10 +365,6 @@ typedef struct CompileEnv {
|
||||
* encountered that have not yet been paired
|
||||
* with a corresponding
|
||||
* INST_INVOKE_EXPANDED. */
|
||||
ContLineLoc *clLoc; /* If not NULL, the table holding the
|
||||
* locations of the invisible continuation
|
||||
* lines in the input script, to adjust the
|
||||
* line counter. */
|
||||
int *clNext; /* If not NULL, it refers to the next slot in
|
||||
* clLoc to check for an invisible
|
||||
* continuation line. */
|
||||
@@ -991,6 +980,9 @@ MODULE_SCOPE ByteCode * TclCompileObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
|
||||
*----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MODULE_SCOPE int TclAttemptCompileProc(Tcl_Interp *interp,
|
||||
Tcl_Parse *parsePtr, int depth, Command *cmdPtr,
|
||||
CompileEnv *envPtr);
|
||||
MODULE_SCOPE void TclCleanupByteCode(ByteCode *codePtr);
|
||||
MODULE_SCOPE void TclCleanupStackForBreakContinue(CompileEnv *envPtr,
|
||||
ExceptionAux *auxPtr);
|
||||
@@ -1002,6 +994,9 @@ MODULE_SCOPE void TclCompileExpr(Tcl_Interp *interp, const char *script,
|
||||
MODULE_SCOPE void TclCompileExprWords(Tcl_Interp *interp,
|
||||
Tcl_Token *tokenPtr, int numWords,
|
||||
CompileEnv *envPtr);
|
||||
MODULE_SCOPE void TclCompileInvocation(Tcl_Interp *interp,
|
||||
Tcl_Token *tokenPtr, Tcl_Obj *cmdObj, int numWords,
|
||||
CompileEnv *envPtr);
|
||||
MODULE_SCOPE void TclCompileScript(Tcl_Interp *interp,
|
||||
const char *script, int numBytes,
|
||||
CompileEnv *envPtr);
|
||||
@@ -1074,7 +1069,7 @@ MODULE_SCOPE void TclPrintSource(FILE *outFile,
|
||||
MODULE_SCOPE void TclPushVarName(Tcl_Interp *interp,
|
||||
Tcl_Token *varTokenPtr, CompileEnv *envPtr,
|
||||
int flags, int *localIndexPtr,
|
||||
int *isScalarPtr, int line, int *clNext);
|
||||
int *isScalarPtr);
|
||||
MODULE_SCOPE int TclRegisterLiteral(CompileEnv *envPtr,
|
||||
char *bytes, int length, int flags);
|
||||
MODULE_SCOPE void TclReleaseLiteral(Tcl_Interp *interp, Tcl_Obj *objPtr);
|
||||
@@ -1114,6 +1109,15 @@ MODULE_SCOPE Tcl_Obj *TclNewInstNameObj(unsigned char inst);
|
||||
*----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Simplified form to access AuxData.
|
||||
*
|
||||
* ClientData TclFetchAuxData(CompileEng *envPtr, int index);
|
||||
*/
|
||||
|
||||
#define TclFetchAuxData(envPtr, index) \
|
||||
(envPtr)->auxDataArrayPtr[(index)].clientData
|
||||
|
||||
#define LITERAL_ON_HEAP 0x01
|
||||
#define LITERAL_CMD_NAME 0x02
|
||||
|
||||
@@ -1407,16 +1411,16 @@ MODULE_SCOPE Tcl_Obj *TclNewInstNameObj(unsigned char inst);
|
||||
#define TclMax(i, j) ((((int) i) > ((int) j))? (i) : (j))
|
||||
|
||||
/*
|
||||
* Convenience macro for use when compiling bodies of commands. The ANSI C
|
||||
* "prototype" for this macro is:
|
||||
* Convenience macros for use when compiling bodies of commands. The ANSI C
|
||||
* "prototype" for these macros are:
|
||||
*
|
||||
* static void CompileBody(CompileEnv *envPtr, Tcl_Token *tokenPtr,
|
||||
* Tcl_Interp *interp);
|
||||
* static void BODY(Tcl_Token *tokenPtr, int word);
|
||||
*/
|
||||
|
||||
#define CompileBody(envPtr, tokenPtr, interp) \
|
||||
TclCompileCmdWord((interp), (tokenPtr)+1, (tokenPtr)->numComponents, \
|
||||
(envPtr))
|
||||
#define BODY(tokenPtr, word) \
|
||||
SetLineInformation((word)); \
|
||||
TclCompileCmdWord(interp, (tokenPtr)+1, (tokenPtr)->numComponents, \
|
||||
envPtr)
|
||||
|
||||
/*
|
||||
* Convenience macro for use when compiling tokens to be pushed. The ANSI C
|
||||
@@ -1515,13 +1519,10 @@ MODULE_SCOPE Tcl_Obj *TclNewInstNameObj(unsigned char inst);
|
||||
|
||||
#define CompileWord(envPtr, tokenPtr, interp, word) \
|
||||
if ((tokenPtr)->type == TCL_TOKEN_SIMPLE_WORD) { \
|
||||
TclEmitPush(TclRegisterNewLiteral((envPtr), (tokenPtr)[1].start, \
|
||||
(tokenPtr)[1].size), (envPtr)); \
|
||||
PushLiteral((envPtr), (tokenPtr)[1].start, (tokenPtr)[1].size); \
|
||||
} else { \
|
||||
envPtr->line = mapPtr->loc[eclIndex].line[word]; \
|
||||
envPtr->clNext = mapPtr->loc[eclIndex].next[word]; \
|
||||
TclCompileTokens((interp), (tokenPtr)+1, (tokenPtr)->numComponents, \
|
||||
(envPtr)); \
|
||||
SetLineInformation((word)); \
|
||||
CompileTokens((envPtr), (tokenPtr), (interp)); \
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1542,9 +1543,8 @@ MODULE_SCOPE Tcl_Obj *TclNewInstNameObj(unsigned char inst);
|
||||
envPtr->clNext = mapPtr->loc[eclIndex].next[(word)]
|
||||
|
||||
#define PushVarNameWord(i,v,e,f,l,sc,word) \
|
||||
TclPushVarName(i,v,e,f,l,sc, \
|
||||
mapPtr->loc[eclIndex].line[(word)], \
|
||||
mapPtr->loc[eclIndex].next[(word)])
|
||||
SetLineInformation(word); \
|
||||
TclPushVarName(i,v,e,f,l,sc)
|
||||
|
||||
/*
|
||||
* Often want to issue one of two versions of an instruction based on whether
|
||||
|
||||
+69
-126
@@ -35,9 +35,6 @@ static void MakeCachedEnsembleCommand(Tcl_Obj *objPtr,
|
||||
static void FreeEnsembleCmdRep(Tcl_Obj *objPtr);
|
||||
static void DupEnsembleCmdRep(Tcl_Obj *objPtr, Tcl_Obj *copyPtr);
|
||||
static void StringOfEnsembleCmdRep(Tcl_Obj *objPtr);
|
||||
static int CompileToCompiledCommand(Tcl_Interp *interp,
|
||||
Tcl_Parse *parsePtr, int depth, Command *cmdPtr,
|
||||
CompileEnv *envPtr);
|
||||
static void CompileToInvokedCommand(Tcl_Interp *interp,
|
||||
Tcl_Parse *parsePtr, Tcl_Obj *replacements,
|
||||
Command *cmdPtr, CompileEnv *envPtr);
|
||||
@@ -88,16 +85,6 @@ const Tcl_ObjType tclEnsembleCmdType = {
|
||||
NULL /* setFromAnyProc */
|
||||
};
|
||||
|
||||
/*
|
||||
* Copied from tclCompCmds.c
|
||||
*/
|
||||
|
||||
#define DefineLineInformation \
|
||||
ExtCmdLoc *mapPtr = envPtr->extCmdMapPtr; \
|
||||
int eclIndex = mapPtr->nuloc - 1
|
||||
#define SetLineInformation(word) \
|
||||
envPtr->line = mapPtr->loc[eclIndex].line[(word)]; \
|
||||
envPtr->clNext = mapPtr->loc[eclIndex].next[(word)]
|
||||
|
||||
static inline Tcl_Obj *
|
||||
NewNsObj(
|
||||
@@ -1537,6 +1524,14 @@ TclMakeEnsemble(
|
||||
cmdName = nameParts[nameCount - 1];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Switch on compilation always for core ensembles now that we can do
|
||||
* nice bytecode things with them. Do it now. Waiting until later will
|
||||
* just cause pointless epoch bumps.
|
||||
*/
|
||||
|
||||
ensembleFlags |= ENSEMBLE_COMPILE;
|
||||
ensemble = Tcl_CreateEnsemble(interp, cmdName, ns, ensembleFlags);
|
||||
|
||||
/*
|
||||
@@ -1588,14 +1583,6 @@ TclMakeEnsemble(
|
||||
}
|
||||
}
|
||||
Tcl_SetEnsembleMappingDict(interp, ensemble, mapDict);
|
||||
|
||||
/*
|
||||
* Switch on compilation always for core ensembles now that we can do
|
||||
* nice bytecode things with them.
|
||||
*/
|
||||
|
||||
Tcl_SetEnsembleFlags(interp, ensemble,
|
||||
ensembleFlags | ENSEMBLE_COMPILE);
|
||||
}
|
||||
|
||||
Tcl_DStringFree(&buf);
|
||||
@@ -3004,8 +2991,8 @@ TclCompileEnsemble(
|
||||
*/
|
||||
|
||||
invokeAnyway = 1;
|
||||
if (CompileToCompiledCommand(interp, parsePtr, depth, cmdPtr,
|
||||
envPtr) == TCL_OK) {
|
||||
if (TCL_OK == TclAttemptCompileProc(interp, parsePtr, depth, cmdPtr,
|
||||
envPtr)) {
|
||||
ourResult = TCL_OK;
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -3039,95 +3026,88 @@ TclCompileEnsemble(
|
||||
return ourResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* How to compile a subcommand using its own command compiler. To do that, we
|
||||
* have to perform some trickery to rewrite the arguments, as compilers *must*
|
||||
* have parse tokens that refer to addresses in the original script.
|
||||
*/
|
||||
|
||||
static int
|
||||
CompileToCompiledCommand(
|
||||
int
|
||||
TclAttemptCompileProc(
|
||||
Tcl_Interp *interp,
|
||||
Tcl_Parse *parsePtr,
|
||||
int depth,
|
||||
Command *cmdPtr,
|
||||
CompileEnv *envPtr) /* Holds resulting instructions. */
|
||||
{
|
||||
Tcl_Parse synthetic;
|
||||
Tcl_Token *tokenPtr;
|
||||
int result, i;
|
||||
int savedNumCmds = envPtr->numCommands;
|
||||
Tcl_Token *saveTokenPtr = parsePtr->tokenPtr;
|
||||
int savedStackDepth = envPtr->currStackDepth;
|
||||
unsigned savedCodeNext = envPtr->codeNext - envPtr->codeStart;
|
||||
DefineLineInformation;
|
||||
|
||||
if (cmdPtr->compileProc == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
TclParseInit(interp, NULL, 0, &synthetic);
|
||||
synthetic.numWords = parsePtr->numWords - depth + 1;
|
||||
TclGrowParseTokenArray(&synthetic, 2);
|
||||
synthetic.numTokens = 2;
|
||||
|
||||
/*
|
||||
* Now we have the space to work in, install something rewritten. The
|
||||
* first word will "officially" be the bytes of the structured ensemble
|
||||
* name. That's technically wrong, but nobody will care; we just need
|
||||
* *something* here...
|
||||
* Advance parsePtr->tokenPtr so that it points at the last subcommand.
|
||||
* This will be wrong, but it will not matter, and it will put the
|
||||
* tokens for the arguments in the right place without the needed to
|
||||
* allocate a synthetic Tcl_Parse struct, or copy tokens around.
|
||||
*/
|
||||
|
||||
synthetic.tokenPtr[0].type = TCL_TOKEN_SIMPLE_WORD;
|
||||
synthetic.tokenPtr[0].start = parsePtr->tokenPtr[0].start;
|
||||
synthetic.tokenPtr[0].numComponents = 1;
|
||||
synthetic.tokenPtr[1].type = TCL_TOKEN_TEXT;
|
||||
synthetic.tokenPtr[1].start = parsePtr->tokenPtr[0].start;
|
||||
synthetic.tokenPtr[1].numComponents = 0;
|
||||
for (i=0,tokenPtr=parsePtr->tokenPtr ; i<depth ; i++) {
|
||||
int sclen = (tokenPtr->start - synthetic.tokenPtr[0].start)
|
||||
+ tokenPtr->size;
|
||||
|
||||
synthetic.tokenPtr[0].size = sclen;
|
||||
synthetic.tokenPtr[1].size = sclen;
|
||||
tokenPtr = TokenAfter(tokenPtr);
|
||||
for (i = 0; i < depth - 1; i++) {
|
||||
parsePtr->tokenPtr = TokenAfter(parsePtr->tokenPtr);
|
||||
}
|
||||
parsePtr->numWords -= (depth - 1);
|
||||
|
||||
/*
|
||||
* Copy over the real argument tokens.
|
||||
* Shift the line information arrays to account for different word
|
||||
* index values.
|
||||
*/
|
||||
|
||||
for (i=1; i<synthetic.numWords; i++) {
|
||||
int toCopy;
|
||||
|
||||
toCopy = tokenPtr->numComponents + 1;
|
||||
TclGrowParseTokenArray(&synthetic, toCopy);
|
||||
memcpy(synthetic.tokenPtr + synthetic.numTokens, tokenPtr,
|
||||
sizeof(Tcl_Token) * toCopy);
|
||||
synthetic.numTokens += toCopy;
|
||||
tokenPtr = TokenAfter(tokenPtr);
|
||||
}
|
||||
mapPtr->loc[eclIndex].line += (depth - 1);
|
||||
mapPtr->loc[eclIndex].next += (depth - 1);
|
||||
|
||||
/*
|
||||
* Hand off compilation to the subcommand compiler. At last!
|
||||
*/
|
||||
|
||||
result = cmdPtr->compileProc(interp, &synthetic, cmdPtr, envPtr);
|
||||
result = cmdPtr->compileProc(interp, parsePtr, cmdPtr, envPtr);
|
||||
|
||||
/*
|
||||
* If our target fails to compile, revert the number of commands and the
|
||||
* pointer to the place to issue the next instruction. [Bug 3600328]
|
||||
* Undo the shift.
|
||||
*/
|
||||
|
||||
mapPtr->loc[eclIndex].line -= (depth - 1);
|
||||
mapPtr->loc[eclIndex].next -= (depth - 1);
|
||||
|
||||
parsePtr->numWords += (depth - 1);
|
||||
parsePtr->tokenPtr = saveTokenPtr;
|
||||
|
||||
/*
|
||||
* If our target failed to compile, revert any data from failed partial
|
||||
* compiles. Note that envPtr->numCommands need not be checked because
|
||||
* we avoid compiling subcommands that recursively call TclCompileScript().
|
||||
*/
|
||||
|
||||
if (result != TCL_OK) {
|
||||
envPtr->numCommands = savedNumCmds;
|
||||
envPtr->currStackDepth = savedStackDepth;
|
||||
envPtr->codeNext = envPtr->codeStart + savedCodeNext;
|
||||
#ifdef TCL_COMPILE_DEBUG
|
||||
} else {
|
||||
/*
|
||||
* Confirm that the command compiler generated a single value on
|
||||
* the stack as its result. This is only done in debugging mode,
|
||||
* as it *should* be correct and normal users have no reasonable
|
||||
* way to fix it anyway.
|
||||
*/
|
||||
|
||||
int diff = envPtr->currStackDepth - savedStackDepth;
|
||||
|
||||
if (diff != 1) {
|
||||
Tcl_Panic("bad stack adjustment when compiling"
|
||||
" %.*s (was %d instead of 1)", parsePtr->tokenPtr->size,
|
||||
parsePtr->tokenPtr->start, diff);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up if necessary.
|
||||
*/
|
||||
|
||||
Tcl_FreeParse(&synthetic);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3157,11 +3137,16 @@ CompileToInvokedCommand(
|
||||
*/
|
||||
|
||||
Tcl_ListObjGetElements(NULL, replacements, &numWords, &words);
|
||||
for (i=0,tokPtr=parsePtr->tokenPtr ; i<parsePtr->numWords ; i++) {
|
||||
for (i = 0, tokPtr = parsePtr->tokenPtr; i < parsePtr->numWords;
|
||||
i++, tokPtr = TokenAfter(tokPtr)) {
|
||||
if (i > 0 && i < numWords+1) {
|
||||
bytes = Tcl_GetStringFromObj(words[i-1], &length);
|
||||
PushLiteral(envPtr, bytes, length);
|
||||
} else if (tokPtr->type == TCL_TOKEN_SIMPLE_WORD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SetLineInformation(i);
|
||||
if (tokPtr->type == TCL_TOKEN_SIMPLE_WORD) {
|
||||
int literal = TclRegisterNewLiteral(envPtr,
|
||||
tokPtr[1].start, tokPtr[1].size);
|
||||
|
||||
@@ -3169,16 +3154,12 @@ CompileToInvokedCommand(
|
||||
TclContinuationsEnterDerived(
|
||||
TclFetchLiteral(envPtr, literal),
|
||||
tokPtr[1].start - envPtr->source,
|
||||
mapPtr->loc[eclIndex].next[i]);
|
||||
envPtr->clNext);
|
||||
}
|
||||
TclEmitPush(literal, envPtr);
|
||||
} else {
|
||||
if (envPtr->clNext) {
|
||||
SetLineInformation(i);
|
||||
}
|
||||
CompileTokens(envPtr, tokPtr, interp);
|
||||
}
|
||||
tokPtr = TokenAfter(tokPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3224,51 +3205,13 @@ CompileBasicNArgCommand(
|
||||
* compiled. */
|
||||
CompileEnv *envPtr) /* Holds resulting instructions. */
|
||||
{
|
||||
Tcl_Token *tokenPtr;
|
||||
Tcl_Obj *objPtr;
|
||||
char *bytes;
|
||||
int length, i, literal;
|
||||
DefineLineInformation;
|
||||
Tcl_Obj *objPtr = Tcl_NewObj();
|
||||
|
||||
/*
|
||||
* Push the name of the command we're actually dispatching to as part of
|
||||
* the implementation.
|
||||
*/
|
||||
|
||||
objPtr = Tcl_NewObj();
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, objPtr);
|
||||
bytes = Tcl_GetStringFromObj(objPtr, &length);
|
||||
literal = TclRegisterNewCmdLiteral(envPtr, bytes, length);
|
||||
TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, literal), cmdPtr);
|
||||
TclEmitPush(literal, envPtr);
|
||||
TclDecrRefCount(objPtr);
|
||||
|
||||
/*
|
||||
* Push the words of the command.
|
||||
*/
|
||||
|
||||
tokenPtr = TokenAfter(parsePtr->tokenPtr);
|
||||
for (i=1 ; i<parsePtr->numWords ; i++) {
|
||||
if (envPtr->clNext) {
|
||||
SetLineInformation(i);
|
||||
}
|
||||
if (tokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
|
||||
PushLiteral(envPtr, tokenPtr[1].start, tokenPtr[1].size);
|
||||
} else {
|
||||
CompileTokens(envPtr, tokenPtr, interp);
|
||||
}
|
||||
tokenPtr = TokenAfter(tokenPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the standard dispatch.
|
||||
*/
|
||||
|
||||
if (i <= 255) {
|
||||
TclEmitInstInt1(INST_INVOKE_STK1, i, envPtr);
|
||||
} else {
|
||||
TclEmitInstInt4(INST_INVOKE_STK4, i, envPtr);
|
||||
}
|
||||
TclCompileInvocation(interp, parsePtr->tokenPtr, objPtr,
|
||||
parsePtr->numWords, envPtr);
|
||||
Tcl_DecrRefCount(objPtr);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
+73
-40
@@ -721,7 +721,7 @@ static ExceptionRange * GetExceptRangeForPc(const unsigned char *pc,
|
||||
int catchOnly, ByteCode *codePtr);
|
||||
static const char * GetSrcInfoForPc(const unsigned char *pc,
|
||||
ByteCode *codePtr, int *lengthPtr,
|
||||
const unsigned char **pcBeg);
|
||||
const unsigned char **pcBeg, int *cmdIdxPtr);
|
||||
static Tcl_Obj ** GrowEvaluationStack(ExecEnv *eePtr, int growth,
|
||||
int move);
|
||||
static void IllegalExprOperandType(Tcl_Interp *interp,
|
||||
@@ -879,6 +879,7 @@ TclCreateExecEnv(
|
||||
eePtr->interp = interp;
|
||||
eePtr->callbackPtr = NULL;
|
||||
eePtr->corPtr = NULL;
|
||||
eePtr->stackLevel = 0;
|
||||
eePtr->rewind = 0;
|
||||
|
||||
esPtr->prevPtr = NULL;
|
||||
@@ -1426,17 +1427,12 @@ Tcl_NRExprObj(
|
||||
Tcl_Obj *resultPtr)
|
||||
{
|
||||
ByteCode *codePtr;
|
||||
Tcl_InterpState state = Tcl_SaveInterpState(interp, TCL_OK);
|
||||
|
||||
/* TODO: consider saving whole state? */
|
||||
Tcl_Obj *saveObjPtr = Tcl_GetObjResult(interp);
|
||||
|
||||
Tcl_IncrRefCount(saveObjPtr);
|
||||
|
||||
Tcl_ResetResult(interp);
|
||||
codePtr = CompileExprObj(interp, objPtr);
|
||||
|
||||
/* TODO: Confirm reset not required? */
|
||||
/*Tcl_ResetResult(interp);*/
|
||||
Tcl_NRAddCallback(interp, ExprObjCallback, saveObjPtr, resultPtr,
|
||||
Tcl_NRAddCallback(interp, ExprObjCallback, state, resultPtr,
|
||||
NULL, NULL);
|
||||
return TclNRExecuteByteCode(interp, codePtr);
|
||||
}
|
||||
@@ -1447,14 +1443,15 @@ ExprObjCallback(
|
||||
Tcl_Interp *interp,
|
||||
int result)
|
||||
{
|
||||
Tcl_Obj *saveObjPtr = data[0];
|
||||
Tcl_InterpState state = data[0];
|
||||
Tcl_Obj *resultPtr = data[1];
|
||||
|
||||
if (result == TCL_OK) {
|
||||
TclSetDuplicateObj(resultPtr, Tcl_GetObjResult(interp));
|
||||
Tcl_SetObjResult(interp, saveObjPtr);
|
||||
(void) Tcl_RestoreInterpState(interp, state);
|
||||
} else {
|
||||
Tcl_DiscardInterpState(state);
|
||||
}
|
||||
TclDecrRefCount(saveObjPtr);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2002,7 +1999,6 @@ TclNRExecuteByteCode(
|
||||
bcFramePtr->type = ((codePtr->flags & TCL_BYTECODE_PRECOMPILED)
|
||||
? TCL_LOCATION_PREBC : TCL_LOCATION_BC);
|
||||
bcFramePtr->level = (iPtr->cmdFramePtr ? iPtr->cmdFramePtr->level+1 : 1);
|
||||
bcFramePtr->numLevels = iPtr->numLevels;
|
||||
bcFramePtr->framePtr = iPtr->framePtr;
|
||||
bcFramePtr->nextPtr = iPtr->cmdFramePtr;
|
||||
bcFramePtr->nline = 0;
|
||||
@@ -2010,8 +2006,9 @@ TclNRExecuteByteCode(
|
||||
bcFramePtr->litarg = NULL;
|
||||
bcFramePtr->data.tebc.codePtr = codePtr;
|
||||
bcFramePtr->data.tebc.pc = NULL;
|
||||
bcFramePtr->cmd.str.cmd = NULL;
|
||||
bcFramePtr->cmd.str.len = 0;
|
||||
bcFramePtr->cmdObj = NULL;
|
||||
bcFramePtr->cmd = NULL;
|
||||
bcFramePtr->len = 0;
|
||||
|
||||
#ifdef TCL_COMPILE_STATS
|
||||
iPtr->stats.numExecutions++;
|
||||
@@ -2134,6 +2131,11 @@ TEBCresume(
|
||||
result = TCL_ERROR;
|
||||
}
|
||||
NRE_ASSERT(iPtr->cmdFramePtr == bcFramePtr);
|
||||
if (bcFramePtr->cmdObj) {
|
||||
Tcl_DecrRefCount(bcFramePtr->cmdObj);
|
||||
bcFramePtr->cmdObj = NULL;
|
||||
bcFramePtr->cmd = NULL;
|
||||
}
|
||||
iPtr->cmdFramePtr = bcFramePtr->nextPtr;
|
||||
if (iPtr->flags & INTERP_DEBUG_FRAME) {
|
||||
TclArgumentBCRelease((Tcl_Interp *) iPtr, bcFramePtr);
|
||||
@@ -2435,8 +2437,11 @@ TEBCresume(
|
||||
iPtr->cmdFramePtr = bcFramePtr;
|
||||
|
||||
if (iPtr->flags & INTERP_DEBUG_FRAME) {
|
||||
TclArgumentBCEnter((Tcl_Interp *) iPtr, objv, objc,
|
||||
codePtr, bcFramePtr, pc - codePtr->codeStart);
|
||||
int cmd;
|
||||
if (GetSrcInfoForPc(pc, codePtr, NULL, NULL, &cmd)) {
|
||||
TclArgumentBCEnter((Tcl_Interp *) iPtr, objv, objc,
|
||||
codePtr, bcFramePtr, cmd, pc - codePtr->codeStart);
|
||||
}
|
||||
}
|
||||
|
||||
pc++;
|
||||
@@ -2889,8 +2894,11 @@ TEBCresume(
|
||||
iPtr->cmdFramePtr = bcFramePtr;
|
||||
|
||||
if (iPtr->flags & INTERP_DEBUG_FRAME) {
|
||||
TclArgumentBCEnter((Tcl_Interp *) iPtr, objv, objc,
|
||||
codePtr, bcFramePtr, pc - codePtr->codeStart);
|
||||
int cmd;
|
||||
if (GetSrcInfoForPc(pc, codePtr, NULL, NULL, &cmd)) {
|
||||
TclArgumentBCEnter((Tcl_Interp *) iPtr, objv, objc,
|
||||
codePtr, bcFramePtr, cmd, pc - codePtr->codeStart);
|
||||
}
|
||||
}
|
||||
|
||||
DECACHE_STACK_INFO();
|
||||
@@ -2898,7 +2906,7 @@ TEBCresume(
|
||||
pc += pcAdjustment;
|
||||
TEBC_YIELD();
|
||||
return TclNREvalObjv(interp, objc, objv,
|
||||
TCL_EVAL_NOERR, NULL);
|
||||
TCL_EVAL_NOERR | TCL_EVAL_SOURCE_IN_FRAME, NULL);
|
||||
|
||||
#if TCL_SUPPORT_84_BYTECODE
|
||||
case INST_CALL_BUILTIN_FUNC1:
|
||||
@@ -3035,8 +3043,11 @@ TEBCresume(
|
||||
bcFramePtr->data.tebc.pc = (char *) pc;
|
||||
iPtr->cmdFramePtr = bcFramePtr;
|
||||
if (iPtr->flags & INTERP_DEBUG_FRAME) {
|
||||
TclArgumentBCEnter((Tcl_Interp *) iPtr, objv, objc,
|
||||
codePtr, bcFramePtr, pc - codePtr->codeStart);
|
||||
int cmd;
|
||||
if (GetSrcInfoForPc(pc, codePtr, NULL, NULL, &cmd)) {
|
||||
TclArgumentBCEnter((Tcl_Interp *) iPtr, objv, objc,
|
||||
codePtr, bcFramePtr, cmd, pc - codePtr->codeStart);
|
||||
}
|
||||
}
|
||||
iPtr->ensembleRewrite.sourceObjs = objv;
|
||||
iPtr->ensembleRewrite.numRemovedObjs = opnd;
|
||||
@@ -6971,7 +6982,7 @@ TEBCresume(
|
||||
if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) {
|
||||
const unsigned char *pcBeg;
|
||||
|
||||
bytes = GetSrcInfoForPc(pc, codePtr, &length, &pcBeg);
|
||||
bytes = GetSrcInfoForPc(pc, codePtr, &length, &pcBeg, NULL);
|
||||
DECACHE_STACK_INFO();
|
||||
TclLogCommandInfo(interp, codePtr->source, bytes,
|
||||
bytes ? length : 0, pcBeg, tosPtr);
|
||||
@@ -7153,7 +7164,7 @@ TEBCresume(
|
||||
}
|
||||
|
||||
codePtr->flags |= TCL_BYTECODE_RECOMPILE;
|
||||
bytes = GetSrcInfoForPc(pc, codePtr, &length, NULL);
|
||||
bytes = GetSrcInfoForPc(pc, codePtr, &length, NULL, NULL);
|
||||
opnd = TclGetUInt4AtPtr(pc+1);
|
||||
pc += (opnd-1);
|
||||
PUSH_OBJECT(Tcl_NewStringObj(bytes, length));
|
||||
@@ -8646,7 +8657,7 @@ ValidatePcAndStackTop(
|
||||
if (checkStack &&
|
||||
((stackTop < 0) || (stackTop > stackUpperBound))) {
|
||||
int numChars;
|
||||
const char *cmd = GetSrcInfoForPc(pc, codePtr, &numChars, NULL);
|
||||
const char *cmd = GetSrcInfoForPc(pc, codePtr, &numChars, NULL, NULL);
|
||||
|
||||
fprintf(stderr, "\nBad stack top %d at pc %u in TclNRExecuteByteCode (min 0, max %i)",
|
||||
stackTop, relativePc, stackUpperBound);
|
||||
@@ -8730,7 +8741,7 @@ IllegalExprOperandType(
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TclGetSrcInfoForPc, GetSrcInfoForPc, TclGetSrcInfoForCmd --
|
||||
* TclGetSrcInfoForPc, GetSrcInfoForPc, TclGetSourceFromFrame --
|
||||
*
|
||||
* Given a program counter value, finds the closest command in the
|
||||
* bytecode code unit's CmdLocation array and returns information about
|
||||
@@ -8751,16 +8762,26 @@ IllegalExprOperandType(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const char *
|
||||
TclGetSrcInfoForCmd(
|
||||
Interp *iPtr,
|
||||
int *lenPtr)
|
||||
Tcl_Obj *
|
||||
TclGetSourceFromFrame(
|
||||
CmdFrame *cfPtr,
|
||||
int objc,
|
||||
Tcl_Obj *const objv[])
|
||||
{
|
||||
CmdFrame *cfPtr = iPtr->cmdFramePtr;
|
||||
ByteCode *codePtr = (ByteCode *) cfPtr->data.tebc.codePtr;
|
||||
if (cfPtr == NULL) {
|
||||
return Tcl_NewListObj(objc, objv);
|
||||
}
|
||||
if (cfPtr->cmdObj == NULL) {
|
||||
if (cfPtr->cmd == NULL) {
|
||||
ByteCode *codePtr = (ByteCode *) cfPtr->data.tebc.codePtr;
|
||||
|
||||
return GetSrcInfoForPc((unsigned char *) cfPtr->data.tebc.pc,
|
||||
codePtr, lenPtr, NULL);
|
||||
cfPtr->cmd = GetSrcInfoForPc((unsigned char *)
|
||||
cfPtr->data.tebc.pc, codePtr, &cfPtr->len, NULL, NULL);
|
||||
}
|
||||
cfPtr->cmdObj = Tcl_NewStringObj(cfPtr->cmd, cfPtr->len);
|
||||
Tcl_IncrRefCount(cfPtr->cmdObj);
|
||||
}
|
||||
return cfPtr->cmdObj;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -8769,13 +8790,16 @@ TclGetSrcInfoForPc(
|
||||
{
|
||||
ByteCode *codePtr = (ByteCode *) cfPtr->data.tebc.codePtr;
|
||||
|
||||
if (cfPtr->cmd.str.cmd == NULL) {
|
||||
cfPtr->cmd.str.cmd = GetSrcInfoForPc(
|
||||
assert(cfPtr->type == TCL_LOCATION_BC);
|
||||
|
||||
if (cfPtr->cmd == NULL) {
|
||||
|
||||
cfPtr->cmd = GetSrcInfoForPc(
|
||||
(unsigned char *) cfPtr->data.tebc.pc, codePtr,
|
||||
&cfPtr->cmd.str.len, NULL);
|
||||
&cfPtr->len, NULL, NULL);
|
||||
}
|
||||
|
||||
if (cfPtr->cmd.str.cmd != NULL) {
|
||||
if (cfPtr->cmd != NULL) {
|
||||
/*
|
||||
* We now have the command. We can get the srcOffset back and from
|
||||
* there find the list of word locations for this command.
|
||||
@@ -8792,7 +8816,7 @@ TclGetSrcInfoForPc(
|
||||
return;
|
||||
}
|
||||
|
||||
srcOffset = cfPtr->cmd.str.cmd - codePtr->source;
|
||||
srcOffset = cfPtr->cmd - codePtr->source;
|
||||
eclPtr = Tcl_GetHashValue(hePtr);
|
||||
|
||||
for (i=0; i < eclPtr->nuloc; i++) {
|
||||
@@ -8832,9 +8856,12 @@ GetSrcInfoForPc(
|
||||
int *lengthPtr, /* If non-NULL, the location where the length
|
||||
* of the command's source should be stored.
|
||||
* If NULL, no length is stored. */
|
||||
const unsigned char **pcBeg)/* If non-NULL, the bytecode location
|
||||
const unsigned char **pcBeg,/* If non-NULL, the bytecode location
|
||||
* where the current instruction starts.
|
||||
* If NULL; no pointer is stored. */
|
||||
int *cmdIdxPtr) /* If non-NULL, the location where the index
|
||||
* of the command containing the pc should
|
||||
* be stored. */
|
||||
{
|
||||
register int pcOffset = (pc - codePtr->codeStart);
|
||||
int numCmds = codePtr->numCommands;
|
||||
@@ -8844,6 +8871,7 @@ GetSrcInfoForPc(
|
||||
int bestDist = INT_MAX; /* Distance of pc to best cmd's start pc. */
|
||||
int bestSrcOffset = -1; /* Initialized to avoid compiler warning. */
|
||||
int bestSrcLength = -1; /* Initialized to avoid compiler warning. */
|
||||
int bestCmdIdx = -1;
|
||||
|
||||
if ((pcOffset < 0) || (pcOffset >= codePtr->numCodeBytes)) {
|
||||
if (pcBeg != NULL) *pcBeg = NULL;
|
||||
@@ -8911,6 +8939,7 @@ GetSrcInfoForPc(
|
||||
bestDist = dist;
|
||||
bestSrcOffset = srcOffset;
|
||||
bestSrcLength = srcLen;
|
||||
bestCmdIdx = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8940,6 +8969,10 @@ GetSrcInfoForPc(
|
||||
*lengthPtr = bestSrcLength;
|
||||
}
|
||||
|
||||
if (cmdIdxPtr != NULL) {
|
||||
*cmdIdxPtr = bestCmdIdx;
|
||||
}
|
||||
|
||||
return (codePtr->source + bestSrcOffset);
|
||||
}
|
||||
|
||||
|
||||
+31
-41
@@ -1175,29 +1175,27 @@ typedef struct CmdFrame {
|
||||
*
|
||||
* EXECUTION CONTEXTS and usage of CmdFrame
|
||||
*
|
||||
* Field TEBC EvalEx EvalObjEx
|
||||
* ======= ==== ====== =========
|
||||
* level yes yes yes
|
||||
* type BC/PREBC SRC/EVAL EVAL_LIST
|
||||
* line0 yes yes yes
|
||||
* framePtr yes yes yes
|
||||
* ======= ==== ====== =========
|
||||
* Field TEBC EvalEx
|
||||
* ======= ==== ======
|
||||
* level yes yes
|
||||
* type BC/PREBC SRC/EVAL
|
||||
* line0 yes yes
|
||||
* framePtr yes yes
|
||||
* ======= ==== ======
|
||||
*
|
||||
* ======= ==== ====== ========= union data
|
||||
* line1 - yes -
|
||||
* line3 - yes -
|
||||
* path - yes -
|
||||
* ------- ---- ------ ---------
|
||||
* codePtr yes - -
|
||||
* pc yes - -
|
||||
* ======= ==== ====== =========
|
||||
* ======= ==== ========= union data
|
||||
* line1 - yes
|
||||
* line3 - yes
|
||||
* path - yes
|
||||
* ------- ---- ------
|
||||
* codePtr yes -
|
||||
* pc yes -
|
||||
* ======= ==== ======
|
||||
*
|
||||
* ======= ==== ====== ========= | union cmd
|
||||
* listPtr - - yes |
|
||||
* ------- ---- ------ --------- |
|
||||
* cmd yes yes - |
|
||||
* cmdlen yes yes - |
|
||||
* ------- ---- ------ --------- |
|
||||
* ======= ==== ========= union cmd
|
||||
* str.cmd yes yes
|
||||
* str.len yes yes
|
||||
* ------- ---- ------
|
||||
*/
|
||||
|
||||
union {
|
||||
@@ -1210,15 +1208,9 @@ typedef struct CmdFrame {
|
||||
const char *pc; /* ... and instruction pointer. */
|
||||
} tebc;
|
||||
} data;
|
||||
union {
|
||||
struct {
|
||||
const char *cmd; /* The executed command, if possible... */
|
||||
int len; /* ... and its length. */
|
||||
} str;
|
||||
Tcl_Obj *listPtr; /* Tcl_EvalObjEx, cmd list. */
|
||||
} cmd;
|
||||
int numLevels; /* Value of interp's numLevels when the frame
|
||||
* was pushed. */
|
||||
Tcl_Obj *cmdObj;
|
||||
const char *cmd; /* The executed command, if possible... */
|
||||
int len; /* ... and its length. */
|
||||
const struct CFWordBC *litarg;
|
||||
/* Link to set of literal arguments which have
|
||||
* ben pushed on the lineLABCPtr stack by
|
||||
@@ -1282,8 +1274,6 @@ typedef struct ContLineLoc {
|
||||
* location data referenced via the 'baseLocPtr'.
|
||||
*
|
||||
* TCL_LOCATION_EVAL : Frame is for a script evaluated by EvalEx.
|
||||
* TCL_LOCATION_EVAL_LIST : Frame is for a script evaluated by the list
|
||||
* optimization path of EvalObjEx.
|
||||
* TCL_LOCATION_BC : Frame is for bytecode.
|
||||
* TCL_LOCATION_PREBC : Frame is for precompiled bytecode.
|
||||
* TCL_LOCATION_SOURCE : Frame is for a script evaluated by EvalEx, from a
|
||||
@@ -1295,8 +1285,6 @@ typedef struct ContLineLoc {
|
||||
*/
|
||||
|
||||
#define TCL_LOCATION_EVAL (0) /* Location in a dynamic eval script. */
|
||||
#define TCL_LOCATION_EVAL_LIST (1) /* Location in a dynamic eval script,
|
||||
* list-path. */
|
||||
#define TCL_LOCATION_BC (2) /* Location in byte code. */
|
||||
#define TCL_LOCATION_PREBC (3) /* Location in precompiled byte code, no
|
||||
* location. */
|
||||
@@ -1450,7 +1438,7 @@ typedef struct CoroutineData {
|
||||
CorContext caller;
|
||||
CorContext running;
|
||||
Tcl_HashTable *lineLABCPtr; /* See Interp.lineLABCPtr */
|
||||
void *stackLevel;
|
||||
int stackLevel;
|
||||
int auxNumLevels; /* While the coroutine is running the
|
||||
* numLevels of the create/resume command is
|
||||
* stored here; for suspended coroutines it
|
||||
@@ -1468,11 +1456,12 @@ typedef struct ExecEnv {
|
||||
struct NRE_callback *callbackPtr;
|
||||
/* Top callback in NRE's stack. */
|
||||
struct CoroutineData *corPtr;
|
||||
int stackLevel;
|
||||
int rewind;
|
||||
} ExecEnv;
|
||||
|
||||
#define COR_IS_SUSPENDED(corPtr) \
|
||||
((corPtr)->stackLevel == NULL)
|
||||
((corPtr)->stackLevel == -1)
|
||||
|
||||
/*
|
||||
* The definitions for the LiteralTable and LiteralEntry structures. Each
|
||||
@@ -2210,9 +2199,9 @@ typedef struct Interp {
|
||||
* other than these should be turned into errors.
|
||||
*/
|
||||
|
||||
#define TCL_ALLOW_EXCEPTIONS 4
|
||||
#define TCL_EVAL_FILE 2
|
||||
#define TCL_EVAL_CTX 8
|
||||
#define TCL_ALLOW_EXCEPTIONS 0x04
|
||||
#define TCL_EVAL_FILE 0x02
|
||||
#define TCL_EVAL_SOURCE_IN_FRAME 0x10
|
||||
|
||||
/*
|
||||
* Flag bits for Interp structures:
|
||||
@@ -2828,7 +2817,7 @@ MODULE_SCOPE void TclArgumentRelease(Tcl_Interp *interp,
|
||||
Tcl_Obj *objv[], int objc);
|
||||
MODULE_SCOPE void TclArgumentBCEnter(Tcl_Interp *interp,
|
||||
Tcl_Obj *objv[], int objc,
|
||||
void *codePtr, CmdFrame *cfPtr, int pc);
|
||||
void *codePtr, CmdFrame *cfPtr, int cmd, int pc);
|
||||
MODULE_SCOPE void TclArgumentBCRelease(Tcl_Interp *interp,
|
||||
CmdFrame *cfPtr);
|
||||
MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj,
|
||||
@@ -2919,7 +2908,8 @@ MODULE_SCOPE int TclGetOpenModeEx(Tcl_Interp *interp,
|
||||
const char *modeString, int *seekFlagPtr,
|
||||
int *binaryPtr);
|
||||
MODULE_SCOPE Tcl_Obj * TclGetProcessGlobalValue(ProcessGlobalValue *pgvPtr);
|
||||
MODULE_SCOPE const char *TclGetSrcInfoForCmd(Interp *iPtr, int *lenPtr);
|
||||
MODULE_SCOPE Tcl_Obj * TclGetSourceFromFrame(CmdFrame *cfPtr, int objc,
|
||||
Tcl_Obj *const objv[]);
|
||||
MODULE_SCOPE int TclGlob(Tcl_Interp *interp, char *pattern,
|
||||
Tcl_Obj *unquotedPrefix, int globFlags,
|
||||
Tcl_GlobTypeData *types);
|
||||
|
||||
@@ -88,7 +88,7 @@ TclOO_Class_Constructor(
|
||||
Tcl_Obj *const *objv)
|
||||
{
|
||||
Object *oPtr = (Object *) Tcl_ObjectContextObject(context);
|
||||
Tcl_Obj *invoke[3];
|
||||
Tcl_Obj **invoke;
|
||||
|
||||
if (objc-1 > Tcl_ObjectContextSkippedArgs(context)) {
|
||||
Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv,
|
||||
@@ -102,6 +102,7 @@ TclOO_Class_Constructor(
|
||||
* Delegate to [oo::define] to do the work.
|
||||
*/
|
||||
|
||||
invoke = ckalloc(3 * sizeof(Tcl_Obj *));
|
||||
invoke[0] = oPtr->fPtr->defineName;
|
||||
invoke[1] = TclOOObjectName(interp, oPtr);
|
||||
invoke[2] = objv[objc-1];
|
||||
@@ -115,7 +116,7 @@ TclOO_Class_Constructor(
|
||||
Tcl_IncrRefCount(invoke[1]);
|
||||
Tcl_IncrRefCount(invoke[2]);
|
||||
TclNRAddCallback(interp, DecrRefsPostClassConstructor,
|
||||
invoke[0], invoke[1], invoke[2], NULL);
|
||||
invoke, NULL, NULL, NULL);
|
||||
|
||||
/*
|
||||
* Tricky point: do not want the extra reported level in the Tcl stack
|
||||
@@ -131,9 +132,12 @@ DecrRefsPostClassConstructor(
|
||||
Tcl_Interp *interp,
|
||||
int result)
|
||||
{
|
||||
TclDecrRefCount((Tcl_Obj *) data[0]);
|
||||
TclDecrRefCount((Tcl_Obj *) data[1]);
|
||||
TclDecrRefCount((Tcl_Obj *) data[2]);
|
||||
Tcl_Obj **invoke = data[0];
|
||||
|
||||
TclDecrRefCount(invoke[0]);
|
||||
TclDecrRefCount(invoke[1]);
|
||||
TclDecrRefCount(invoke[2]);
|
||||
ckfree(invoke);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+31
-18
@@ -2206,29 +2206,42 @@ ClassSuperSet(
|
||||
|
||||
/*
|
||||
* Parse the arguments to get the class to use as superclasses.
|
||||
*
|
||||
* Note that zero classes is special, as it is equivalent to just the
|
||||
* class of objects. [Bug 9d61624b3d]
|
||||
*/
|
||||
|
||||
for (i=0 ; i<superc ; i++) {
|
||||
superclasses[i] = GetClassInOuterContext(interp, superv[i],
|
||||
"only a class can be a superclass");
|
||||
if (superclasses[i] == NULL) {
|
||||
goto failedAfterAlloc;
|
||||
if (superc == 0) {
|
||||
superclasses = ckrealloc(superclasses, sizeof(Class *));
|
||||
superclasses[0] = oPtr->fPtr->objectCls;
|
||||
superc = 1;
|
||||
if (TclOOIsReachable(oPtr->fPtr->classCls, oPtr->classPtr)) {
|
||||
superclasses[0] = oPtr->fPtr->classCls;
|
||||
}
|
||||
for (j=0 ; j<i ; j++) {
|
||||
if (superclasses[j] == superclasses[i]) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"class should only be a direct superclass once", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "OO", "REPETITIOUS", NULL);
|
||||
} else {
|
||||
for (i=0 ; i<superc ; i++) {
|
||||
superclasses[i] = GetClassInOuterContext(interp, superv[i],
|
||||
"only a class can be a superclass");
|
||||
if (superclasses[i] == NULL) {
|
||||
goto failedAfterAlloc;
|
||||
}
|
||||
}
|
||||
if (TclOOIsReachable(oPtr->classPtr, superclasses[i])) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"attempt to form circular dependency graph", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "OO", "CIRCULARITY", NULL);
|
||||
failedAfterAlloc:
|
||||
ckfree((char *) superclasses);
|
||||
return TCL_ERROR;
|
||||
for (j=0 ; j<i ; j++) {
|
||||
if (superclasses[j] == superclasses[i]) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"class should only be a direct superclass once",
|
||||
-1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "OO", "REPETITIOUS",NULL);
|
||||
goto failedAfterAlloc;
|
||||
}
|
||||
}
|
||||
if (TclOOIsReachable(oPtr->classPtr, superclasses[i])) {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(
|
||||
"attempt to form circular dependency graph", -1));
|
||||
Tcl_SetErrorCode(interp, "TCL", "OO", "CIRCULARITY", NULL);
|
||||
failedAfterAlloc:
|
||||
ckfree((char *) superclasses);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,12 +122,6 @@ typedef struct ForwardMethod {
|
||||
Tcl_Obj *prefixObj; /* The list of values to use to replace the
|
||||
* object and method name with. Will be a
|
||||
* non-empty list. */
|
||||
int fullyQualified; /* If 1, the command name is fully qualified
|
||||
* and we should let the default Tcl mechanism
|
||||
* handle the command lookup because it is
|
||||
* more efficient. If 0, we need to do a
|
||||
* specialized lookup based on the current
|
||||
* object's namespace. */
|
||||
} ForwardMethod;
|
||||
|
||||
/*
|
||||
|
||||
+7
-16
@@ -513,8 +513,8 @@ TclOOMakeProcInstanceMethod(
|
||||
cfPtr->data.eval.path = context.data.eval.path;
|
||||
Tcl_IncrRefCount(cfPtr->data.eval.path);
|
||||
|
||||
cfPtr->cmd.str.cmd = NULL;
|
||||
cfPtr->cmd.str.len = 0;
|
||||
cfPtr->cmd = NULL;
|
||||
cfPtr->len = 0;
|
||||
|
||||
hPtr = Tcl_CreateHashEntry(iPtr->linePBodyPtr,
|
||||
(char *) procPtr, &isNew);
|
||||
@@ -626,8 +626,8 @@ TclOOMakeProcMethod(
|
||||
cfPtr->data.eval.path = context.data.eval.path;
|
||||
Tcl_IncrRefCount(cfPtr->data.eval.path);
|
||||
|
||||
cfPtr->cmd.str.cmd = NULL;
|
||||
cfPtr->cmd.str.len = 0;
|
||||
cfPtr->cmd = NULL;
|
||||
cfPtr->len = 0;
|
||||
|
||||
hPtr = Tcl_CreateHashEntry(iPtr->linePBodyPtr,
|
||||
(char *) procPtr, &isNew);
|
||||
@@ -1338,7 +1338,6 @@ TclOONewForwardInstanceMethod(
|
||||
fmPtr = ckalloc(sizeof(ForwardMethod));
|
||||
fmPtr->prefixObj = prefixObj;
|
||||
Tcl_ListObjIndex(interp, prefixObj, 0, &cmdObj);
|
||||
fmPtr->fullyQualified = (strncmp(TclGetString(cmdObj), "::", 2) == 0);
|
||||
Tcl_IncrRefCount(prefixObj);
|
||||
return (Method *) Tcl_NewInstanceMethod(interp, (Tcl_Object) oPtr,
|
||||
nameObj, flags, &fwdMethodType, fmPtr);
|
||||
@@ -1380,7 +1379,6 @@ TclOONewForwardMethod(
|
||||
fmPtr = ckalloc(sizeof(ForwardMethod));
|
||||
fmPtr->prefixObj = prefixObj;
|
||||
Tcl_ListObjIndex(interp, prefixObj, 0, &cmdObj);
|
||||
fmPtr->fullyQualified = (strncmp(TclGetString(cmdObj), "::", 2) == 0);
|
||||
Tcl_IncrRefCount(prefixObj);
|
||||
return (Method *) Tcl_NewMethod(interp, (Tcl_Class) clsPtr, nameObj,
|
||||
flags, &fwdMethodType, fmPtr);
|
||||
@@ -1409,7 +1407,6 @@ InvokeForwardMethod(
|
||||
ForwardMethod *fmPtr = clientData;
|
||||
Tcl_Obj **argObjs, **prefixObjs;
|
||||
int numPrefixes, len, skip = contextPtr->skip;
|
||||
Command *cmdPtr;
|
||||
|
||||
/*
|
||||
* Build the real list of arguments to use. Note that we know that the
|
||||
@@ -1421,15 +1418,10 @@ InvokeForwardMethod(
|
||||
Tcl_ListObjGetElements(NULL, fmPtr->prefixObj, &numPrefixes, &prefixObjs);
|
||||
argObjs = InitEnsembleRewrite(interp, objc, objv, skip,
|
||||
numPrefixes, prefixObjs, &len);
|
||||
|
||||
if (fmPtr->fullyQualified) {
|
||||
cmdPtr = NULL;
|
||||
} else {
|
||||
cmdPtr = (Command *) Tcl_FindCommand(interp, TclGetString(argObjs[0]),
|
||||
contextPtr->oPtr->namespacePtr, 0 /* normal lookup */);
|
||||
}
|
||||
Tcl_NRAddCallback(interp, FinalizeForwardCall, argObjs, NULL, NULL, NULL);
|
||||
return TclNREvalObjv(interp, len, argObjs, TCL_EVAL_INVOKE, cmdPtr);
|
||||
((Interp *)interp)->lookupNsPtr
|
||||
= (Namespace *) contextPtr->oPtr->namespacePtr;
|
||||
return TclNREvalObjv(interp, len, argObjs, TCL_EVAL_INVOKE, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1474,7 +1466,6 @@ CloneForwardMethod(
|
||||
ForwardMethod *fm2Ptr = ckalloc(sizeof(ForwardMethod));
|
||||
|
||||
fm2Ptr->prefixObj = fmPtr->prefixObj;
|
||||
fm2Ptr->fullyQualified = fmPtr->fullyQualified;
|
||||
Tcl_IncrRefCount(fm2Ptr->prefixObj);
|
||||
*newClientData = fm2Ptr;
|
||||
return TCL_OK;
|
||||
|
||||
+3
-35
@@ -97,7 +97,6 @@ typedef struct ThreadSpecificData {
|
||||
|
||||
static Tcl_ThreadDataKey dataKey;
|
||||
|
||||
static void ContLineLocFree(char *clientData);
|
||||
static void TclThreadFinalizeContLines(ClientData clientData);
|
||||
static ThreadSpecificData *TclGetContLineTable(void);
|
||||
|
||||
@@ -805,14 +804,7 @@ TclThreadFinalizeContLines(
|
||||
|
||||
for (hPtr = Tcl_FirstHashEntry(tsdPtr->lineCLPtr, &hSearch);
|
||||
hPtr != NULL; hPtr = Tcl_NextHashEntry(&hSearch)) {
|
||||
/*
|
||||
* We are not using Tcl_EventuallyFree (as in TclFreeObj()) because
|
||||
* here we can be sure that the compiler will not hold references to
|
||||
* the data in the hashtable, and using TEF might bork the
|
||||
* finalization sequence.
|
||||
*/
|
||||
|
||||
ContLineLocFree(Tcl_GetHashValue(hPtr));
|
||||
ckfree(Tcl_GetHashValue(hPtr));
|
||||
Tcl_DeleteHashEntry(hPtr);
|
||||
}
|
||||
Tcl_DeleteHashTable(tsdPtr->lineCLPtr);
|
||||
@@ -820,30 +812,6 @@ TclThreadFinalizeContLines(
|
||||
tsdPtr->lineCLPtr = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* ContLineLocFree --
|
||||
*
|
||||
* The freProc for continuation line location tables.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side effects:
|
||||
* Releases memory.
|
||||
*
|
||||
* TIP #280
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
ContLineLocFree(
|
||||
char *clientData)
|
||||
{
|
||||
ckfree(clientData);
|
||||
}
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------
|
||||
*
|
||||
@@ -1405,7 +1373,7 @@ TclFreeObj(
|
||||
if (tsdPtr->lineCLPtr) {
|
||||
hPtr = Tcl_FindHashEntry(tsdPtr->lineCLPtr, objPtr);
|
||||
if (hPtr) {
|
||||
Tcl_EventuallyFree(Tcl_GetHashValue(hPtr), ContLineLocFree);
|
||||
ckfree(Tcl_GetHashValue(hPtr));
|
||||
Tcl_DeleteHashEntry(hPtr);
|
||||
}
|
||||
}
|
||||
@@ -1496,7 +1464,7 @@ TclFreeObj(
|
||||
if (tsdPtr->lineCLPtr) {
|
||||
hPtr = Tcl_FindHashEntry(tsdPtr->lineCLPtr, objPtr);
|
||||
if (hPtr) {
|
||||
Tcl_EventuallyFree(Tcl_GetHashValue(hPtr), ContLineLocFree);
|
||||
ckfree(Tcl_GetHashValue(hPtr));
|
||||
Tcl_DeleteHashEntry(hPtr);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-8
@@ -13,6 +13,7 @@
|
||||
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include "tclInt.h"
|
||||
#include "tclParse.h"
|
||||
|
||||
@@ -1567,6 +1568,7 @@ Tcl_ParseVar(
|
||||
|
||||
code = TclSubstTokens(interp, parsePtr->tokenPtr, parsePtr->numTokens,
|
||||
NULL, 1, NULL, NULL);
|
||||
Tcl_FreeParse(parsePtr);
|
||||
TclStackFree(interp, parsePtr);
|
||||
if (code != TCL_OK) {
|
||||
return NULL;
|
||||
@@ -1577,16 +1579,13 @@ Tcl_ParseVar(
|
||||
* At this point we should have an object containing the value of a
|
||||
* variable. Just return the string from that object.
|
||||
*
|
||||
* This should have returned the object for the user to manage, but
|
||||
* instead we have some weak reference to the string value in the object,
|
||||
* which is why we make sure the object exists after resetting the result.
|
||||
* This isn't ideal, but it's the best we can do with the current
|
||||
* documented interface. -- hobbs
|
||||
* Since TclSubstTokens above returned TCL_OK, we know that objPtr
|
||||
* is shared. It is in both the interp result and the value of the
|
||||
* variable. Returning the string relies on that to be true.
|
||||
*/
|
||||
|
||||
if (!Tcl_IsShared(objPtr)) {
|
||||
Tcl_IncrRefCount(objPtr);
|
||||
}
|
||||
assert( Tcl_IsShared(objPtr) );
|
||||
|
||||
Tcl_ResetResult(interp);
|
||||
return TclGetString(objPtr);
|
||||
}
|
||||
|
||||
+4
-4
@@ -271,8 +271,8 @@ Tcl_ProcObjCmd(
|
||||
cfPtr->data.eval.path = contextPtr->data.eval.path;
|
||||
Tcl_IncrRefCount(cfPtr->data.eval.path);
|
||||
|
||||
cfPtr->cmd.str.cmd = NULL;
|
||||
cfPtr->cmd.str.len = 0;
|
||||
cfPtr->cmd = NULL;
|
||||
cfPtr->len = 0;
|
||||
|
||||
hePtr = Tcl_CreateHashEntry(iPtr->linePBodyPtr,
|
||||
procPtr, &isNew);
|
||||
@@ -2595,8 +2595,8 @@ SetLambdaFromAny(
|
||||
cfPtr->data.eval.path = contextPtr->data.eval.path;
|
||||
Tcl_IncrRefCount(cfPtr->data.eval.path);
|
||||
|
||||
cfPtr->cmd.str.cmd = NULL;
|
||||
cfPtr->cmd.str.len = 0;
|
||||
cfPtr->cmd = NULL;
|
||||
cfPtr->len = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+3
-3
@@ -1555,14 +1555,14 @@ DelCallbackProc(
|
||||
*
|
||||
* TestdelCmd --
|
||||
*
|
||||
* This procedure implements the "testdcall" command. It is used
|
||||
* to test Tcl_CallWhenDeleted.
|
||||
* This procedure implements the "testdel" command. It is used
|
||||
* to test calling of command deletion callbacks.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* Creates and deletes interpreters.
|
||||
* Creates a command.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
+2
-2
@@ -1555,10 +1555,10 @@ Tcl_UniCharIsSpace(
|
||||
*/
|
||||
|
||||
if (((Tcl_UniChar) ch) < ((Tcl_UniChar) 0x80)) {
|
||||
return TclIsSpaceProc(ch);
|
||||
return TclIsSpaceProc((char) ch);
|
||||
} else if ((Tcl_UniChar) ch == 0x0085 || (Tcl_UniChar) ch == 0x180e
|
||||
|| (Tcl_UniChar) ch == 0x200b || (Tcl_UniChar) ch == 0x2060
|
||||
|| (Tcl_UniChar) ch == 0xfeff) {
|
||||
|| (Tcl_UniChar) ch == 0x202f || (Tcl_UniChar) ch == 0xfeff) {
|
||||
return 1;
|
||||
} else {
|
||||
return ((SPACE_BITS >> GetCategory(ch)) & 1);
|
||||
|
||||
@@ -617,4 +617,18 @@ auto_mkindex_parser::command namespace {op args} {
|
||||
}
|
||||
}
|
||||
|
||||
# AUTO MKINDEX: oo::class create name ?definition?
|
||||
# Adds an entry to the auto index list for the given class name.
|
||||
foreach cmd {oo::class class} {
|
||||
auto_mkindex_parser::command $cmd {ecmd name {body ""}} {
|
||||
if {$cmd eq "create"} {
|
||||
variable index
|
||||
variable scriptFile
|
||||
append index [format "set %s \[list source \[%s]]\n" \
|
||||
[list auto_index([fullname $name])] \
|
||||
[list file join $dir {*}[file split $scriptFile]]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ proc ::tcl::clock::Initialize {} {
|
||||
{-10800 0 3600 0 2 0 2 2 0 0 0 0 10 0 3 2 0 0 0} :America/Sao_Paulo
|
||||
{-10800 0 3600 0 10 0 5 2 0 0 0 0 4 0 1 2 0 0 0} :America/Godthab
|
||||
{-10800 0 3600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} :America/Buenos_Aires
|
||||
{-10800 0 3600 0 2 0 5 2 0 0 0 0 11 0 1 2 0 0 0} :America/Brasilia
|
||||
{-10800 0 3600 0 2 0 5 2 0 0 0 0 11 0 1 2 0 0 0} :America/Bahia
|
||||
{-10800 0 3600 0 3 0 2 2 0 0 0 0 10 0 1 2 0 0 0} :America/Montevideo
|
||||
{-7200 0 3600 0 9 0 5 2 0 0 0 0 3 0 5 2 0 0 0} :America/Noronha
|
||||
{-3600 0 3600 0 10 0 5 3 0 0 0 0 3 0 5 2 0 0 0} :Atlantic/Azores
|
||||
|
||||
+1
-2
@@ -175,8 +175,7 @@ test assemble-4.1 {syntax error} {
|
||||
-match glob
|
||||
-result {1 {extra characters after close-brace} {extra characters after close-brace
|
||||
while executing
|
||||
"{}extra
|
||||
"
|
||||
"{}e"
|
||||
("assemble" body, line 2)*}}
|
||||
}
|
||||
test assemble-4.2 {null command} {
|
||||
|
||||
@@ -609,6 +609,30 @@ test coroutine-7.3 {yielding between coroutines} -body {
|
||||
} -cleanup {
|
||||
catch {rename juggler ""}
|
||||
} -result {{{a b c d e} ::j1 {a b c d} ::j2 {a b c} ::j3 {a b} ::j1 a ::j2} {} {} {}}
|
||||
|
||||
test coroutine-7.4 {Bug 8ff0cb9fe1} -setup {
|
||||
proc foo {a b} {catch yield; return 1}
|
||||
} -cleanup {
|
||||
rename foo {}
|
||||
} -body {
|
||||
coroutine demo lsort -command foo {a b}
|
||||
} -result {b a}
|
||||
|
||||
test coroutine-7.5 {return codes} {
|
||||
set result {}
|
||||
foreach code {0 1 2 3 4 5} {
|
||||
lappend result [catch {coroutine demo return -level 0 -code $code}]
|
||||
}
|
||||
set result
|
||||
} {0 1 2 3 4 5}
|
||||
|
||||
test coroutine-7.6 {Early yield crashes} {
|
||||
proc foo args {}
|
||||
trace add execution foo enter {catch yield}
|
||||
coroutine demo foo
|
||||
rename foo {}
|
||||
} {}
|
||||
|
||||
|
||||
# cleanup
|
||||
unset lambda
|
||||
|
||||
+434
@@ -1961,6 +1961,440 @@ test info-9.13 {info level option, value in global context} -body {
|
||||
uplevel #0 {info level 2}
|
||||
} -returnCodes error -result {bad level "2"}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
catch {*}{
|
||||
{info frame 0}
|
||||
res
|
||||
}
|
||||
return $res
|
||||
}
|
||||
test info-33.4 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 1968 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
dict for {a b} {c d} {*}{
|
||||
{set res [info frame 0]}
|
||||
}
|
||||
return $res
|
||||
}
|
||||
test info-33.5 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 1983 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
set d {a b}
|
||||
dict update d x y {*}{
|
||||
{set res [info frame 0]}
|
||||
}
|
||||
return $res
|
||||
}
|
||||
test info-33.6 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 1998 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
set d {}
|
||||
dict with d {*}{
|
||||
{set res [info frame 0]}
|
||||
}
|
||||
return $res
|
||||
}
|
||||
test info-33.7 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2013 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
for {*}{
|
||||
{set res [info frame 0]}
|
||||
{1} {} {break}
|
||||
}
|
||||
return $res
|
||||
}
|
||||
test info-33.8 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2027 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
for {*}{
|
||||
{} {1} {}
|
||||
{set res [info frame 0]; break}
|
||||
}
|
||||
return $res
|
||||
}
|
||||
test info-33.9 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2043 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
for {*}{
|
||||
{} {1}
|
||||
{return [info frame 0]}
|
||||
{}
|
||||
}
|
||||
}
|
||||
test info-33.10 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2058 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
for {*}{
|
||||
{}
|
||||
{[return [info frame 0]]}
|
||||
{} {}
|
||||
}
|
||||
}
|
||||
test info-33.11 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2073 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
foreach {*}{
|
||||
x
|
||||
} [return [info frame 0]] {}
|
||||
}
|
||||
test info-33.12 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2088 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
foreach {*}{
|
||||
x y
|
||||
{set res [info frame 0]}
|
||||
}
|
||||
return $res
|
||||
}
|
||||
test info-33.13 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2101 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
if {*}{
|
||||
{[return [info frame 0]]}
|
||||
{}
|
||||
}
|
||||
}
|
||||
test info-33.14 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2115 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
if 0 {*}{
|
||||
{} else
|
||||
{return [info frame 0]}
|
||||
}
|
||||
}
|
||||
test info-33.15 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2130 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
incr {*}{
|
||||
x
|
||||
} [return [info frame 0]]
|
||||
}
|
||||
test info-33.16 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2144 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
info level {*}{
|
||||
} [return [info frame 0]]
|
||||
}
|
||||
test info-33.17 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2156 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
string match {*}{
|
||||
} [return [info frame 0]] {}
|
||||
}
|
||||
test info-33.18 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2168 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
string match {*}{
|
||||
{}
|
||||
} [return [info frame 0]]
|
||||
}
|
||||
test info-33.19 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2181 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
string length {*}{
|
||||
} [return [info frame 0]]
|
||||
}
|
||||
test info-33.20 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2193 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
while {*}{
|
||||
{[return [info frame 0]]}
|
||||
} {}
|
||||
}
|
||||
test info-33.21 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2205 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
switch -- {*}{
|
||||
} [return [info frame 0]] {*}{
|
||||
} x y
|
||||
}
|
||||
test info-33.22 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2218 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
try {*}{
|
||||
{set res [info frame 0]}
|
||||
}
|
||||
return $res
|
||||
}
|
||||
test info-33.23 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2231 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
try {*}{
|
||||
{set res [info frame 0]}
|
||||
} finally {}
|
||||
return $res
|
||||
}
|
||||
test info-33.24 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2245 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
try {*}{
|
||||
{set res [info frame 0]}
|
||||
} on ok {} {}
|
||||
return $res
|
||||
}
|
||||
test info-33.25 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2259 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
try {*}{
|
||||
{set res [info frame 0]}
|
||||
} on ok {} {} finally {}
|
||||
return $res
|
||||
}
|
||||
test info-33.26 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2273 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
while 1 {*}{
|
||||
{return [info frame 0]}
|
||||
}
|
||||
}
|
||||
test info-33.27 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2287 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
try {} finally {*}{
|
||||
{return [info frame 0]}
|
||||
}
|
||||
}
|
||||
test info-33.28 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2300 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
try {} on ok {} {} finally {*}{
|
||||
{return [info frame 0]}
|
||||
}
|
||||
}
|
||||
test info-33.29 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2313 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
try {} on ok {} {*}{
|
||||
{return [info frame 0]}
|
||||
}
|
||||
}
|
||||
test info-33.30 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2326 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
try {} on ok {} {*}{
|
||||
{return [info frame 0]}
|
||||
} finally {}
|
||||
}
|
||||
test info-33.31 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2339 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
binary format {*}{
|
||||
} [return [info frame 0]]
|
||||
}
|
||||
test info-33.32 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2352 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
set format format
|
||||
binary $format {*}{
|
||||
} [return [info frame 0]]
|
||||
}
|
||||
test info-33.33 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2365 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
append x {*}{
|
||||
} [return [info frame 0]]
|
||||
}
|
||||
test info-33.34 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2377 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
namespace eval foo {}
|
||||
proc foo::bar {} {
|
||||
append {*}{
|
||||
} x([return [info frame 0]]) {*}{
|
||||
} a
|
||||
}
|
||||
test info-33.35 {{*}, literal, simple, bytecompiled} -body {
|
||||
reduce [foo::bar]
|
||||
} -cleanup {
|
||||
namespace delete foo
|
||||
} -result {type source line 2389 file info.test cmd {info frame 0} proc ::foo::bar level 0}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
unset -nocomplain res
|
||||
|
||||
|
||||
@@ -1599,6 +1599,20 @@ test interp-20.50 {Bug 2486550} -setup {
|
||||
} -cleanup {
|
||||
interp delete slave
|
||||
} -returnCodes error -match glob -result *
|
||||
test interp-20.50.1 {Bug 2486550} -setup {
|
||||
interp create slave
|
||||
} -body {
|
||||
slave hide coroutine
|
||||
catch {slave invokehidden coroutine} m o
|
||||
dict get $o -errorinfo
|
||||
} -cleanup {
|
||||
unset -nocomplain m 0
|
||||
interp delete slave
|
||||
} -returnCodes ok -result {wrong # args: should be "coroutine name cmd ?arg ...?"
|
||||
while executing
|
||||
"coroutine"
|
||||
invoked from within
|
||||
"slave invokehidden coroutine"}
|
||||
|
||||
test interp-21.1 {interp hidden} {
|
||||
interp hidden {}
|
||||
|
||||
+1
-6
@@ -59,12 +59,7 @@ test misc-1.2 {error in variable ref. in command in array reference} {
|
||||
missing close-brace for variable name
|
||||
missing close-brace for variable name
|
||||
while executing
|
||||
"set tst $a([winfo name $\{zz)
|
||||
# this is a bogus comment
|
||||
# this is a bogus comment
|
||||
# this is a bogus comment
|
||||
# this is a bogus comment
|
||||
# this is a ..."
|
||||
"set tst $a([winfo name $\{"
|
||||
(procedure "tstProc" line 4)
|
||||
invoked from within
|
||||
"tstProc"}]
|
||||
|
||||
@@ -936,6 +936,69 @@ test oo-6.18 {Bug 3408830: more forwarding cases} -setup {
|
||||
} -returnCodes error -cleanup {
|
||||
fooClass destroy
|
||||
} -result {wrong # args: should be "::foo len string"}
|
||||
test oo-6.19 {Bug 3610404: forwarding resolution + traces} -setup {
|
||||
oo::object create foo
|
||||
unset -nocomplain ::result
|
||||
set ::result {}
|
||||
} -body {
|
||||
proc ::my {method} {lappend ::result global}
|
||||
oo::objdefine foo {
|
||||
method target {} {lappend ::result instance}
|
||||
forward bar my target
|
||||
method bump {} {
|
||||
set ns [info object namespace ::foo]
|
||||
rename ${ns}::my ${ns}::
|
||||
rename ${ns}:: ${ns}::my
|
||||
}
|
||||
}
|
||||
proc harness {} {
|
||||
foo target
|
||||
foo bar
|
||||
foo target
|
||||
}
|
||||
trace add execution harness enterstep {apply {{cmd args} {foo bump}}}
|
||||
foo target
|
||||
foo bar
|
||||
foo bump
|
||||
foo bar
|
||||
harness
|
||||
} -cleanup {
|
||||
catch {rename harness {}}
|
||||
catch {rename ::my {}}
|
||||
foo destroy
|
||||
} -result {instance instance instance instance instance instance}
|
||||
test oo-6.20 {Bug 3610404: forwarding resolution + traces} -setup {
|
||||
oo::class create fooClass
|
||||
fooClass create foo
|
||||
unset -nocomplain ::result
|
||||
set ::result {}
|
||||
} -body {
|
||||
proc ::my {method} {lappend ::result global}
|
||||
oo::define fooClass {
|
||||
method target {} {lappend ::result class}
|
||||
forward bar my target
|
||||
method bump {} {
|
||||
set ns [info object namespace [self]]
|
||||
rename ${ns}::my ${ns}::
|
||||
rename ${ns}:: ${ns}::my
|
||||
}
|
||||
}
|
||||
proc harness {} {
|
||||
foo target
|
||||
foo bar
|
||||
foo target
|
||||
}
|
||||
trace add execution harness enterstep {apply {{cmd args} {foo bump}}}
|
||||
foo target
|
||||
foo bar
|
||||
foo bump
|
||||
foo bar
|
||||
harness
|
||||
} -cleanup {
|
||||
catch {rename harness {}}
|
||||
catch {rename ::my {}}
|
||||
fooClass destroy
|
||||
} -result {class class class class class class}
|
||||
|
||||
test oo-7.1 {OO: inheritance 101} -setup {
|
||||
oo::class create superClass
|
||||
@@ -3374,6 +3437,42 @@ test oo-34.8 {TIP 380: slots - presence} {
|
||||
test oo-34.9 {TIP 380: slots - presence} {
|
||||
getMethods oo::objdefine::variable
|
||||
} {{-append -clear -set} {Get Set}}
|
||||
|
||||
test oo-35.1 {Bug 9d61624b3d: Empty superclass must not cause crash} -setup {
|
||||
oo::class create fruit {
|
||||
method eat {} {}
|
||||
}
|
||||
set result {}
|
||||
} -body {
|
||||
lappend result [fruit create ::apple] [info class superclasses fruit]
|
||||
oo::define fruit superclass
|
||||
lappend result [info class superclasses fruit] \
|
||||
[info object class apple oo::object] \
|
||||
[info class call fruit destroy] \
|
||||
[catch { apple }]
|
||||
} -cleanup {
|
||||
unset -nocomplain result
|
||||
fruit destroy
|
||||
} -result {::apple ::oo::object ::oo::object 1 {{method destroy ::oo::object {core method: "destroy"}}} 1}
|
||||
test oo-35.2 {Bug 9d61624b3d: Empty superclass must not cause crash} -setup {
|
||||
oo::class create fruitMetaclass {
|
||||
superclass oo::class
|
||||
method eat {} {}
|
||||
}
|
||||
set result {}
|
||||
} -body {
|
||||
lappend result [fruitMetaclass create ::appleClass] \
|
||||
[appleClass create orange] \
|
||||
[info class superclasses fruitMetaclass]
|
||||
oo::define fruitMetaclass superclass
|
||||
lappend result [info class superclasses fruitMetaclass] \
|
||||
[info object class appleClass oo::class] \
|
||||
[catch { orange }] [info object class orange] \
|
||||
[appleClass create pear]
|
||||
} -cleanup {
|
||||
unset -nocomplain result
|
||||
fruitMetaclass destroy
|
||||
} -result {::appleClass ::orange ::oo::class ::oo::class 1 1 ::appleClass ::pear}
|
||||
|
||||
cleanupTests
|
||||
return
|
||||
|
||||
@@ -27,6 +27,7 @@ testConstraint testparsevar [llength [info commands testparsevar]]
|
||||
testConstraint testasync [llength [info commands testasync]]
|
||||
testConstraint testcmdtrace [llength [info commands testcmdtrace]]
|
||||
testConstraint testevent [llength [info commands testevent]]
|
||||
testConstraint memory [llength [info commands memory]]
|
||||
|
||||
test parse-1.1 {Tcl_ParseCommand procedure, computing string length} testparser {
|
||||
testparser [bytestring "foo\0 bar"] -1
|
||||
@@ -678,6 +679,26 @@ test parse-13.5 {Tcl_ParseVar procedure, error looking up variable} testparsevar
|
||||
unset -nocomplain abc
|
||||
list [catch {testparsevar {$abc([bogus x y z])}} msg] $msg
|
||||
} {1 {invalid command name "bogus"}}
|
||||
test parse-13.6 {Tcl_ParseVar memory leak} -constraints memory -setup {
|
||||
proc getbytes {} {
|
||||
return [lindex [split [memory info] \n] 3 3]
|
||||
}
|
||||
} -body {
|
||||
set a() foo
|
||||
set end [getbytes]
|
||||
for {set i 0} {$i < 5} {incr i} {
|
||||
set vn {}
|
||||
set res [testparsevar [append vn $ a([string repeat {[]} 19]) bar]]
|
||||
if {$res ne {foo bar}} {error "Unexpected result: $res"}
|
||||
|
||||
set tmp $end
|
||||
set end [getbytes]
|
||||
}
|
||||
expr {$end - $tmp}
|
||||
} -cleanup {
|
||||
unset -nocomplain a end i vn res tmp
|
||||
rename getbytes {}
|
||||
} -result 0
|
||||
|
||||
test parse-14.1 {Tcl_ParseBraces procedure, computing string length} testparser {
|
||||
testparser [bytestring "foo\0 bar"] -1
|
||||
@@ -1097,6 +1118,12 @@ test parse-21.0 {Bug 1884496} testevent {
|
||||
testevent queue a head $::script
|
||||
vwait done
|
||||
} {}
|
||||
test parse-21.1 {TCL_EVAL_DIRECT coverage} testevent {
|
||||
testevent queue a head {testevent delete a; \
|
||||
set ::done [dict get [info frame 0] line]}
|
||||
vwait done
|
||||
set ::done
|
||||
} 2
|
||||
|
||||
cleanupTests
|
||||
}
|
||||
|
||||
@@ -1155,6 +1155,9 @@ test reg-33.15 {Bug 3603557 - an "in the wild" RE} {
|
||||
(.*) # ConditionalFields
|
||||
}] 0
|
||||
} 68
|
||||
test reg-33.16 {Bug [8d2c0da36d]- another "in the wild" RE} {
|
||||
lindex [regexp -about "^MRK:client1: =1339 14HKelly Talisman 10011000 (\[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]*) \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 8 0 8 0 0 0 77 77 1 1 2 0 11 { 1 3 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 13HC6 My Creator 2 3 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 31HC7 Slightly offensive name, huh 3 8 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 23HE-mail:kelly@hotbox.com 4 9 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 17Hcompface must die 5 10 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 3HAir 6 12 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 14HPGP public key 7 13 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 16Hkelly@hotbox.com 8 30 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 12H2 text/plain 9 30 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 13H2 x-kom/basic 10 33 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 1H0 11 14 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 1H3 }\r?"] 0
|
||||
} 1
|
||||
|
||||
# cleanup
|
||||
::tcltest::cleanupTests
|
||||
|
||||
@@ -876,6 +876,10 @@ test regexp-22.5 {Bug 3610026} -setup {
|
||||
} -cleanup {
|
||||
unset -nocomplain e cp
|
||||
} -returnCodes error -match glob -result {*too many colors*}
|
||||
test regexp-22.6 {Bug 6585b21ca8} {
|
||||
expr {[regexp {(\w).*?\1} Programmer m] ? $m : "<NONE>"}
|
||||
} rogr
|
||||
|
||||
|
||||
test regexp-23.1 {regexp -all and -line} {
|
||||
set string ""
|
||||
|
||||
@@ -140,6 +140,13 @@ test rename-4.7 {reentrancy issues with command deletion and renaming} testdel {
|
||||
if {[info exists env(value)]} {
|
||||
unset env(value)
|
||||
}
|
||||
test rename-4.8 {Bug a16752c252} testdel {
|
||||
set x broken
|
||||
testdel {} foo {set x ok}
|
||||
proc foo args {}
|
||||
rename foo {}
|
||||
return -level 0 $x[unset x]
|
||||
} ok
|
||||
|
||||
# Save the unknown procedure which is modified by the following test.
|
||||
|
||||
|
||||
@@ -425,6 +425,19 @@ test safe-10.1 {testing statics loading} -constraints TcltestPackage -setup {
|
||||
} -returnCodes error -cleanup {
|
||||
safe::interpDelete $i
|
||||
} -result {can't use package in a safe interpreter: no Safepkg1_SafeInit procedure}
|
||||
test safe-10.1.1 {testing statics loading} -constraints TcltestPackage -setup {
|
||||
set i [safe::interpCreate]
|
||||
} -body {
|
||||
catch {interp eval $i {load {} Safepkg1}} m o
|
||||
dict get $o -errorinfo
|
||||
} -returnCodes ok -cleanup {
|
||||
unset -nocomplain m o
|
||||
safe::interpDelete $i
|
||||
} -result {can't use package in a safe interpreter: no Safepkg1_SafeInit procedure
|
||||
invoked from within
|
||||
"load {} Safepkg1"
|
||||
invoked from within
|
||||
"interp eval $i {load {} Safepkg1}"}
|
||||
test safe-10.2 {testing statics loading / -nostatics} -constraints TcltestPackage -body {
|
||||
set i [safe::interpCreate -nostatics]
|
||||
interp eval $i {load {} Safepkg1}
|
||||
@@ -444,6 +457,18 @@ test safe-10.4 {testing nested statics loading / -nestedloadok} -constraints Tcl
|
||||
} -returnCodes error -cleanup {
|
||||
safe::interpDelete $i
|
||||
} -result {can't use package in a safe interpreter: no Safepkg1_SafeInit procedure}
|
||||
test safe-10.4.1 {testing nested statics loading / -nestedloadok} -constraints TcltestPackage -body {
|
||||
set i [safe::interpCreate -nestedloadok]
|
||||
catch {interp eval $i {interp create x; load {} Safepkg1 x}} m o
|
||||
dict get $o -errorinfo
|
||||
} -returnCodes ok -cleanup {
|
||||
unset -nocomplain m o
|
||||
safe::interpDelete $i
|
||||
} -result {can't use package in a safe interpreter: no Safepkg1_SafeInit procedure
|
||||
invoked from within
|
||||
"load {} Safepkg1 x"
|
||||
invoked from within
|
||||
"interp eval $i {interp create x; load {} Safepkg1 x}"}
|
||||
|
||||
test safe-11.1 {testing safe encoding} -setup {
|
||||
set i [safe::interpCreate]
|
||||
@@ -501,6 +526,23 @@ test safe-11.7 {testing safe encoding} -setup {
|
||||
} -returnCodes error -cleanup {
|
||||
safe::interpDelete $i
|
||||
} -result {wrong # args: should be "encoding convertfrom ?encoding? data"}
|
||||
test safe-11.7.1 {testing safe encoding} -setup {
|
||||
set i [safe::interpCreate]
|
||||
} -body {
|
||||
catch {interp eval $i encoding convertfrom} m o
|
||||
dict get $o -errorinfo
|
||||
} -returnCodes ok -cleanup {
|
||||
unset -nocomplain m o
|
||||
safe::interpDelete $i
|
||||
} -result {wrong # args: should be "encoding convertfrom ?encoding? data"
|
||||
while executing
|
||||
"encoding convertfrom"
|
||||
invoked from within
|
||||
"::interp invokehidden interp1 encoding convertfrom"
|
||||
invoked from within
|
||||
"encoding convertfrom"
|
||||
invoked from within
|
||||
"interp eval $i encoding convertfrom"}
|
||||
test safe-11.8 {testing safe encoding} -setup {
|
||||
set i [safe::interpCreate]
|
||||
} -body {
|
||||
@@ -508,6 +550,23 @@ test safe-11.8 {testing safe encoding} -setup {
|
||||
} -returnCodes error -cleanup {
|
||||
safe::interpDelete $i
|
||||
} -result {wrong # args: should be "encoding convertto ?encoding? data"}
|
||||
test safe-11.8.1 {testing safe encoding} -setup {
|
||||
set i [safe::interpCreate]
|
||||
} -body {
|
||||
catch {interp eval $i encoding convertto} m o
|
||||
dict get $o -errorinfo
|
||||
} -returnCodes ok -cleanup {
|
||||
unset -nocomplain m o
|
||||
safe::interpDelete $i
|
||||
} -result {wrong # args: should be "encoding convertto ?encoding? data"
|
||||
while executing
|
||||
"encoding convertto"
|
||||
invoked from within
|
||||
"::interp invokehidden interp1 encoding convertto"
|
||||
invoked from within
|
||||
"encoding convertto"
|
||||
invoked from within
|
||||
"interp eval $i encoding convertto"}
|
||||
|
||||
test safe-12.1 {glob is restricted [Bug 2906841]} -setup {
|
||||
set i [safe::interpCreate]
|
||||
@@ -715,8 +774,29 @@ test safe-15.1 {safe file ensemble does not surprise code} -setup {
|
||||
lappend result [catch {interp eval $i {file split a/b/c}} msg] $msg
|
||||
lappend result [catch {interp eval $i {file isdirectory .}} msg] $msg
|
||||
} -cleanup {
|
||||
unset -nocomplain msg
|
||||
interp delete $i
|
||||
} -result {1 {a b c} 1 {a b c} 1 {invalid command name "file"} 1 0 {a b c} 1 {not allowed to invoke subcommand isdirectory of file}}
|
||||
test safe-15.1.1 {safe file ensemble does not surprise code} -setup {
|
||||
set i [interp create -safe]
|
||||
} -body {
|
||||
set result [expr {"file" in [interp hidden $i]}]
|
||||
lappend result [interp eval $i {tcl::file::split a/b/c}]
|
||||
lappend result [catch {interp eval $i {tcl::file::isdirectory .}}]
|
||||
lappend result [interp invokehidden $i file split a/b/c]
|
||||
lappend result [catch {interp eval $i {file split a/b/c}} msg] $msg
|
||||
lappend result [catch {interp invokehidden $i file isdirectory .}]
|
||||
interp expose $i file
|
||||
lappend result [catch {interp eval $i {file split a/b/c}} msg] $msg
|
||||
lappend result [catch {interp eval $i {file isdirectory .}} msg o] [dict get $o -errorinfo]
|
||||
} -cleanup {
|
||||
unset -nocomplain msg o
|
||||
interp delete $i
|
||||
} -result {1 {a b c} 1 {a b c} 1 {invalid command name "file"} 1 0 {a b c} 1 {not allowed to invoke subcommand isdirectory of file
|
||||
while executing
|
||||
"file isdirectory ."
|
||||
invoked from within
|
||||
"interp eval $i {file isdirectory .}"}}
|
||||
|
||||
### ~ should have no special meaning in paths in safe interpreters
|
||||
test safe-16.1 {Bug 3529949: defang ~ in paths} -setup {
|
||||
|
||||
@@ -293,6 +293,10 @@ test subst-13.1 {Bug 3081065} -setup {
|
||||
} -cleanup {
|
||||
removeFile subst13.tcl
|
||||
}
|
||||
test subst-13.2 {Test for segfault} -body {
|
||||
subst {[}
|
||||
} -returnCodes error -result * -match glob
|
||||
|
||||
|
||||
# cleanup
|
||||
::tcltest::cleanupTests
|
||||
|
||||
@@ -2661,6 +2661,13 @@ test trace-39.1 {bug #3485022: tracing Bc'ed commands} -setup {
|
||||
rename dotrace {}
|
||||
rename foo {}
|
||||
} -result {3 | 0 1 1}
|
||||
|
||||
test trace-40.1 {execution trace errors become command errors} {
|
||||
proc foo args {}
|
||||
trace add execution foo enter {rename foo {}; error bar;#}
|
||||
catch foo m
|
||||
return -level 0 $m[unset m]
|
||||
} bar
|
||||
|
||||
# Delete procedures when done, so we don't clash with other tests
|
||||
# (e.g. foobar will clash with 'unknown' tests).
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# This file contains a collection of tests for the procedures in the file
|
||||
# tclUnixNotify.c. Sourcing this file into Tcl runs the tests and
|
||||
# generates output for errors. No output means no errors were found.
|
||||
#
|
||||
# Copyright (c) 1995-1997 Sun Microsystems, Inc.
|
||||
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
||||
#
|
||||
# See the file "license.terms" for information on usage and redistribution
|
||||
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
|
||||
package require tcltest 2
|
||||
namespace import -force ::tcltest::*
|
||||
|
||||
testConstraint testfork [llength [info commands testfork]]
|
||||
|
||||
# Test if the notifier thread is well initialized in a forked interpreter
|
||||
# by Tcl_InitNotifier
|
||||
test unixforkevent-1.1 {fork and test writeable event} \
|
||||
-constraints {testfork nonPortable} \
|
||||
-body {
|
||||
set myFolder [makeDirectory unixtestfork]
|
||||
set pid [testfork]
|
||||
if {$pid == 0} {
|
||||
# we are the forked process
|
||||
set result initialized
|
||||
set h [open [file join $myFolder test.txt] w]
|
||||
fileevent $h writable\
|
||||
"set result writable;\
|
||||
after cancel [after 1000 {set result timeout}]"
|
||||
vwait result
|
||||
close $h
|
||||
makeFile $result result.txt $myFolder
|
||||
exit
|
||||
}
|
||||
# we are the original process
|
||||
while {![file readable [file join $myFolder result.txt]]} {}
|
||||
viewFile result.txt $myFolder
|
||||
} \
|
||||
-result {writable} \
|
||||
-cleanup {
|
||||
catch { removeFolder $myFolder }
|
||||
}
|
||||
|
||||
::tcltest::cleanupTests
|
||||
return
|
||||
+10
-2
@@ -335,7 +335,10 @@ TOMMATH_OBJS = bncore.o bn_reverse.o bn_fast_s_mp_mul_digs.o \
|
||||
bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_s_mp_add.o \
|
||||
bn_s_mp_mul_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o
|
||||
|
||||
STUB_LIB_OBJS = tclStubLib.o tclTomMathStubLib.o tclOOStubLib.o ${COMPAT_OBJS}
|
||||
STUB_LIB_OBJS = tclStubLib.o \
|
||||
tclTomMathStubLib.o \
|
||||
tclOOStubLib.o \
|
||||
${COMPAT_OBJS}
|
||||
|
||||
UNIX_OBJS = tclUnixChan.o tclUnixEvent.o tclUnixFCmd.o \
|
||||
tclUnixFile.o tclUnixPipe.o tclUnixSock.o \
|
||||
@@ -346,6 +349,8 @@ NOTIFY_OBJS = tclUnixNotfy.o
|
||||
|
||||
MAC_OSX_OBJS = tclMacOSXBundle.o tclMacOSXFCmd.o tclMacOSXNotify.o
|
||||
|
||||
CYGWIN_OBJS = tclWinError.o
|
||||
|
||||
DTRACE_OBJ = tclDTrace.o
|
||||
|
||||
ZLIB_OBJS = Zadler32.o Zcompress.o Zcrc32.o Zdeflate.o Zinfback.o \
|
||||
@@ -575,6 +580,9 @@ MAC_OSX_SRCS = \
|
||||
$(MAC_OSX_DIR)/tclMacOSXFCmd.c \
|
||||
$(MAC_OSX_DIR)/tclMacOSXNotify.c
|
||||
|
||||
CYGWIN_SRCS = \
|
||||
$(TOP_DIR)/win/tclWinError.c
|
||||
|
||||
DTRACE_HDR = tclDTrace.h
|
||||
|
||||
DTRACE_SRC = $(GENERIC_DIR)/tclDTrace.d
|
||||
@@ -1683,7 +1691,7 @@ Zzutil.o: $(ZLIB_DIR)/zutil.c
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
tclStubLib.o: $(GENERIC_DIR)/tclStubLib.c
|
||||
$(CC) -c $(STUB_CC_SWITCHES) $(GENERIC_DIR)/tclStubLib.c
|
||||
$(CC) -c $(STUB_CC_SWITCHES) -DSTATIC_BUILD $(GENERIC_DIR)/tclStubLib.c
|
||||
|
||||
tclTomMathStubLib.o: $(GENERIC_DIR)/tclTomMathStubLib.c
|
||||
$(CC) -c $(STUB_CC_SWITCHES) $(GENERIC_DIR)/tclTomMathStubLib.c
|
||||
|
||||
Vendored
+9
-104
@@ -4821,7 +4821,11 @@ echo "$as_me: WARNING: Don't know how to find pthread lib on your system - you m
|
||||
# Does the pthread-implementation provide
|
||||
# 'pthread_attr_setstacksize' ?
|
||||
|
||||
for ac_func in pthread_attr_setstacksize
|
||||
ac_saved_libs=$LIBS
|
||||
LIBS="$LIBS $THREADS_LIBS"
|
||||
|
||||
|
||||
for ac_func in pthread_attr_setstacksize pthread_atfork
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
@@ -4922,6 +4926,7 @@ _ACEOF
|
||||
fi
|
||||
done
|
||||
|
||||
LIBS=$ac_saved_libs
|
||||
else
|
||||
TCL_THREADS=0
|
||||
fi
|
||||
@@ -7068,7 +7073,9 @@ fi
|
||||
SHLIB_CFLAGS=""
|
||||
SHLIB_LD='${CC} -shared'
|
||||
SHLIB_SUFFIX=".dll"
|
||||
DL_OBJS="tclLoadDl.o tclWinError.o"
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
PLAT_OBJS='${CYGWIN_OBJS}'
|
||||
PLAT_SRCS='${CYGWIN_SRCS}'
|
||||
DL_LIBS="-ldl"
|
||||
CC_SEARCH_FLAGS=""
|
||||
LD_SEARCH_FLAGS=""
|
||||
@@ -17945,108 +17952,6 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
|
||||
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
for ac_func in pthread_atfork
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
|
||||
if eval "test \"\${$as_ac_var+set}\" = set"; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
|
||||
For example, HP-UX 11i <limits.h> declares gettimeofday. */
|
||||
#define $ac_func innocuous_$ac_func
|
||||
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func (); below.
|
||||
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
|
||||
<limits.h> exists even on freestanding compilers. */
|
||||
|
||||
#ifdef __STDC__
|
||||
# include <limits.h>
|
||||
#else
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
#undef $ac_func
|
||||
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
builtin and then its argument prototype would still apply. */
|
||||
char $ac_func ();
|
||||
/* The GNU C library defines this for functions which it implements
|
||||
to always fail with ENOSYS. Some functions are actually named
|
||||
something starting with __ and the normal name is an alias. */
|
||||
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
|
||||
choke me
|
||||
#else
|
||||
char (*f) () = $ac_func;
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return f != $ac_func;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
eval "$as_ac_var=yes"
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
eval "$as_ac_var=no"
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
|
||||
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
|
||||
if test `eval echo '${'$as_ac_var'}'` = yes; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -576,7 +576,6 @@ if test "`uname -s`" = "Darwin" ; then
|
||||
if test $tcl_corefoundation = yes; then
|
||||
AC_CHECK_HEADERS(libkern/OSAtomic.h)
|
||||
AC_CHECK_FUNCS(OSSpinLockLock)
|
||||
AC_CHECK_FUNCS(pthread_atfork)
|
||||
fi
|
||||
AC_DEFINE(USE_VFORK, 1, [Should we use vfork() instead of fork()?])
|
||||
AC_DEFINE(TCL_DEFAULT_ENCODING, "utf-8",
|
||||
|
||||
+8
-2
@@ -676,7 +676,11 @@ AC_DEFUN([SC_ENABLE_THREADS], [
|
||||
|
||||
# Does the pthread-implementation provide
|
||||
# 'pthread_attr_setstacksize' ?
|
||||
AC_CHECK_FUNCS(pthread_attr_setstacksize)
|
||||
|
||||
ac_saved_libs=$LIBS
|
||||
LIBS="$LIBS $THREADS_LIBS"
|
||||
AC_CHECK_FUNCS(pthread_attr_setstacksize pthread_atfork)
|
||||
LIBS=$ac_saved_libs
|
||||
else
|
||||
TCL_THREADS=0
|
||||
fi
|
||||
@@ -1224,7 +1228,9 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
|
||||
SHLIB_CFLAGS=""
|
||||
SHLIB_LD='${CC} -shared'
|
||||
SHLIB_SUFFIX=".dll"
|
||||
DL_OBJS="tclLoadDl.o tclWinError.o"
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
PLAT_OBJS='${CYGWIN_OBJS}'
|
||||
PLAT_SRCS='${CYGWIN_SRCS}'
|
||||
DL_LIBS="-ldl"
|
||||
CC_SEARCH_FLAGS=""
|
||||
LD_SEARCH_FLAGS=""
|
||||
|
||||
+112
-1
@@ -119,6 +119,15 @@ static Tcl_ThreadDataKey dataKey;
|
||||
|
||||
static int notifierCount = 0;
|
||||
|
||||
/*
|
||||
* The following static stores the process ID of the initialized notifier
|
||||
* thread. If it changes, we have passed a fork and we should start a new
|
||||
* notifier thread.
|
||||
*
|
||||
* You must hold the notifierMutex lock before accessing this variable.
|
||||
*/
|
||||
static pid_t processIDInitialized = 0;
|
||||
|
||||
/*
|
||||
* The following variable points to the head of a doubly-linked list of
|
||||
* ThreadSpecificData structures for all threads that are currently waiting on
|
||||
@@ -185,7 +194,13 @@ static Tcl_ThreadId notifierThread;
|
||||
|
||||
#ifdef TCL_THREADS
|
||||
static void NotifierThreadProc(ClientData clientData);
|
||||
#endif
|
||||
#ifdef HAVE_PTHREAD_ATFORK
|
||||
static int atForkInit = 0;
|
||||
static void AtForkPrepare(void);
|
||||
static void AtForkParent(void);
|
||||
static void AtForkChild(void);
|
||||
#endif /* HAVE_PTHREAD_ATFORK */
|
||||
#endif /* TCL_THREADS */
|
||||
static int FileHandlerEventProc(Tcl_Event *evPtr, int flags);
|
||||
|
||||
/*
|
||||
@@ -275,11 +290,38 @@ Tcl_InitNotifier(void)
|
||||
*/
|
||||
|
||||
Tcl_MutexLock(¬ifierMutex);
|
||||
#ifdef HAVE_PTHREAD_ATFORK
|
||||
/*
|
||||
* Install pthread_atfork handlers to reinitialize the notifier in the
|
||||
* child of a fork.
|
||||
*/
|
||||
|
||||
if (!atForkInit) {
|
||||
int result = pthread_atfork(AtForkPrepare, AtForkParent, AtForkChild);
|
||||
|
||||
if (result) {
|
||||
Tcl_Panic("Tcl_InitNotifier: pthread_atfork failed");
|
||||
}
|
||||
atForkInit = 1;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Check if my process id changed, e.g. I was forked
|
||||
* In this case, restart the notifier thread and close the
|
||||
* pipe to the original notifier thread
|
||||
*/
|
||||
if (notifierCount > 0 && processIDInitialized != getpid()) {
|
||||
notifierCount = 0;
|
||||
processIDInitialized = 0;
|
||||
close(triggerPipe);
|
||||
triggerPipe = -1;
|
||||
}
|
||||
if (notifierCount == 0) {
|
||||
if (TclpThreadCreate(¬ifierThread, NotifierThreadProc, NULL,
|
||||
TCL_THREAD_STACK_DEFAULT, TCL_THREAD_JOINABLE) != TCL_OK) {
|
||||
Tcl_Panic("Tcl_InitNotifier: unable to start notifier thread");
|
||||
}
|
||||
processIDInitialized = getpid();
|
||||
}
|
||||
notifierCount++;
|
||||
|
||||
@@ -1270,6 +1312,75 @@ NotifierThreadProc(
|
||||
|
||||
TclpThreadExit(0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PTHREAD_ATFORK
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* AtForkPrepare --
|
||||
*
|
||||
* Lock the notifier in preparation for a fork.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
AtForkPrepare(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* AtForkParent --
|
||||
*
|
||||
* Unlock the notifier in the parent after a fork.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
AtForkParent(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* AtForkChild --
|
||||
*
|
||||
* Unlock and reinstall the notifier in the child after a fork.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
AtForkChild(void)
|
||||
{
|
||||
notifierMutex = NULL;
|
||||
notifierCV = NULL;
|
||||
Tcl_InitNotifier();
|
||||
}
|
||||
#endif /* HAVE_PTHREAD_ATFORK */
|
||||
|
||||
#endif /* TCL_THREADS */
|
||||
|
||||
#endif /* !HAVE_COREFOUNDATION */
|
||||
|
||||
@@ -67,6 +67,7 @@ static Tcl_CmdProc TestchmodCmd;
|
||||
static Tcl_CmdProc TestfilehandlerCmd;
|
||||
static Tcl_CmdProc TestfilewaitCmd;
|
||||
static Tcl_CmdProc TestfindexecutableCmd;
|
||||
static Tcl_ObjCmdProc TestforkObjCmd;
|
||||
static Tcl_CmdProc TestgetdefencdirCmd;
|
||||
static Tcl_CmdProc TestgetopenfileCmd;
|
||||
static Tcl_CmdProc TestgotsigCmd;
|
||||
@@ -103,6 +104,8 @@ TclplatformtestInit(
|
||||
NULL, NULL);
|
||||
Tcl_CreateCommand(interp, "testfindexecutable", TestfindexecutableCmd,
|
||||
NULL, NULL);
|
||||
Tcl_CreateObjCommand(interp, "testfork", TestforkObjCmd,
|
||||
NULL, NULL);
|
||||
Tcl_CreateCommand(interp, "testgetopenfile", TestgetopenfileCmd,
|
||||
NULL, NULL);
|
||||
Tcl_CreateCommand(interp, "testgetdefenc", TestgetdefencdirCmd,
|
||||
@@ -526,6 +529,52 @@ TestsetdefencdirCmd(
|
||||
Tcl_SetDefaultEncodingDir(argv[1]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TestforkObjCmd --
|
||||
*
|
||||
* This function implements the "testfork" command. It is used to
|
||||
* fork the Tcl process for specific test cases.
|
||||
*
|
||||
* Results:
|
||||
* A standard Tcl result.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
TestforkObjCmd(
|
||||
ClientData clientData, /* Not used. */
|
||||
Tcl_Interp *interp, /* Current interpreter. */
|
||||
int objc, /* Number of arguments. */
|
||||
Tcl_Obj *const *objv) /* Argument strings. */
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (objc != 1) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
Tcl_AppendResult(interp,
|
||||
"Cannot fork", NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#if !defined(HAVE_PTHREAD_ATFORK) || defined(MAC_OSX_TCL)
|
||||
/* Only needed when pthread_atfork is not present or on OSX. */
|
||||
if (pid==0) {
|
||||
Tcl_InitNotifier();
|
||||
}
|
||||
#endif
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(pid));
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user