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)
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;
return PREINC;
else if (st.equals("predec"))
return PREDEC;
+ else if (st.equals("not"))
+ return LOGIC_NOT;
else
throw new Error();
}
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)
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);
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");
tmp=tmp.getChild("array");
}
String paramname=tmp.getChild("single").getTerminal();
-
+ FlagExpressionNode fen=parseFlagExpression(paramn.getChild("flag"));
td.addParameter(type,paramname);
}
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());