summaryrefslogtreecommitdiffstats
path: root/generic/tclNamesp.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-11-16 14:11:50 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-11-16 14:11:50 (GMT)
commit837b9c9c7f6f3f01e286eb8ab111b268eba47842 (patch)
tree752c216216cf230e79bafdc10e22bb4d6d97502c /generic/tclNamesp.c
parent7ac80cab9e7494b78ed8010a98bd096e83cd5955 (diff)
downloadtcl-837b9c9c7f6f3f01e286eb8ab111b268eba47842.zip
tcl-837b9c9c7f6f3f01e286eb8ab111b268eba47842.tar.gz
tcl-837b9c9c7f6f3f01e286eb8ab111b268eba47842.tar.bz2
Greatly improved ensemble compiler. This one now can handle any ensemble.
It is usually not enabled though; only worth it when a subcommand is actually expected to undergo bytecode compilation.
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r--generic/tclNamesp.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 5c6582d..7d9c2b4 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -23,7 +23,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNamesp.c,v 1.154 2007/11/15 16:21:04 dkf Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.155 2007/11/16 14:11:52 dkf Exp $
*/
#include "tclInt.h"
@@ -109,8 +109,8 @@ typedef struct EnsembleConfig {
* all lists, and cannot be found by scanning
* the list from the namespace's ensemble
* field. */
- int flags; /* ORed combo of TCL_ENSEMBLE_PREFIX and
- * ENS_DEAD. */
+ int flags; /* ORed combo of TCL_ENSEMBLE_PREFIX, ENS_DEAD
+ * and ENSEMBLE_COMPILE. */
/* OBJECT FIELDS FOR ENSEMBLE CONFIGURATION */
@@ -5284,6 +5284,10 @@ Tcl_CreateEnsemble(
nsPtr->exportLookupEpoch++;
+ if (flags & ENSEMBLE_COMPILE) {
+ ((Command *) ensemblePtr->token)->compileProc = TclCompileEnsemble;
+ }
+
if (nameObj != NULL) {
TclDecrRefCount(nameObj);
}
@@ -5358,9 +5362,6 @@ Tcl_SetEnsembleSubcommandList(
if (cmdPtr->compileProc != NULL) {
((Interp *)interp)->compileEpoch++;
- if (subcmdList != NULL) {
- cmdPtr->compileProc = NULL;
- }
}
return TCL_OK;
@@ -5434,9 +5435,6 @@ Tcl_SetEnsembleMappingDict(
if (cmdPtr->compileProc != NULL) {
((Interp *)interp)->compileEpoch++;
- if (mapDict == NULL) {
- cmdPtr->compileProc = NULL;
- }
}
return TCL_OK;
@@ -5531,6 +5529,7 @@ Tcl_SetEnsembleFlags(
{
Command *cmdPtr = (Command *) token;
EnsembleConfig *ensemblePtr;
+ int wasCompiled;
if (cmdPtr->objProc != NsEnsembleImplementationCmd) {
Tcl_AppendResult(interp, "command is not an ensemble", NULL);
@@ -5538,6 +5537,7 @@ Tcl_SetEnsembleFlags(
}
ensemblePtr = (EnsembleConfig *) cmdPtr->objClientData;
+ wasCompiled = ensemblePtr->flags & ENSEMBLE_COMPILE;
/*
* This API refuses to set the ENS_DEAD flag...
@@ -5555,6 +5555,24 @@ Tcl_SetEnsembleFlags(
ensemblePtr->nsPtr->exportLookupEpoch++;
+ /*
+ * If the ENSEMBLE_COMPILE flag status was changed, install or remove the
+ * compiler function and bump the interpreter's compilation epoch so that
+ * bytecode gets regenerated.
+ */
+
+ if (flags & ENSEMBLE_COMPILE) {
+ if (!wasCompiled) {
+ ((Command*) ensemblePtr->token)->compileProc = TclCompileEnsemble;
+ ((Interp *) interp)->compileEpoch++;
+ }
+ } else {
+ if (wasCompiled) {
+ ((Command*) ensemblePtr->token)->compileProc = NULL;
+ ((Interp *) interp)->compileEpoch++;
+ }
+ }
+
return TCL_OK;
}