Bugs with generating ands and ors...ahh.
[repair.git] / Repair / RepairCompiler / MCC / IR / OpExpr.java
index 89bc976ca1866a5a6afcbc240d214dd75f35d3f2..23644364db60649b6a49b0e227405be1b741fa91 100755 (executable)
@@ -8,6 +8,34 @@ public class OpExpr extends Expr {
     Expr right;
     Opcode opcode;
 
+    public Expr getUpper() {
+       Expr lupper=left.getUpper();
+       if (lupper==null)
+           return null;
+       if (right!=null) {
+           Expr rupper=right.getUpper();
+           if (rupper==null)
+               return null;
+           OpExpr oe=new OpExpr(this.opcode,lupper,rupper);
+           oe.td = ReservedTypeDescriptor.INT;
+           return oe;
+       } else return lupper;
+    }
+
+    public Expr getLower() {
+       Expr llower=left.getLower();
+       if (llower==null)
+           return null;
+       if (right!=null) {
+           Expr rlower=right.getLower();
+           if (rlower==null)
+               return null;
+           OpExpr oe=new OpExpr(this.opcode,llower,rlower);
+           oe.td = ReservedTypeDescriptor.INT;
+           return oe;
+       } else return llower;
+    }
+
     public boolean isSafe() {
        if (right==null)
            return left.isSafe();
@@ -156,9 +184,6 @@ public class OpExpr extends Expr {
        return opcode;
     }
 
-
-
-
     public boolean equals(Map remap, Expr e) {
        if (e==null||!(e instanceof OpExpr))
            return false;
@@ -310,7 +335,7 @@ public class OpExpr extends Expr {
            if ((opcode==Opcode.OR)||
                (opcode==Opcode.AND)) {
                writer.outputline("int "+lm.getSafeSymbol()+"=maybe;");
-               writer.outputline("int maybe=0;");
+               writer.outputline("maybe=0;");
            }
 
             rd = VarDescriptor.makeNew("rightop");
@@ -328,12 +353,12 @@ public class OpExpr extends Expr {
         } else if (opcode == Opcode.AND) {
            writer.outputline("int "+rm.getSafeSymbol()+"=maybe;");
            writer.outputline("maybe = (" + ld.getSafeSymbol() + " && " + rm.getSafeSymbol() + ") || (" + rd.getSafeSymbol() + " && " + lm.getSafeSymbol() + ") || (" + lm.getSafeSymbol() + " && " + rm.getSafeSymbol() + ");");
-           writer.outputline(dest.getSafeSymbol() + " = " + ld.getSafeSymbol() + " && " + rd.getSafeSymbol() + ";");
+           writer.outputline("int "+dest.getSafeSymbol() + " = " + ld.getSafeSymbol() + " && " + rd.getSafeSymbol() + ";");
        } else if (opcode == Opcode.OR) {
            writer.outputline("int "+rm.getSafeSymbol()+"=maybe;");
            writer.outputline("maybe = (!" + ld.getSafeSymbol() + " && " + rm.getSafeSymbol() + ") || (!" + rd.getSafeSymbol() +
                              " && " + lm.getSafeSymbol() + ") || (" + lm.getSafeSymbol() + " && " + rm.getSafeSymbol() + ");");
-           writer.outputline(dest.getSafeSymbol() + " = " + ld.getSafeSymbol() + " || " + rd.getSafeSymbol() +
+           writer.outputline("int "+dest.getSafeSymbol() + " = " + ld.getSafeSymbol() + " || " + rd.getSafeSymbol() +
                              ";");
        } else if (opcode != Opcode.NOT) { /* two operands */
             assert rd != null;