summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-07-08 19:29:01 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-07-08 19:29:01 (GMT)
commit8127bc5dd162ce6a44aa4bdcb28f378ae8663514 (patch)
treefa364db0332ba88a570deefc93856e5d8918510b /generic/tclCompile.c
parentd668a84e6108d23992a0dcfa20714ce1c4be3037 (diff)
downloadtcl-8127bc5dd162ce6a44aa4bdcb28f378ae8663514.zip
tcl-8127bc5dd162ce6a44aa4bdcb28f378ae8663514.tar.gz
tcl-8127bc5dd162ce6a44aa4bdcb28f378ae8663514.tar.bz2
Factor out compiling the Command literal.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 1958d47..a1ad5c8 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -1761,6 +1761,23 @@ ExpandRequested(
}
static void
+CompileCmdLiteral(
+ Tcl_Interp *interp,
+ Tcl_Obj *cmdObj,
+ CompileEnv *envPtr)
+{
+ int numBytes;
+ const char *bytes = Tcl_GetStringFromObj(cmdObj, &numBytes);
+ int cmdLitIdx = TclRegisterNewCmdLiteral(envPtr, bytes, numBytes);
+ Command *cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, cmdObj);
+
+ if (cmdPtr) {
+ TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLitIdx), cmdPtr);
+ }
+ TclEmitPush(cmdLitIdx, envPtr);
+}
+
+static void
CompileInvocation(
Tcl_Interp *interp,
Tcl_Token *tokenPtr,
@@ -1773,17 +1790,7 @@ CompileInvocation(
ExtCmdLoc *eclPtr = envPtr->extCmdMapPtr;
if (cmdObj) {
- int numBytes;
- const char *bytes = Tcl_GetStringFromObj(cmdObj, &numBytes);
- int cmdLitIdx = TclRegisterNewCmdLiteral(envPtr, bytes, numBytes);
- Command *cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, cmdObj);
-
- if (cmdPtr) {
- TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLitIdx),
- cmdPtr);
- }
- TclEmitPush(cmdLitIdx, envPtr);
-
+ CompileCmdLiteral(interp, cmdObj, envPtr);
wordIdx = 1;
tokenPtr += tokenPtr->numComponents + 1;
}
@@ -1839,17 +1846,7 @@ CompileExpanded(
StartExpanding(envPtr);
if (cmdObj) {
- int numBytes;
- const char *bytes = Tcl_GetStringFromObj(cmdObj, &numBytes);
- int cmdLitIdx = TclRegisterNewCmdLiteral(envPtr, bytes, numBytes);
- Command *cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, cmdObj);
-
- if (cmdPtr) {
- TclSetCmdNameObj(interp,
- TclFetchLiteral(envPtr, cmdLitIdx), cmdPtr);
- }
- TclEmitPush(cmdLitIdx, envPtr);
-
+ CompileCmdLiteral(interp, cmdObj, envPtr);
wordIdx = 1;
tokenPtr += tokenPtr->numComponents + 1;
}