test
[repair.git] / Repair / RepairCompiler / MCC / IR / RelationExpr.java
index b966628be324d52be7701c935b1172ed867a7d02..cc2d5de1e7a53ef62d1fcac26e11c66f42f94f5c 100755 (executable)
@@ -22,15 +22,21 @@ public class RelationExpr extends Expr {
 
     public void generate(CodeWriter writer, VarDescriptor dest) {
         VarDescriptor domain = VarDescriptor.makeNew("domain");
+        String found = (VarDescriptor.makeNew("found")).getSafeSymbol();
         expr.generate(writer, domain);
-        writer.outputline(relation.getRange().getType().getSafeSymbol() + " " + dest.getSymbol() + " = " + relation.getSafeSymbol() + "_hash->get(" + domain.getSafeSymbol() + ");");
+        writer.outputline(relation.getRange().getType().getGenerateType().getSafeSymbol() + " " + dest.getSafeSymbol() + ";");
+        writer.outputline("int " + found + " = " + relation.getSafeSymbol() + "_hash->get(" + domain.getSafeSymbol() + ", " + dest.getSafeSymbol() + ");");
+        writer.outputline("if (!" + found + ") { maybe = 1; }");
     }
 
-    public void generate_set(CodeWriter writer, VarDescriptor dest) {
-        VarDescriptor domain = VarDescriptor.makeNew("domain");
-        expr.generate(writer, domain);
-        writer.outputline(relation.getRange().getType().getSafeSymbol() + " " + dest.getSymbol() + " = " + relation.getSafeSymbol() + "_hash->get(" + domain.getSafeSymbol() + ");");
-    }
+    // #TBD#: don't think this method is needed (or even called/referenced)
+    /*
+      public void generate_set(CodeWriter writer, VarDescriptor dest) {
+      VarDescriptor domain = VarDescriptor.makeNew("domain");
+      expr.generate(writer, domain);
+      writer.outputline(relation.getRange().getType().getGenerateType().getSafeSymbol() + " " + dest.getSafeSymbol() + " = " + relation.getSafeSymbol() + "_hash->get(" + domain.getSafeSymbol() + ");");
+      }
+    */
 
     public void prettyPrint(PrettyPrinter pp) {
         expr.prettyPrint(pp);
@@ -57,7 +63,7 @@ public class RelationExpr extends Expr {
             
             if (rangetype != type) {
                 sa.getErrorReporter().report(null, "Type of left side of relation operator '.' is '" + type.getSymbol() + 
-                                    "' but must be the '" + rangetype.getSymbol() + 
+                                    "' but must be '" + rangetype.getSymbol() + 
                                     "', the type of the range of the relation '" + relation.getSymbol() + "'");
                 return null;
             }
@@ -69,8 +75,8 @@ public class RelationExpr extends Expr {
             
             if (domaintype != type) {
                 sa.getErrorReporter().report(null, "Type of left side of relation operator '.' is '" + type.getSymbol() + 
-                                    "' but must be the '" + domaintype.getSymbol() + 
-                                    "', the type of the range of the relation '" + relation.getSymbol() + "'");
+                                    "' but must be '" + domaintype.getSymbol() + 
+                                    "', the type of the domain of the relation '" + relation.getSymbol() + "'");
                 return null;
             }