fixed problems with CDL.cup
authordroy <droy>
Mon, 7 Jul 2003 19:11:51 +0000 (19:11 +0000)
committerdroy <droy>
Mon, 7 Jul 2003 19:11:51 +0000 (19:11 +0000)
Repair/RepairCompiler/MCC/IR/Opcode.java
Repair/RepairCompiler/MCC/IR/SemanticChecker.java

index 79a1666a7346d073b0ce152287307c10bedd49e1..6dc95d793ac28b91cca2ff101cb7002d8a91cf65 100755 (executable)
@@ -24,4 +24,38 @@ public class Opcode {
     public static final Opcode OR = new Opcode("||");
     public static final Opcode NOT = new Opcode("!");
 
     public static final Opcode OR = new Opcode("||");
     public static final Opcode NOT = new Opcode("!");
 
+    public static Opcode decodeFromString(String opname) {
+        Opcode opcode;
+
+        if (opname.equals("add")) {
+            opcode = Opcode.ADD;
+        } else if (opname.equals("sub")) {
+            opcode = Opcode.SUB;
+        } else if (opname.equals("mult")) {
+            opcode = Opcode.MULT;
+        } else if (opname.equals("div")) {
+            opcode = Opcode.DIV;
+        } else if (opname.equals("and")) {
+            opcode = Opcode.AND;
+        } else if (opname.equals("or")) {
+            opcode = Opcode.OR;
+        } else if (opname.equals("not")) {
+            opcode = Opcode.NOT;
+        } else if (opname.equals("gt")) {
+            opcode = Opcode.GT;
+        } else if (opname.equals("ge")) {
+            opcode = Opcode.GE;
+        } else if (opname.equals("lt")) {
+            opcode = Opcode.LT;
+        } else if (opname.equals("le")) {
+            opcode = Opcode.LE;
+        } else if (opname.equals("eq")) {
+            opcode = Opcode.EQ;
+        } else if (opname.equals("ne")) {
+            opcode = Opcode.NE;
+        } else {
+            return null;
+        }
+    }
+
 }
 }
index be4e07d6e94f23ae39cd210dc84513a350633f9f..a20c5a63f648fe23bc7480568256f4e2a1d6bed5 100755 (executable)
@@ -582,23 +582,7 @@ public class SemanticChecker {
             return null;
         }
 
             return null;
         }
 
-        if (pn.getChild("comparison") != null) {
-            ParseNode cn = pn.getChild("comparison");
-            
-            /* get the expr's */
-            Expr left = parse_expr(cn.getChild("left").getChild("expr"));
-            Expr right = parse_expr(cn.getChild("right").getChild("expr"));
-
-            if ((left == null) || (right == null)) {
-                return null;
-            }
-
-            /* get comparison operator */
-            String comparison = cn.getChild("compare").getTerminal();
-            assert comparison != null;
-                         
-            return new ComparisonPredicate(comparison, left, right);
-        } else if (pn.getChild("inclusion") != null) {
+        if (pn.getChild("inclusion") != null) {
             ParseNode in = pn.getChild("inclusion");
             
             /* get quantiifer var */
             ParseNode in = pn.getChild("inclusion");
             
             /* get quantiifer var */
@@ -616,6 +600,44 @@ public class SemanticChecker {
             }
 
             return new InclusionPredicate(vd, setexpr);
             }
 
             return new InclusionPredicate(vd, setexpr);
+        } else if (pn.getChild("sizeof") != null) {
+            ParseNode sizeof = pn.getChild("sizeof");
+            
+            /* get set expr */
+            SetExpr setexpr = parse_setexpr(sizeof.getChild("setexpr"));
+
+            if (setexpr == null) {
+                return null;
+            }
+
+            /* get comparison operator */
+            String compareop = sizeof.getChild("compare").getTerminal();
+            Opcode opcode = Opcode.decodeFromString(opname);
+
+            if (opcode == null) {
+                er.report(pn, "Unsupported operation: " + opname);
+                return null;
+            }
+
+
+
+            return new InclusionPredicate(vd, setexpr);
+        } else if (pn.getChild("comparison") != null) {
+            ParseNode cn = pn.getChild("comparison");
+            
+            /* get the expr's */
+            Expr left = parse_expr(cn.getChild("left").getChild("expr"));
+            Expr right = parse_expr(cn.getChild("right").getChild("expr"));
+
+            if ((left == null) || (right == null)) {
+                return null;
+            }
+
+            /* get comparison operator */
+            String comparison = cn.getChild("compare").getTerminal();
+            assert comparison != null;
+                         
+            return new ComparisonPredicate(comparison, left, right);
         } else {
             throw new IRException();
         }       
         } else {
             throw new IRException();
         }       
@@ -1522,36 +1544,9 @@ public class SemanticChecker {
         }
 
         String opname = pn.getChild("op").getTerminal();
         }
 
         String opname = pn.getChild("op").getTerminal();
+        Opcode opcode = Opcode.decodeFromString(opname);
 
 
-        Opcode opcode;
-
-        if (opname.equals("add")) {
-            opcode = Opcode.ADD;
-        } else if (opname.equals("sub")) {
-            opcode = Opcode.SUB;
-        } else if (opname.equals("mult")) {
-            opcode = Opcode.MULT;
-        } else if (opname.equals("div")) {
-            opcode = Opcode.DIV;
-        } else if (opname.equals("and")) {
-            opcode = Opcode.AND;
-        } else if (opname.equals("or")) {
-            opcode = Opcode.OR;
-        } else if (opname.equals("not")) {
-            opcode = Opcode.NOT;
-        } else if (opname.equals("gt")) {
-            opcode = Opcode.GT;
-        } else if (opname.equals("ge")) {
-            opcode = Opcode.GE;
-        } else if (opname.equals("lt")) {
-            opcode = Opcode.LT;
-        } else if (opname.equals("le")) {
-            opcode = Opcode.LE;
-        } else if (opname.equals("eq")) {
-            opcode = Opcode.EQ;
-        } else if (opname.equals("ne")) {
-            opcode = Opcode.NE;
-        } else {
+        if (opcode == null) {
             er.report(pn, "Unsupported operation: " + opname);
             return null;
         }
             er.report(pn, "Unsupported operation: " + opname);
             return null;
         }