requires the unEx method of a Cx object (Web hosting company)
Friday, August 31st, 2007requires the unEx method of a Cx object so that a 1 (for true) or 0 (for false) can be stored into flag. Program 7.3 shows the class Cx. The unEx method is of particular interest. To convert a “conditional” into a “value expression”, we invent a new temporary r and new labels t and f. Then we make a Tree.Stm that moves the value 1 into r, and a conditional jump unCx(t, f) that implements the conditional. If the condition is false, then 0 is moved into r; if it is true, then execution proceeds at t and the second move is skipped. The result of the whole thing is just the temporary r containing zero or one. PROGRAM 7.3: The Cx class. abstract class Cx extends Exp { Tree.Exp unEx() { Temp r = new Temp(); Label t = new Label(); Label f = new Label(); return new Tree.ESEQ( new Tree.SEQ(new Tree.MOVE(new Tree.TEMP(r), new Tree.CONST(1)), new Tree.SEQ(unCx(t,f), new Tree.SEQ(new Tree.LABEL(f), new Tree.SEQ(new Tree.MOVE(new Tree.TEMP(r), new Tree.CONST(0)), new Tree.LABEL(t))))), new Tree.TEMP(r)); } abstract Tree.Stm unCx(Label t, Label f); Tree.Stm unNx() { … } } The unCx method is still abstract: We will discuss this later, with the translation of comparison operators. But the unEx and unNx methods can still be implemented in terms of the unCx method. We have shown unEx; we will leave unNx (which is simpler) as an exercise. The unCx method of class Ex is left as an exercise. It’s helpful to have unCx treat the cases of CONST 0and CONST 1 specially, since they have particularly simple and efficient translations. Class Nx’s unEx and unCx methods need not be implemented, since these cases should never occur in compiling a well-typed MiniJava program. SIMPLE VARIABLES For a simple variable v declared in the current procedure’s stack frame, we translate it as where k is the offset of v within the frame and TEMP fp is the frame-pointer register. For the
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.