summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authormig <mig>2013-01-11 12:42:14 (GMT)
committermig <mig>2013-01-11 12:42:14 (GMT)
commit43988caaa2e63f25b6f9758bd8f9d573e510bd78 (patch)
treeaf1e0947d55ec2c3c237c75a2f72d6b793d87951 /generic
parentd562dc0f601c1e4871dea0129f2e43bfca1fdb0a (diff)
downloadtcl-43988caaa2e63f25b6f9758bd8f9d573e510bd78.zip
tcl-43988caaa2e63f25b6f9758bd8f9d573e510bd78.tar.gz
tcl-43988caaa2e63f25b6f9758bd8f9d573e510bd78.tar.bz2
Name functions according to 'what' instead of 'how' in the [tailcall]
machinery, in view of making public some parts of it.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBasic.c41
-rw-r--r--generic/tclEnsemble.c4
-rw-r--r--generic/tclExecute.c2
-rw-r--r--generic/tclInt.h7
-rw-r--r--generic/tclInterp.c2
-rw-r--r--generic/tclNamesp.c2
6 files changed, 34 insertions, 24 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 55014ec..b511d07 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -4309,14 +4309,6 @@ TclNREvalObjv(
}
}
-void
-TclPushTailcallPoint(
- Tcl_Interp *interp)
-{
- TclNRAddCallback(interp, NRCommand, NULL, NULL, NULL, NULL);
- ((Interp *) interp)->numLevels++;
-}
-
int
TclNRRunCallbacks(
Tcl_Interp *interp,
@@ -4633,7 +4625,7 @@ TEOV_NotFound(
savedNsPtr = varFramePtr->nsPtr;
varFramePtr->nsPtr = lookupNsPtr;
}
- TclDeferCallbacks(interp, 1);
+ TclSkipTailcall(interp);
TclNRAddCallback(interp, TEOV_NotFoundCallback, INT2PTR(handlerObjc),
newObjv, savedNsPtr, NULL);
return TclNREvalObjv(interp, newObjc, newObjv, TCL_EVAL_NOERR, NULL);
@@ -6020,7 +6012,7 @@ TclNREvalObjEx(
iPtr->cmdFramePtr = eoFramePtr;
}
- TclDeferCallbacks(interp, 0);
+ TclMarkTailcall(interp);
TclNRAddCallback(interp, TEOEx_ListCallback, listPtr, eoFramePtr,
NULL, NULL);
@@ -8278,22 +8270,37 @@ Tcl_NRCmdSwap(
*/
void
-TclDeferCallbacks(
- Tcl_Interp *interp,
- int skipTailcalls)
+TclMarkTailcall(
+ Tcl_Interp *interp)
{
Interp *iPtr = (Interp *) interp;
if (iPtr->deferredCallbacks == NULL) {
- TclNRAddCallback(interp, NRCommand, NULL, INT2PTR(skipTailcalls != 0),
+ TclNRAddCallback(interp, NRCommand, NULL, NULL,
NULL, NULL);
iPtr->deferredCallbacks = TOP_CB(interp);
- } else if (skipTailcalls) {
- iPtr->deferredCallbacks->data[1] = INT2PTR(skipTailcalls != 0);
}
}
void
+TclSkipTailcall(
+ Tcl_Interp *interp)
+{
+ Interp *iPtr = (Interp *) interp;
+
+ TclMarkTailcall(interp);
+ iPtr->deferredCallbacks->data[1] = INT2PTR(1);
+}
+
+void
+TclPushTailcallPoint(
+ Tcl_Interp *interp)
+{
+ TclNRAddCallback(interp, NRCommand, NULL, NULL, NULL, NULL);
+ ((Interp *) interp)->numLevels++;
+}
+
+void
TclSetTailcall(
Tcl_Interp *interp,
Tcl_Obj *listPtr)
@@ -8410,7 +8417,7 @@ TclNRTailcallEval(
* Perform the tailcall
*/
- TclDeferCallbacks(interp, 0);
+ TclMarkTailcall(interp);
TclNRAddCallback(interp, TailcallCleanup, listPtr, NULL, NULL,NULL);
iPtr->lookupNsPtr = (Namespace *) nsPtr;
return TclNREvalObjv(interp, objc-1, objv+1, 0, NULL);
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index 2753876..058590a 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -1914,7 +1914,7 @@ NsEnsembleImplementationCmdNR(
* Hand off to the target command.
*/
- TclDeferCallbacks(interp, /* skip tailcalls */ 1);
+ TclSkipTailcall(interp);
return TclNREvalObjEx(interp, copyPtr, TCL_EVAL_INVOKE, NULL,INT_MIN);
}
@@ -2122,7 +2122,7 @@ EnsembleUnknownCallback(
*/
Tcl_Preserve(ensemblePtr);
- TclDeferCallbacks (interp, /*skip tailcalls */ 1);
+ TclSkipTailcall(interp);
result = Tcl_EvalObjv(interp, paramc, paramv, 0);
if ((result == TCL_OK) && (ensemblePtr->flags & ENSEMBLE_DEAD)) {
if (!Tcl_InterpDeleted(interp)) {
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index af60a95..303bafd 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -3049,7 +3049,7 @@ TEBCresume(
TEBC_YIELD();
TclNRAddCallback(interp, TclClearRootEnsemble, NULL,NULL,NULL,NULL);
- TclDeferCallbacks(interp, /*skip tailcalls */ 1);
+ TclSkipTailcall(interp);
return TclNREvalObjEx(interp, objPtr, TCL_EVAL_INVOKE, NULL, INT_MIN);
/*
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 6cf594e..18768d9 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2805,7 +2805,11 @@ MODULE_SCOPE Tcl_ObjCmdProc TclNRYieldmObjCmd;
MODULE_SCOPE Tcl_ObjCmdProc TclNRYieldToObjCmd;
MODULE_SCOPE void TclSetTailcall(Tcl_Interp *interp, Tcl_Obj *tailcallPtr);
-MODULE_SCOPE void TclDeferCallbacks(Tcl_Interp *interp, int skipTailcall);
+MODULE_SCOPE void TclPushTailcallPoint(Tcl_Interp *interp);
+
+/* These two can be considered for the public api */
+MODULE_SCOPE void TclMarkTailcall(Tcl_Interp *interp);
+MODULE_SCOPE void TclSkipTailcall(Tcl_Interp *interp);
/*
* This structure holds the data for the various iteration callbacks used to
@@ -2880,7 +2884,6 @@ MODULE_SCOPE void TclAppendBytesToByteArray(Tcl_Obj *objPtr,
const unsigned char *bytes, int len);
MODULE_SCOPE int TclNREvalCmd(Tcl_Interp *interp, Tcl_Obj *objPtr,
int flags);
-MODULE_SCOPE void TclPushTailcallPoint(Tcl_Interp *interp);
MODULE_SCOPE void TclAdvanceContinuations(int *line, int **next,
int loc);
MODULE_SCOPE void TclAdvanceLines(int *line, const char *start,
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 2e90caf..d5d43ed 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -1800,7 +1800,7 @@ AliasNRCmd(
if (isRootEnsemble) {
TclNRAddCallback(interp, TclClearRootEnsemble, NULL, NULL, NULL, NULL);
}
- TclDeferCallbacks(interp, /* skip tailcalls */ 1);
+ TclSkipTailcall(interp);
return Tcl_NREvalObj(interp, listPtr, flags);
}
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index ee8aaa6..304487b 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -1945,7 +1945,7 @@ InvokeImportedNRCmd(
ImportedCmdData *dataPtr = clientData;
Command *realCmdPtr = dataPtr->realCmdPtr;
- TclDeferCallbacks(interp, /* skip tailcalls */ 1);
+ TclSkipTailcall(interp);
return Tcl_NRCmdSwap(interp, (Tcl_Command) realCmdPtr, objc, objv, 0);
}