From: bdemsky Date: Mon, 13 Jul 2009 00:35:47 +0000 (+0000) Subject: bug in cast code X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c42d6ea031eaf947bb5a3d1ae7bba4274f6907bd;p=IRC.git bug in cast code --- diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 2e2fc524..8a97ce79 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -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")) { diff --git a/Robust/src/Parse/java14.cup b/Robust/src/Parse/java14.cup index 01f07d0d..80c2f593 100644 --- a/Robust/src/Parse/java14.cup +++ b/Robust/src/Parse/java14.cup @@ -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;