public class BuildIR {
State state;
+
+ private int m_taskexitnum;
+
public BuildIR(State state) {
this.state=state;
+ this.m_taskexitnum = 0;
}
+
public void buildtree() {
for(Iterator it=state.parsetrees.iterator(); it.hasNext();) {
ParseNode pn=(ParseNode)it.next();
ParseNodeVector pnv=paramlist.getChildren();
for(int i=0; i<pnv.size(); i++) {
ParseNode paramn=pnv.elementAt(i);
- if(paramn.getChild("optional")!=null){
+ if(paramn.getChild("optional")!=null) {
optional = true;
paramn = paramn.getChild("optional").getFirstChild();
System.out.println("OPTIONAL FOUND!!!!!!!");
private TypeDescriptor parseTypeDescriptor(ParseNode pn) {
ParseNode tn=pn.getChild("type");
-
String type_st=tn.getTerminal();
if(type_st.equals("byte")) {
return state.getTypeDescriptor(TypeDescriptor.BYTE);
TypeDescriptor td=parseTypeDescriptor(pn);
Vector args=parseArgumentList(pn);
boolean isglobal=pn.getChild("global")!=null;
- CreateObjectNode con=new CreateObjectNode(td, isglobal);
+ String disjointId=null;
+ if( pn.getChild("disjoint") != null) {
+ disjointId = pn.getChild("disjoint").getTerminal();
+ }
+ CreateObjectNode con=new CreateObjectNode(td, isglobal, disjointId);
for(int i=0; i<args.size(); i++) {
con.addArgument((ExpressionNode)args.get(i));
}
} else if (isNode(pn,"createarray")) {
//System.out.println(pn.PPrint(3,true));
boolean isglobal=pn.getChild("global")!=null;
+ String disjointId=null;
+ if( pn.getChild("disjoint") != null) {
+ disjointId = pn.getChild("disjoint").getTerminal();
+ }
TypeDescriptor td=parseTypeDescriptor(pn);
Vector args=parseDimExprs(pn);
int num=0;
num=((Integer)pn.getChild("dims_opt").getLiteral()).intValue();
for(int i=0; i<(args.size()+num); i++)
td=td.makeArray(state);
- CreateObjectNode con=new CreateObjectNode(td, isglobal);
+ CreateObjectNode con=new CreateObjectNode(td, isglobal, disjointId);
for(int i=0; i<args.size(); i++) {
con.addArgument((ExpressionNode)args.get(i));
}
}
return min;
} else if (isNode(pn,"fieldaccess")) {
- ExpressionNode en=parseExpression(pn.getChild("base").getFirstChild()); String fieldname=pn.getChild("field").getTerminal();
+ ExpressionNode en=parseExpression(pn.getChild("base").getFirstChild());
+ String fieldname=pn.getChild("field").getTerminal();
return new FieldAccessNode(en,fieldname);
} else if (isNode(pn,"arrayaccess")) {
ExpressionNode en=parseExpression(pn.getChild("base").getFirstChild());
return new CastNode(parseTypeDescriptor(pn.getChild("type")),parseExpression(pn.getChild("exp").getFirstChild()));
} else if (isNode(pn,"cast2")) {
return new CastNode(parseExpression(pn.getChild("type").getFirstChild()),parseExpression(pn.getChild("exp").getFirstChild()));
+ } else if (isNode(pn, "getoffset")) {
+ TypeDescriptor td=parseTypeDescriptor(pn);
+ String fieldname = pn.getChild("field").getTerminal();
+ //System.out.println("Checking the values of: "+ " td.toString()= " + td.toString()+ " fieldname= " + fieldname);
+ return new OffsetNode(td, fieldname);
+ } else if (isNode(pn, "tert")) {
+ return new TertiaryNode(parseExpression(pn.getChild("cond").getFirstChild()),
+ parseExpression(pn.getChild("trueexpr").getFirstChild()),
+ parseExpression(pn.getChild("falseexpr").getFirstChild()) );
} else {
System.out.println("---------------------");
System.out.println(pn.PPrint(3,true));
}
public BlockNode parseBlock(ParseNode pn) {
+ this.m_taskexitnum = 0;
if (pn==null||isEmpty(pn.getTerminal()))
return new BlockNode();
ParseNode bsn=pn.getChild("block_statement_list");
return bn;
}
+ public Vector parseSESEBlock(Vector parentbs, ParseNode pn) {
+ ParseNodeVector pnv=pn.getChildren();
+ Vector bv=new Vector();
+ for(int i=0; i<pnv.size(); i++) {
+ bv.addAll(parseBlockStatement(pnv.elementAt(i)));
+ }
+ return bv;
+ }
+
public Vector parseBlockStatement(ParseNode pn) {
Vector blockstatements=new Vector();
if (isNode(pn,"tag_declaration")) {
if (pn.getChild("cons_checks")!=null)
ccs=parseChecks(pn.getChild("cons_checks"));
- blockstatements.add(new TaskExitNode(vfe, ccs));
+ blockstatements.add(new TaskExitNode(vfe, ccs, this.m_taskexitnum++));
} else if (isNode(pn,"atomic")) {
BlockNode bn=parseBlockHelper(pn);
blockstatements.add(new AtomicNode(bn));
ExpressionNode condition=parseExpression(pn.getChild("condition").getFirstChild());
BlockNode body=parseSingleBlock(pn.getChild("statement").getFirstChild());
blockstatements.add(new LoopNode(condition,body,LoopNode.DOWHILELOOP));
+ } else if (isNode(pn,"sese")) {
+ SESENode start=new SESENode();
+ SESENode end =new SESENode();
+ start.setEnd( end );
+ end.setStart( start );
+ blockstatements.add(start);
+ blockstatements.addAll(parseSESEBlock(blockstatements,pn.getChild("body").getFirstChild()));
+ blockstatements.add(end);
+ } else if (isNode(pn,"continue")) {
+ blockstatements.add(new ContinueBreakNode(false));
+ } else if (isNode(pn,"break")) {
+ blockstatements.add(new ContinueBreakNode(true));
+
} else {
System.out.println("---------------");
System.out.println(pn.PPrint(3,true));