Go to the previous, next section.

WHILE and DO Loops

A more general WHILE loop can be created using the builder's WHILE() and DO() functions (which are equivalent). The first argument to these functions is the test and the second argument is the body of the loop. The builder's WHILE() and DO() functions get translated to a SUIF LOOP macro instruction.

For exampe, the following C loop:

        i = 0;
        while(i<100) {
           i = i + 1;
           ...;
        }

Can be created by the following builder structure:

        block i(block::new_sym(cst_int, i));
        block code(block(block(i = block(0)),
                  block::WHILE(block(i < block(100)),
                               block(block(i = i + block(1)),
                                     block(...)))));

Go to the previous, next section.