From 27f21e8c049b0cd20fd2d4e2fd9b96cad6c910cc Mon Sep 17 00:00:00 2001 From: dsmith Date: Mon, 6 Nov 2006 16:05:50 +0000 Subject: 2006-11-06 David Smith Added "limit EXP" support to foreach statements. * translate.cxx (c_tmpcounter::visit_foreach_loop): Handles "limit" member variable. (c_unparser::visit_foreach_loop): Ditto. * staptree.cxx (foreach_loop::print): Prints "limit EXP" addition. (traversing_visitor::visit_foreach_loop): Handles "limit" member variable. (deep_copy_visitor::visit_foreach_loop): Ditto. * staptree.h (struct foreach_loop): Added "limit" member variable. * stap.1.in: Added documentation for the "limit EXP" addition to foreach statement. * parse.cxx (lexer::scan): Added "limit" keyword for foreach statements. (parser::parse_foreach_loop): Parses "limit" keyword for foreach statements. * elaborate.cxx (symresolution_info::visit_foreach_loop): Handles "limit" member variable. (typeresolution_info::visit_foreach_loop): Ditto. --- stap.1.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'stap.1.in') diff --git a/stap.1.in b/stap.1.in index 7b572943..8b3f7409 100644 --- a/stap.1.in +++ b/stap.1.in @@ -304,15 +304,20 @@ While integer-valued EXP evaluates to non-zero, execute STMT. Execute EXP1 as initialization. While EXP2 is non-zero, execute STMT, then the iteration expression EXP3. .TP -.BR foreach " (VAR " in " ARRAY) STMT" +.BR foreach " (VAR " in " ARRAY [ "limit " EXP ]) STMT" Loop over each element of the named global array, assigning current key to VAR. The array may not be modified within the statement. By adding a single .BR + " or " \- operator after the VAR or the ARRAY identifier, the iteration will proceed in a sorted order, by ascending or descending index or value. + +Using the optional +.BR limit +keyword limits the number of loop iterations to EXP times. EXP is +evaluted once at the beginning of the loop. .TP -.BR foreach " ([VAR1, VAR2, ...] " in " ARRAY) STMT" +.BR foreach " ([VAR1, VAR2, ...] " in " ARRAY [ "limit " EXP ]) STMT" Same as above, used when the array is indexed with a tuple of keys. A sorting suffix may be used on at most one VAR or ARRAY identifier. .TP -- cgit