From 59dde997436f01504074155c2e385b9a0478dd26 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 25 Apr 2006 21:37:02 +0000 Subject: [PATCH] checking in code --- Robust/src/IR/Flat/BuildCode.java | 2 ++ Robust/src/IR/Operation.java | 6 +++++- Robust/src/IR/Tree/BuildIR.java | 24 ++++++++++++++++++++++-- Robust/src/Parse/java14.cup | 3 ++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 6f4f95fa..78989dd3 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -671,6 +671,8 @@ public class BuildCode { output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+";"); else if (fon.getOp().getOp()==Operation.UNARYMINUS) output.println(generateTemp(fm, fon.getDest())+" = -"+generateTemp(fm, fon.getLeft())+";"); + else if (fon.getOp().getOp()==Operation.LOGIC_NOT) + output.println(generateTemp(fm, fon.getDest())+" = !"+generateTemp(fm, fon.getLeft())+";"); else if (fon.getOp().getOp()==Operation.POSTINC) output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+"++;"); else if (fon.getOp().getOp()==Operation.POSTDEC) diff --git a/Robust/src/IR/Operation.java b/Robust/src/IR/Operation.java index 3cb40282..274c0414 100644 --- a/Robust/src/IR/Operation.java +++ b/Robust/src/IR/Operation.java @@ -25,7 +25,7 @@ public class Operation { public static final int POSTDEC=22; public static final int PREINC=23; public static final int PREDEC=24; - + public static final int LOGIC_NOT=25; /* Flat Operations */ public static final int ASSIGN=100; @@ -91,6 +91,8 @@ public class Operation { return PREINC; else if (st.equals("predec")) return PREDEC; + else if (st.equals("not")) + return LOGIC_NOT; else throw new Error(); } @@ -100,6 +102,8 @@ public class Operation { return "||"; else if (operation==LOGIC_AND) return "&&"; + else if (operation==LOGIC_NOT) + return "not"; else if (operation==BIT_OR) return "|"; else if (operation==BIT_XOR) diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 44d793ec..2f2797fd 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -37,7 +37,6 @@ public class BuildIR { public TaskDescriptor parseTaskDecl(ParseNode pn) { TaskDescriptor td=new TaskDescriptor(pn.getChild("name").getTerminal()); - ParseNode bodyn=pn.getChild("body"); BlockNode bn=parseBlock(bodyn); parseParameterList(td, pn); @@ -45,6 +44,26 @@ public class BuildIR { return td; } + public FlagExpressionNode parseFlagExpression(ParseNode pn) { + if (paramn.getChild("or")!=null) { + ParseNodeVector pnv=paramn.getChild("or").getChildren(); + ParseNode left=pnv.elementAt(0); + ParseNode right=pnv.elementAt(1); + return new FlagOpNode(parseFlagExpression(left), parseFlagExpression(right), new Operation(Operation.LOGIC_OR)); + } else if (paramn.getChild("and")!=null) { + ParseNodeVector pnv=paramn.getChild("and").getChildren(); + ParseNode left=pnv.elementAt(0); + ParseNode right=pnv.elementAt(1); + return new FlagOpNode(parseFlagExpression(left), parseFlagExpression(right), new Operation(Operation.LOGIC_AND)); + } else if (paramn.getChild("not")!=null) { + ParseNodeVector pnv=paramn.getChild("not").getChildren(); + ParseNode left=pnv.elementAt(0); + return new FlagOpNode(parseFlagExpression(left), new Operation(Operation.LOGIC_NOT)); + + } else if (paramn.getChild("name")!=null) { + return new FlagNode(paramn.getChild("name").getTerminal()); + } else throw new Error(); + } public void parseParameterList(TaskDescriptor td, ParseNode pn) { ParseNode paramlist=pn.getChild("task_parameter_list"); @@ -61,7 +80,7 @@ public class BuildIR { tmp=tmp.getChild("array"); } String paramname=tmp.getChild("single").getTerminal(); - + FlagExpressionNode fen=parseFlagExpression(paramn.getChild("flag")); td.addParameter(type,paramname); } @@ -210,6 +229,7 @@ public class BuildIR { isNode(pn,"postinc")|| isNode(pn,"postdec")|| isNode(pn,"preinc")|| + isNode(pn,"not")|| isNode(pn,"predec")) { ParseNode left=pn.getFirstChild(); Operation op=new Operation(pn.getLabel()); diff --git a/Robust/src/Parse/java14.cup b/Robust/src/Parse/java14.cup index 1d296fae..381ab5e3 100644 --- a/Robust/src/Parse/java14.cup +++ b/Robust/src/Parse/java14.cup @@ -271,7 +271,7 @@ task_parameter ::= ParseNode pn=new ParseNode("task_parameter"); pn.addChild(type); pn.addChild(name); - pn.addChild(exp); + pn.addChild("flag").addChild(exp); RESULT=pn; :} ; @@ -334,6 +334,7 @@ flag_effects ::= flag_effect:fe {: flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE {: ParseNode pn=new ParseNode("flag_effect"); + pn.addChild("name").addChild(id); pn.addChild(fl); RESULT=pn; :}; -- 2.34.1