/* Implement looping actions for CHILL.
- Copyright (C) 1992, 93, 1994, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1993, 1994, 1998, 1999, 2000
+ Free Software Foundation, Inc.
This file is part of GNU CC.
int flag_local_loop_counter = 1;
/* forward declarations */
-static int declare_temps PROTO((void));
-static int initialize_iter_var PROTO((void));
-static void maybe_skip_loop PROTO((void));
-static int bottom_loop_end_check PROTO((void));
-static int increment_temps PROTO((void));
-static tree build_temporary_variable PROTO((const char *, tree));
-static tree maybe_make_for_temp PROTO((tree, const char *, tree));
+static int declare_temps PARAMS ((void));
+static int initialize_iter_var PARAMS ((void));
+static void maybe_skip_loop PARAMS ((void));
+static int bottom_loop_end_check PARAMS ((void));
+static int increment_temps PARAMS ((void));
+static tree build_temporary_variable PARAMS ((const char *, tree));
+static tree maybe_make_for_temp PARAMS ((tree, const char *, tree));
#if 0
-static tree chill_unsigned_type PROTO((tree));
+static tree chill_unsigned_type PARAMS ((tree));
#endif
\f
/* In terms of the parameters passed to build_loop_iterator,
static LOOP *loopstack = (LOOP *)0;
\f
-#if 0
+/*
Here is a CHILL DO FOR statement:
FOR i := (i+1) TO (i+10) DO
To prevent changes to the start/end/step expressions from
-effecting the loop''s termination, and to make the loop end-check
+effecting the loop's termination, and to make the loop end-check
as simple as possible, we evaluate the step expression into
a temporary and compute a hidden iteration count before entering
-the loop''s body. User code cannot effect the counter, and the
+the loop's body. User code cannot effect the counter, and the
end-loop check simply decrements the counter and checks for zero.
The whole phrase FOR iter := ... TO end_exp can be repeated
The loop counter calculations need careful design since a loop
from MININT TO MAXINT must work, in the precision of integers.
-Here''s how it works, in C:
+Here's how it works, in C:
0) The DO ... OD loop is simply a block with
its own scope.
start_temp = start_exp
end_temp = end_exp
if (end_exp < start_exp) goto end_loop
- /* following line is all unsigned arithmetic */
+ // following line is all unsigned arithmetic
iter_var = (end_exp - start_exp) / step_exp
user_var = start_temp
loop_top:
start_temp = start_exp
end_temp = end_exp
if (end_exp > start_exp) goto end_loop
- /* following line is all unsigned arithmetic */
+ // following line is all unsigned arithmetic
iter_var = (start_exp - end_exp) / step_exp
user_var = start_temp
loop_top:
pop scope
- 5) The range loop, which iterates over a mode''s possible
+ 5) The range loop, which iterates over a mode's possible
values, works just like the above step loops, but with
- the start and end values taken from the mode''s lower
+ the start and end values taken from the mode's lower
and upper domain values.
\f
loc_ptr_temp as pointer to a composite base type
if array is varying
- iter_var = array''s length field
+ iter_var = array's length field
else
iter_var = sizeof array / sizeof base_type
loc_ptr_temp = &of highest or lowest indexable entry
pop scope
\f
-So, here''s the general DO FOR schema, as implemented here:
+So, here's the general DO FOR schema, as implemented here:
- expand_start_loop -- start the loop''s control scope
+ expand_start_loop -- start the loop's control scope
-- start scope for synthesized loop variables
declare_temps -- create, initialize temporary variables
maybe_skip_loop -- skip loop if end conditions unsatisfiable
initialize_iter_var -- initialize the iteration counter
- -- initialize user''s loop variable
+ -- initialize user's loop variable
expand_start_loop -- generate top-of-loop label
top_loop_end_check -- generate while code and/or
powerset find-a-bit function call
.
.
- . user''s loop body code
+ . user's loop body code
.
.
bottom_loop_end_check -- exit if counter has become zero
"the actions statement list in a do action, including any
loop counter and while control". This means that an exp-
ression in a WHILE control can include references to the
- loop counters created for the loop''s exclusive use.
+ loop counters created for the loop's exclusive use.
Example:
DCL a (1:10) INT;
...
OD;
The 'j' referenced in the while is the loc-identity 'j'
- created inside the loop''s scope, and NOT the 'j' declared
+ created inside the loop's scope, and NOT the 'j' declared
before the loop.
-#endif
+*/
\f
/*
* The following routines are called directly by the
ip->itype = DO_LOC_VARYING;
else
{
- error ("Loop's IN expression is not a composite object");
+ error ("loop's IN expression is not a composite object");
return;
}
}
if (TREE_CODE (TREE_TYPE (array_type)) == BOOLEAN_TYPE)
{
- error ("Can't iterate through array of BOOL");
+ error ("can't iterate through array of BOOL");
firstp->error_flag = 1;
return firstp->error_flag;
}