Fixed lot of random bugs. Added code generate strings for expr's.
[repair.git] / Repair / RepairCompiler / MCC / IR / LogicStatement.java
index 43fb985118580afedc3db675b03fbfe9a9f287b0..aa093b4da76f4c2841488acf2abf9f753e05ad17 100755 (executable)
@@ -7,7 +7,41 @@ public class LogicStatement {
     public static final Operation AND = new Operation("AND");
     public static final Operation OR = new Operation("OR");
     public static final Operation NOT = new Operation("NOT");
+
+    public String name() {
+       String name=left.name();
+       name+=op.toString();
+       if (right!=null)
+           name+=right.name();
+       return name;
+    }
+
+    public Set getInversedRelations() {
+        if (left == null) {
+            throw new IRException();
+        }
+        Set set = left.getInversedRelations();
+        if (right != null) {
+            set.addAll(right.getInversedRelations());
+        }
+        return set;
+    }
     
+    public DNFConstraint constructDNF() {
+       if (op==AND) {
+           DNFConstraint leftd=left.constructDNF();
+           DNFConstraint rightd=right.constructDNF();
+           return leftd.and(rightd);
+       } else if (op==OR) {
+           DNFConstraint leftd=left.constructDNF();
+           DNFConstraint rightd=right.constructDNF();
+           return leftd.or(rightd);
+       } else if (op==NOT) {
+           DNFConstraint leftd=left.constructDNF();
+           return leftd.not();
+       } else throw new Error();
+    }
+
     public static class Operation {
         private final String name;
         private Operation(String opname) { name = opname; }