+
+static void WhileStatement (void)
+/* Handle the 'while' statement */
+{
+ /* Get the loop control labels */
+ unsigned loop = GetLocalLabel ();
+ unsigned lab = GetLocalLabel ();
+
+ /* Skip the while token */
+ NextToken ();
+
+ /* Add the loop to the loop stack */
+ AddLoop (oursp, loop, lab, 0, 0);
+
+ /* Define the head label */
+ g_defcodelabel (loop);
+
+ /* Test the loop condition */
+ test (lab, 0);
+
+ /* If the statement following the while loop is empty, that is, we have
+ * something like "while (1) ;", the test function ommitted the jump as
+ * an optimization. Since we know, the condition codes are set, we can
+ * do another small optimization here, and use a conditional jump
+ * instead an absolute one.
+ */
+ if (CurTok.Tok == TOK_SEMI) {
+ /* Use a conditional jump */
+ g_truejump (CF_NONE, loop);
+ /* Shortcut */
+ NextToken ();
+ } else {
+ /* There is code inside the while loop, parse the body */
+ Statement ();
+ g_jump (loop);
+ g_defcodelabel (lab);