The DO- WHILE LOOP

Loops are used in programming to automate repetitious tasks.  There are different kind of circuits that are used in programming. In Java, the loops that are used include The do-while loop and the while loop. The while and the do-while loop statements can be said to be conditional statements. They execute if a detailed condition results in a report are accurate. The difference between the while, do-while loop and the if loop, is that the if loop evaluates once and the while and the do-while loop runs multiple times until the condition no longer evaluates to true.

In our compiler babycino, it lacks the do-while loop although the while loop is available. The do-while loop should/ must return a Boolean value. In our condition, the compiler can establish the Boolean expression but the requirement that required continued processing lacks. There are other loops like for statement. This loop executes for a given number of times. It is possible to forecast the result of this loop unlike the do-while and while loop whose are conditionally based which makes it difficult to know the number of times the loop will run.

In the babycino compiler, the while loop is used to code up the search code, under the TAC block. The system continues even into the TAC flow analysis. The loop is used in conjunction with for loop, if else loop and if loop. The while loop is considered the most basic loop in Java and JavaScript. In the coding of the babycino, the coder first imports java array list and creates a public class TAC Block and a TACOp as a register to hold the results. The code that follows allows the coder to register for the block, after which he gets the results for the block. There is the use of for loop, to get the highest-valued as shown in the code below.

do (op. get Type ()) {

// Unconditional jumps can’t fall through to the next operation.

while JMP:

return Collections. Singleton List (this. Label Locs. Get (op. get Label ()));

// Conditional jumps can fall through.

while JZ:

int dest = this. Label Locs. Get (op. get Label ());

if (last) {

return Collections. Singlet on List (dest);

}

else {

return pair List (dest, n+1);

}

// Returns can’t go anywhere (within the block).

while RET:

return Collections .empty List ();

By use of a three-address code operation, the coder then creates a Public class TACOp, that is meant to reduce the classes. The TACOp then allows the creation of three register arguments, strings r1,r2,r3 and a label argument string label.  Due to the constructor being private, TACOp can only be created by the static. After the creation, the need to return the value of the TACOp fields lead to the creation of a Public class TACOpType that is allowed to get the information from the Strings created as shown below.

Do boolean[] seen = new Boolean [(this .code .size ())];

Array Deque <Integer> next = new Array Deque <Integer> ();

Next .add All (this. Succ (n));

while (!next .is Empty()) {

int here = next. remove();

// Process each location only once to avoid an infinite loop.

if (seen [here]) {

continue;

}

Seen [here] = true;

// A use of the register means the definition was not redundant.

if (this. Uses (here) .contains (def)) {

return false;

}

The creation of the Public Static that move the r1, r2, r3 to TACOpType, loads, stores, binop and immed them to return new. The public static also allows TACop to offset, parameter, call, retain and even label string r1, r2, r3, string label. It thus enables the manipulation of the strings. The string can thus be converted from string presentation to the binary presentation. To do so, the Switch case can be used and also the do – while loop. In our case, we prefer the use of the do- while. The do while will allow the change and use of the arithmetic equation until the result is not accurate as below

Array Deque <Integer> next = new Array Deque <Integer> ();

Next .add All (this. Succ (n));

while (!next .is Empty()) {

int here = next. remove();

// Process each location only once to avoid an infinite loop.

if (seen [here]) {

continue;

}

Seen [here] = true;

// A use of the register means the definition was not redundant.

if (this. Uses (here) .contains (def)) {

return false;

To check whether the data type that is input is an array or Boolean or Integer, the coder uses the If else loop. The loop here can be interchanged with the do-while loop which will allow the code to look for the data type of all the available data and then return the result as an object.  Besides, the do- while loop may also be used to attest the quality of two data types.

The do- while loop is also usable in the CGenerator code. Here the switch case is used to give the union and bring about the right behaviour. The Do – while loop can be used to allow the correct usage of the different fields. It poses a problem to implement the code, but theoretically, it can be done.  The basic idea of converting any flow of control statement to a three-address code is to be able to stimulate the “branching” of the flow of control.  It is done through the skipping of different parts of the code (label) to mimic the mixed flow of the branches as indicated.

do (op. get Type ()) {

// Unconditional jumps can’t fall through to the next operation.

while JMP:

return Collections. Singleton List (this. Label Locs. Get (op. get Label ()));

// Conditional jumps can fall through.

while JZ:

int dest = this. Label Locs. Get (op. get Label ());

if (last) {

return Collections. Singlet on List (dest);

}

else {

return pair List (dest, n+1);

}

// Returns can’t go anywhere (within the block).

while RET:

return Collections .empty List ();

 

 

The code is converted into a three-address code by the use of the function: Move, Immed, Load, Store, Binop, Param, Call, Ret, Label, Jmp, Jz, and Malloc. Malloc is used as it zeros the memory which allocated the correct default values for all the Java types as below:

private List <String>  defs (int n) {

TACOp op = this .code. get (n);

do (op .get Type ()) {

            // These operations define r1.

while MOV:

while IMMED:

while LOAD:

while BINOP:

while MALLOC:

while READ:

while ADDROF:

return Collections .single ton List (op. get R1 ());

 

            // A call may put a result in r0.

case CALL:

return Collections .single ton List (“r0”);

 

            // Everything else defines nothing.

default:

return Collections .empty List();

}

Some attributes are associated with the non-terminals for the code generation of the do while loop. Code- contains the generated three-address code, contains the label to which a jump takes place if the Boolean expression associated evaluates to “true”, contains the label to which a jump takes place if the Boolean expression associated evaluates to “False”, contains the label/ address pointing to the beginning of the code chunk for the statement generated if any by the non-terminal as explained by the code below

private List <String> uses (int n) {

TACOp op = this .code .get(n);

While (op .get Type ()) {

// Uses r1 only:

While PARAM:

while CALL:

while JZ:

while WRITE:

return Collections .single ton  List(op.getR1());

     // Uses r2 only:

while MOV:

while LOAD:

while MALLOC:

return Collections. Single ton List(op.getR2());

 

            // Uses r1 and r2:

While STORE:

return pair List(op.getR1(), op.getR2());

 

            // Uses r2 and r3:

While BINOP:

return pair List(op.getR2(), op.getR3());

 

            // A return implicitly uses r0.

while RET:

return Collections. Single ton List (“r0”);

 

            // Anything else uses nothing:

default:

return Collections .empty List();

}

}

 

The testing of a Do while loop only accepts to execute when the Boolean condition is met, and there is ni infinite loop. If the test does not evaluate to false, it will mean that the loop has no end and thus it becomes an endless loop. The infinite do- while loop is similar to that of the while loop. In our program the testing of the loop mostly when searching for something. During the coding process, the compiler was coded to accept the do- while codes to allow the loops code.

The Do- while the body is executed once before the test expression is checked. After the test expression has been verified, then the loops occur until the condition goes to negative.  The evaluation of the condition to true leads to the execution of the codes that are in between the body and also the testing of the expression until the test expression is evaluated as false. After the test express is estimated to false, the do- while loop is terminated.