summaryrefslogtreecommitdiffstats
path: root/generic/tclEnsemble.c
diff options
context:
space:
mode:
authordgp <dgp@noemail.net>2014-08-01 14:36:30 (GMT)
committerdgp <dgp@noemail.net>2014-08-01 14:36:30 (GMT)
commitfa38ddcd7ec32605a19a0df6f20c7184d944abf1 (patch)
treeb79ac3b6e77515f4a96505f2ef220a7024f14524 /generic/tclEnsemble.c
parentdbd61f34b50ea39dfbfd70d027d653cbf1faffde (diff)
downloadtcl-fa38ddcd7ec32605a19a0df6f20c7184d944abf1.zip
tcl-fa38ddcd7ec32605a19a0df6f20c7184d944abf1.tar.gz
tcl-fa38ddcd7ec32605a19a0df6f20c7184d944abf1.tar.bz2
Correction and commentary in the details of ensemble compiling.
FossilOrigin-Name: 2bee22315abad7ebcfe4e29265eb83544a0b7adb
Diffstat (limited to 'generic/tclEnsemble.c')
-rw-r--r--generic/tclEnsemble.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index 022dafa..763f5a0 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -3019,8 +3019,24 @@ TclCompileEnsemble(
cmdPtr = oldCmdPtr;
depth--;
}
- (void) Tcl_ListObjReplace(NULL, replaced, depth, 2, 0, NULL);
}
+ /*
+ * The length of the "replaced" list must be depth-1. Trim back
+ * any extra elements that might have been appended by failing
+ * pathways above.
+ */
+ (void) Tcl_ListObjReplace(NULL, replaced, depth-1, INT_MAX, 0, NULL);
+
+ /*
+ * TODO: Reconsider whether we ought to call CompileToInvokedCommand()
+ * when depth==1. In that case we are choosing to emit the
+ * INST_INVOKE_REPLACE bytecode when there is in fact no replacing
+ * to be done. It would be equally functional and presumably more
+ * performant to fall through to cleanup below, return TCL_ERROR,
+ * and let the compiler harness emit the INST_INVOKE_STK
+ * implementation for us.
+ */
+
CompileToInvokedCommand(interp, parsePtr, replaced, cmdPtr, envPtr);
ourResult = TCL_OK;
}