summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-12-12 09:13:39 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-12-12 09:13:39 (GMT)
commit6665e28f718ef3c403652ca551b6cadd3a3318aa (patch)
tree0452907d177676bbc3258a647e4f3a616961101a /generic/tclCompile.c
parent66b561ac5eb7ff1750f8003c6a14a2c7ae52963b (diff)
parent2b1bafdd8a2fca08d2d7b57f68cc803f83dba72e (diff)
downloadtcl-6665e28f718ef3c403652ca551b6cadd3a3318aa.zip
tcl-6665e28f718ef3c403652ca551b6cadd3a3318aa.tar.gz
tcl-6665e28f718ef3c403652ca551b6cadd3a3318aa.tar.bz2
merge trunk; document added instructions
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 418dd1c..14d9451 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -545,6 +545,34 @@ InstructionDesc const tclInstructionTable[] = {
/* Drops an element from the auxiliary stack, popping stack elements
* until the matching stack depth is reached. */
+ /* New foreach implementation */
+ {"foreach_start", 5, +2, 1, {OPERAND_AUX4}},
+ /* Initialize execution of a foreach loop. Operand is aux data index
+ * of the ForeachInfo structure for the foreach command. It pushes 2
+ * elements which hold runtime params for foreach_step, they are later
+ * dropped by foreach_end together with the value lists. NOTE that the
+ * iterator-tracker and info reference must not be passed to bytecodes
+ * that handle normal Tcl values. NOTE that this instruction jumps to
+ * the foreach_step instruction paired with it; the stack info below
+ * is only nominal.
+ * Stack: ... listObjs... => ... listObjs... iterTracker info */
+ {"foreach_step", 1, 0, 0, {OPERAND_NONE}},
+ /* "Step" or begin next iteration of foreach loop. Assigns to foreach
+ * iteration variables. May jump to straight after the foreach_start
+ * that pushed the iterTracker and info values. MUST be followed
+ * immediately by a foreach_end.
+ * Stack: ... listObjs... iterTracker info =>
+ * ... listObjs... iterTracker info */
+ {"foreach_end", 1, 0, 0, {OPERAND_NONE}},
+ /* Clean up a foreach loop by dropping the info value, the tracker
+ * value and the lists that were being iterated over.
+ * Stack: ... listObjs... iterTracker info => ... */
+ {"lmap_collect", 1, -1, 0, {OPERAND_NONE}},
+ /* Appends the value at the top of the stack to the list located on
+ * the stack the "other side" of the foreach-related values.
+ * Stack: ... collector listObjs... iterTracker info value =>
+ * ... collector listObjs... iterTracker info */
+
{"strtrim", 1, -1, 0, {OPERAND_NONE}},
/* [string trim] core: removes the characters (designated by the value
* at the top of the stack) from both ends of the string and pushes
@@ -579,17 +607,6 @@ InstructionDesc const tclInstructionTable[] = {
* the default (extended "C" locale) rules.
* Stack: ... string => ... newString */
- /* New foreach implementation */
- {"foreach_start", 5, +2, 1, {OPERAND_AUX4}},
- /* Initialize execution of a foreach loop. Operand is aux data index
- * of the ForeachInfo structure for the foreach command. It pushes 2
- * elements which hold runtime params for foreach_step, they are later
- * dropped by foreach_end together with the value lists. */
- {"foreach_step", 1, 0, 0, {OPERAND_NONE}},
- /* "Step" or begin next iteration of foreach loop. */
- {"foreach_end", 1, 0, 0, {OPERAND_NONE}},
- {"lmap_collect", 1, -1, 0, {OPERAND_NONE}},
-
{NULL, 0, 0, 0, {OPERAND_NONE}}
};