summaryrefslogtreecommitdiffstats
path: root/generic/tclLiteral.c
diff options
context:
space:
mode:
authordgp <dgp@noemail.net>2013-03-05 22:13:30 (GMT)
committerdgp <dgp@noemail.net>2013-03-05 22:13:30 (GMT)
commit4343401381805fd18b62e72b84ff6a4e27b2be32 (patch)
tree75bdcad5e3dd07490f2ff56d5d37a926d77e61a2 /generic/tclLiteral.c
parent59d31c99d1ecc6300cd716856561a7dbe40eef16 (diff)
downloadtcl-4343401381805fd18b62e72b84ff6a4e27b2be32.zip
tcl-4343401381805fd18b62e72b84ff6a4e27b2be32.tar.gz
tcl-4343401381805fd18b62e72b84ff6a4e27b2be32.tar.bz2
New internal routine TclFetchLiteral() for better CompileEnv encapsulation.
FossilOrigin-Name: b98f550ddf6e9702e73ed101ccecf3053773e623
Diffstat (limited to 'generic/tclLiteral.c')
-rw-r--r--generic/tclLiteral.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index bd5fe73..e2ee9b4 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.c
@@ -305,6 +305,33 @@ TclCreateLiteral(
/*
*----------------------------------------------------------------------
*
+ * TclFetchLiteral --
+ *
+ * Fetch from a CompileEnv the literal value identified by an index
+ * value, as returned by a prior call to TclRegisterLiteral().
+ *
+ * Results:
+ * The literal value, or NULL if the index is out of range.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tcl_Obj *
+TclFetchLiteral(
+ CompileEnv *envPtr, /* Points to the CompileEnv from which to
+ * fetch the registered literal value. */
+ unsigned int index) /* Index of the desired literal, as returned
+ * by prior call to TclRegisterLiteral() */
+{
+ if (index >= envPtr->literalArrayNext) {
+ return NULL;
+ }
+ return envPtr->literalArrayPtr[index].objPtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TclRegisterLiteral --
*
* Find, or if necessary create, an object in a CompileEnv literal array