summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-08-01 14:36:30 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-08-01 14:36:30 (GMT)
commit374022fc5dab400eaec3c8af83d78f75e53a488f (patch)
treeae5874a03d3b90d627822a2e976d7d550c566f85
parent039b5c21864604ac410777f49e11d9a11b255d06 (diff)
downloadtcl-374022fc5dab400eaec3c8af83d78f75e53a488f.zip
tcl-374022fc5dab400eaec3c8af83d78f75e53a488f.tar.gz
tcl-374022fc5dab400eaec3c8af83d78f75e53a488f.tar.bz2
Correction and commentary in the details of ensemble compiling.
-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;
}