|
|
@@ -52,6 +52,30 @@
|
|
|
|
|
|
A simple heuristic is applied to decide whether a recognised for-loop will
|
|
|
be unrolled: the resulting number of statements must not be larger than 20.
|
|
|
+
|
|
|
+ Note that since programmer-defined for-loops are also transformed into
|
|
|
+ while-loops, these are recognized by the compiler as well (as long as the
|
|
|
+ loop has constant boundaries). For example:
|
|
|
+
|
|
|
+{v extern void printInt(int val);
|
|
|
+export int main() \{
|
|
|
+ for (int i = 0, 10, 2)
|
|
|
+ printInt(i);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+\} v}
|
|
|
+
|
|
|
+ which is transformed into:
|
|
|
+
|
|
|
+{v extern void printInt(int val);
|
|
|
+export int main() \{
|
|
|
+ printInt(0);
|
|
|
+ printInt(2);
|
|
|
+ printInt(4);
|
|
|
+ printInt(6);
|
|
|
+ printInt(8);
|
|
|
+ return 0;
|
|
|
+\} v}
|
|
|
*)
|
|
|
|
|
|
(** Main phase function, called by {!Main}. *)
|