bug in cast code
authorbdemsky <bdemsky>
Mon, 13 Jul 2009 00:35:47 +0000 (00:35 +0000)
committerbdemsky <bdemsky>
Mon, 13 Jul 2009 00:35:47 +0000 (00:35 +0000)
Robust/src/IR/Tree/BuildIR.java
Robust/src/Parse/java14.cup

index 2e2fc524bc15721f207ff3bc3e4a5aa664f0eaad..8a97ce799400375e489394114443638db27bb92d 100644 (file)
@@ -306,6 +306,7 @@ public class BuildIR {
        td=td.makeArray(state);
       return td;
     } else {
+      System.out.println(pn.PPrint(2, true));
       throw new Error();
     }
   }
@@ -479,7 +480,13 @@ public class BuildIR {
       ExpressionNode index=parseExpression(pn.getChild("index").getFirstChild());
       return new ArrayAccessNode(en,index);
     } else if (isNode(pn,"cast1")) {
-      return new CastNode(parseTypeDescriptor(pn.getChild("type")),parseExpression(pn.getChild("exp").getFirstChild()));
+      try {
+       return new CastNode(parseTypeDescriptor(pn.getChild("type")),parseExpression(pn.getChild("exp").getFirstChild()));
+      } catch (Exception e) {
+       System.out.println(pn.PPrint(1,true));
+       e.printStackTrace();
+       throw new Error();
+      }
     } else if (isNode(pn,"cast2")) {
       return new CastNode(parseExpression(pn.getChild("type").getFirstChild()),parseExpression(pn.getChild("exp").getFirstChild()));
     } else if (isNode(pn, "getoffset")) {
index 01f07d0de4ea26729630051042f4970634386216..80c2f59304023bc2f9d66efbc64cde4318e3b5ea 100644 (file)
@@ -1730,9 +1730,9 @@ cast_expression ::=
 if (dims.intValue()==0)
                pn.addChild("type").addChild(type);
 else {
-               ParseNode arrayt=pn.addChild("type").addChild("array");
-               pn.addChild("basetype").addChild(type);
-               pn.addChild("dims").setLiteral(dims);
+               ParseNode arrayt=pn.addChild("type").addChild("type").addChild("array");
+               arrayt.addChild("basetype").addChild(type);
+               arrayt.addChild("dims").setLiteral(dims);
 }
                pn.addChild("exp").addChild(exp);
                RESULT=pn;