MethodDescriptor currmd;
TypeUtil typeutil;
+ HashSet breakset;
+ HashSet continueset;
+ FlatExit fe;
+
public BuildFlat(State st, TypeUtil typeutil) {
state=st;
temptovar=new Hashtable();
this.typeutil=typeutil;
+ this.breakset=new HashSet();
+ this.continueset=new HashSet();
}
public Hashtable getMap() {
BlockNode bn=state.getMethodBody(td);
NodePair np=flattenBlockNode(bn);
FlatNode fn=np.getBegin();
- if (np.getEnd().kind()!=FKind.FlatReturnNode) {
+ fe=new FlatExit();
+ FlatNode fn2=np.getEnd();
+
+ if (fn2!=null&& fn2.kind()!=FKind.FlatReturnNode) {
FlatReturnNode rnflat=new FlatReturnNode(null);
- np.getEnd().addNext(rnflat);
+ rnflat.addNext(fe);
+ fn2.addNext(rnflat);
}
FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.PRE);
ffan.addNext(fn);
- FlatMethod fm=new FlatMethod(td);
+ FlatMethod fm=new FlatMethod(td, fe);
fm.addNext(ffan);
Hashtable visitedset=new Hashtable();
private void flattenClass(ClassDescriptor cn) {
Iterator methodit=cn.getMethods();
- while(methodit.hasNext()) {
+ while(methodit.hasNext()) {
currmd=(MethodDescriptor)methodit.next();
+
+ FlatSESEEnterNode rootSESE = null;
+ FlatSESEExitNode rootExit = null;
+ if (state.MLP && currmd.equals(typeutil.getMain())) {
+ SESENode rootTree = new SESENode( "root" );
+ rootSESE = new FlatSESEEnterNode( rootTree );
+ rootExit = new FlatSESEExitNode ( rootTree );
+ rootSESE.setFlatExit ( rootExit );
+ rootExit.setFlatEnter( rootSESE );
+ }
+
+ fe=new FlatExit();
+
BlockNode bn=state.getMethodBody(currmd);
if (state.DSM&&currmd.getModifiers().isAtomic()) {
FlatCall fc=new FlatCall(memd, null, thistd, new TempDescriptor[0]);
fc.addNext(fn);
fn=fc;
- if (np.getEnd().kind()!=FKind.FlatReturnNode) {
+ if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) {
MethodDescriptor memdex=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
FlatCall fcunlock=new FlatCall(memdex, null, thistd, new TempDescriptor[0]);
np.getEnd().addNext(fcunlock);
FlatReturnNode rnflat=new FlatReturnNode(null);
fcunlock.addNext(rnflat);
+ rnflat.addNext(fe);
}
} else if (state.DSM&&currmd.getModifiers().isAtomic()) {
curran.addNext(fn);
fn=curran;
- if (np.getEnd().kind()!=FKind.FlatReturnNode) {
+ if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) {
FlatAtomicExitNode aen=new FlatAtomicExitNode(curran);
np.getEnd().addNext(aen);
FlatReturnNode rnflat=new FlatReturnNode(null);
aen.addNext(rnflat);
+ rnflat.addNext(fe);
}
- } else if (np.getEnd().kind()!=FKind.FlatReturnNode) {
+ } else if (state.MLP && rootSESE != null) {
+ rootSESE.addNext(fn);
+ fn=rootSESE;
+ FlatReturnNode rnflat=new FlatReturnNode(null);
+ np.getEnd().addNext(rootExit);
+ rootExit.addNext(rnflat);
+ rnflat.addNext(fe);
+
+ } else if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) {
FlatReturnNode rnflat=new FlatReturnNode(null);
np.getEnd().addNext(rnflat);
+ rnflat.addNext(fe);
}
- FlatMethod fm=new FlatMethod(currmd);
+ FlatMethod fm=new FlatMethod(currmd, fe);
fm.addNext(fn);
if (!currmd.isStatic())
fm.addParameterTemp(getTempforParam(currmd.getThis()));
end=np_end;
} else {
end.addNext(np_begin);
- end=np_end;
+ if (np_end==null) {
+ return new NodePair(begin, null);
+ } else
+ end=np_end;
}
}
if (begin==null) {
}
private NodePair flattenBlockExpressionNode(BlockExpressionNode en) {
+ //System.out.println("DEBUG -> inside flattenBlockExpressionNode\n");
TempDescriptor tmp=TempDescriptor.tempFactory("neverused",en.getExpression().getType());
return flattenExpressionNode(en.getExpression(),tmp);
}
return new NodePair(fln,fln);
}
+ private NodePair flattenOffsetNode(OffsetNode ofn, TempDescriptor out_temp) {
+ FlatOffsetNode fln = new FlatOffsetNode(ofn.getClassType(), ofn.getField(), out_temp);
+ return new NodePair(fln, fln);
+ }
+
private NodePair flattenCreateObjectNode(CreateObjectNode con,TempDescriptor out_temp) {
TypeDescriptor td=con.getType();
if (!td.isArray()) {
- FlatNew fn=new FlatNew(td, out_temp, con.isGlobal());
- TempDescriptor[] temps=new TempDescriptor[con.numArgs()];
+ FlatNode fn=new FlatNew(td, out_temp, con.isGlobal(), con.getDisjointId());
FlatNode last=fn;
+ //handle wrapper fields
+ ClassDescriptor cd=td.getClassDesc();
+ for(Iterator fieldit=cd.getFields();fieldit.hasNext();) {
+ FieldDescriptor fd=(FieldDescriptor)fieldit.next();
+ if (fd.getType().iswrapper()) {
+ TempDescriptor wrap_tmp=TempDescriptor.tempFactory("wrapper_obj",fd.getType());
+ FlatNode fnwrapper=new FlatNew(fd.getType(), wrap_tmp, con.isGlobal());
+ FlatSetFieldNode fsfn=new FlatSetFieldNode(out_temp, fd, wrap_tmp);
+ last.addNext(fnwrapper);
+ fnwrapper.addNext(fsfn);
+ last=fsfn;
+ }
+ }
+
+ TempDescriptor[] temps=new TempDescriptor[con.numArgs()];
+
// Build arguments
for(int i=0; i<con.numArgs(); i++) {
ExpressionNode en=con.getArg(i);
out_temp :
TempDescriptor.tempFactory("arg",en.getType());
}
- FlatNew fn=new FlatNew(td, out_temp, temps[0], con.isGlobal());
+ FlatNew fn=new FlatNew(td, out_temp, temps[0], con.isGlobal(), con.getDisjointId());
last.addNext(fn);
if (temps.length>1) {
NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0, con.isGlobal());
fn.addNext(np.getBegin());
return new NodePair(first,np.getEnd());
+ } else if (td.isArray()&&td.dereference().iswrapper()) {
+ NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0, con.isGlobal());
+ fn.addNext(np.getBegin());
+ return new NodePair(first,np.getEnd());
} else
return new NodePair(first, fn);
}
fcb.setLoop();
//is index<temp[i]
TempDescriptor new_tmp=TempDescriptor.tempFactory("tmp",td);
- FlatNew fn=new FlatNew(td, new_tmp, temparray[i+1], isglobal);
+ FlatNew fn=td.iswrapper()?new FlatNew(td, new_tmp, isglobal):new FlatNew(td, new_tmp, temparray[i+1], isglobal);
FlatSetElementNode fsen=new FlatSetElementNode(tmp,index,new_tmp);
// index=index+1
FlatOpNode fon=new FlatOpNode(index,index,tmpone,new Operation(Operation.ADD));
NodePair np2=generateNewArrayLoop(temparray, td.dereference(), new_tmp, i+1, isglobal);
fsen.addNext(np2.getBegin());
np2.getEnd().addNext(fon);
+ } else if (td.isArray()&&td.dereference().iswrapper()) {
+ NodePair np2=generateNewArrayLoop(temparray, td.dereference(), new_tmp, i+1, isglobal);
+ fsen.addNext(np2.getBegin());
+ np2.getEnd().addNext(fon);
} else {
fsen.addNext(fon);
}
TempDescriptor tmpindex=TempDescriptor.tempFactory("temp",aan.getIndex().getType());
NodePair npe=flattenExpressionNode(aan.getExpression(),tmp);
NodePair npi=flattenExpressionNode(aan.getIndex(),tmpindex);
- FlatElementNode fn=new FlatElementNode(tmp,tmpindex,out_temp);
+ TempDescriptor arraytmp=out_temp;
+ if (aan.iswrapper()) {
+ //have wrapper
+ arraytmp=TempDescriptor.tempFactory("temp", aan.getExpression().getType().dereference());
+ }
+ FlatNode fn=new FlatElementNode(tmp,tmpindex,arraytmp);
npe.getEnd().addNext(npi.getBegin());
npi.getEnd().addNext(fn);
+ if (aan.iswrapper()) {
+ FlatFieldNode ffn=new FlatFieldNode((FieldDescriptor)aan.getExpression().getType().dereference().getClassDesc().getFieldTable().get("value") ,arraytmp,out_temp);
+ fn.addNext(ffn);
+ fn=ffn;
+ }
return new NodePair(npe.getBegin(),fn);
}
}
FlatNode first=null;
FlatNode last=null;
- TempDescriptor src_tmp=an.getSrc()==null ? TempDescriptor.tempFactory("srctmp",an.getDest().getType()) : TempDescriptor.tempFactory("srctmp",an.getSrc().getType());
+ TempDescriptor src_tmp = src_tmp=an.getSrc()==null ? TempDescriptor.tempFactory("srctmp",an.getDest().getType()) : TempDescriptor.tempFactory("srctmp",an.getSrc().getType());
//Get src value
if (an.getSrc()!=null) {
if (base!=null) {
//If it is a preinc we need to store the initial value
TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
- TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3",an.getDest().getType());
+ TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
FlatFieldNode ffn=new FlatFieldNode(fan.getField(), dst_tmp, src_tmp2);
last.addNext(ffn);
last=ffn;
} else if (an.getDest().kind()==Kind.ArrayAccessNode) {
//We are assigning an array element
-
ArrayAccessNode aan=(ArrayAccessNode)an.getDest();
ExpressionNode en=aan.getExpression();
ExpressionNode enindex=aan.getIndex();
if (base!=null) {
//If it is a preinc we need to store the initial value
TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
- TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3",an.getDest().getType());
-
- FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp2);
- last.addNext(fen);
- last=fen;
-
+ TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
+
+ if (aan.iswrapper()) {
+ TypeDescriptor arrayeltype=aan.getExpression().getType().dereference();
+ TempDescriptor src_tmp3=TempDescriptor.tempFactory("src3",arrayeltype);
+ FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp3);
+ FlatFieldNode ffn=new FlatFieldNode((FieldDescriptor)arrayeltype.getClassDesc().getFieldTable().get("value"),src_tmp3,src_tmp2);
+ last.addNext(fen);
+ fen.addNext(ffn);
+ last=ffn;
+ } else {
+ FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp2);
+ last.addNext(fen);
+ last=fen;
+ }
if (base.getOp()==Operation.ADD&&an.getDest().getType().isString()) {
ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
last.addNext(fc);
last=fc;
} else {
-
-
FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
src_tmp=tmp;
last.addNext(fon);
}
}
-
- FlatSetElementNode fsen=new FlatSetElementNode(dst_tmp, index_tmp, src_tmp);
- last.addNext(fsen);
- last=fsen;
+ if (aan.iswrapper()) {
+ TypeDescriptor arrayeltype=aan.getExpression().getType().dereference();
+ TempDescriptor src_tmp3=TempDescriptor.tempFactory("src3",arrayeltype);
+ FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp3);
+ FlatSetFieldNode fsfn=new FlatSetFieldNode(src_tmp3,(FieldDescriptor)arrayeltype.getClassDesc().getFieldTable().get("value"),src_tmp);
+ last.addNext(fen);
+ fen.addNext(fsfn);
+ last=fsfn;
+ } else {
+ FlatSetElementNode fsen=new FlatSetElementNode(dst_tmp, index_tmp, src_tmp);
+ last.addNext(fsen);
+ last=fsen;
+ }
if (pre) {
FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
- fsen.addNext(fon2);
+ last.addNext(fon2);
last=fon2;
}
return new NodePair(first, last);
} else if (an.getDest().kind()==Kind.NameNode) {
//We could be assigning a field or variable
NameNode nn=(NameNode)an.getDest();
+
+
if (nn.getExpression()!=null) {
//It is a field
FieldAccessNode fan=(FieldAccessNode)nn.getExpression();
if (base!=null) {
//If it is a preinc we need to store the initial value
TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
- TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3",an.getDest().getType());
+ TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
FlatFieldNode ffn=new FlatFieldNode(fan.getField(), dst_tmp, src_tmp2);
last.addNext(ffn);
if (base!=null) {
//If it is a preinc we need to store the initial value
TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
- TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3",an.getDest().getType());
+ TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
FlatFieldNode ffn=new FlatFieldNode(nn.getField(), getTempforVar(nn.getVar()), src_tmp2);
if (first==null)
if (base!=null) {
//If it is a preinc we need to store the initial value
TempDescriptor src_tmp2=getTempforVar(nn.getVar());
- TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3",an.getDest().getType());
+ TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
if (!pre) {
FlatOpNode fon=new FlatOpNode(out_temp, src_tmp2, null, new Operation(Operation.ASSIGN));
if (first==null)
}
FlatOpNode fon=new FlatOpNode(getTempforVar(nn.getVar()), src_tmp, null, new Operation(Operation.ASSIGN));
+
last.addNext(fon);
last=fon;
if (pre) {
last=fon2;
}
return new NodePair(first, last);
- }
+ } //end of else
}
}
+
throw new Error();
}
return flattenNameNode((NameNode)en,out_temp);
case Kind.OpNode:
- return flattenOpNode((OpNode)en,out_temp);
+ return flattenOpNode((OpNode)en,out_temp);
+
+ case Kind.OffsetNode:
+ return flattenOffsetNode((OffsetNode)en,out_temp);
+
+ case Kind.TertiaryNode:
+ return flattenTertiaryNode((TertiaryNode)en,out_temp);
+
+ case Kind.InstanceOfNode:
+ return flattenInstanceOfNode((InstanceOfNode)en,out_temp);
+
+ case Kind.ArrayInitializerNode:
+ return flattenArrayInitializerNode((ArrayInitializerNode)en,out_temp);
}
throw new Error();
}
cond.getEnd().addNext(fcb);
fcb.addTrueNext(true_np.getBegin());
fcb.addFalseNext(false_np.getBegin());
- true_np.getEnd().addNext(nopend);
- false_np.getEnd().addNext(nopend);
+ if (true_np.getEnd()!=null)
+ true_np.getEnd().addNext(nopend);
+ if (false_np.getEnd()!=null)
+ false_np.getEnd().addNext(nopend);
return new NodePair(cond.getBegin(), nopend);
}
private NodePair flattenLoopNode(LoopNode ln) {
+ HashSet oldbs=breakset;
+ HashSet oldcs=continueset;
+ breakset=new HashSet();
+ continueset=new HashSet();
+
if (ln.getType()==LoopNode.FORLOOP) {
NodePair initializer=flattenBlockNode(ln.getInitializer());
TempDescriptor cond_temp=TempDescriptor.tempFactory("condition", new TypeDescriptor(TypeDescriptor.BOOLEAN));
FlatNop nop2=new FlatNop();
initializer.getEnd().addNext(nop2);
nop2.addNext(condition.getBegin());
- body.getEnd().addNext(update.getBegin());
+ if (body.getEnd()!=null)
+ body.getEnd().addNext(update.getBegin());
update.getEnd().addNext(backedge);
backedge.addNext(condition.getBegin());
condition.getEnd().addNext(fcb);
fcb.addFalseNext(nopend);
fcb.addTrueNext(body.getBegin());
+ for(Iterator contit=continueset.iterator();contit.hasNext();) {
+ FlatNode fn=(FlatNode)contit.next();
+ contit.remove();
+ fn.addNext(update.getBegin());
+ }
+ for(Iterator breakit=breakset.iterator();breakit.hasNext();) {
+ FlatNode fn=(FlatNode)breakit.next();
+ breakit.remove();
+ fn.addNext(nopend);
+ }
+ breakset=oldbs;
+ continueset=oldcs;
return new NodePair(begin,nopend);
} else if (ln.getType()==LoopNode.WHILELOOP) {
TempDescriptor cond_temp=TempDescriptor.tempFactory("condition", new TypeDescriptor(TypeDescriptor.BOOLEAN));
FlatNop nopend=new FlatNop();
FlatBackEdge backedge=new FlatBackEdge();
- body.getEnd().addNext(backedge);
+ if (body.getEnd()!=null)
+ body.getEnd().addNext(backedge);
backedge.addNext(condition.getBegin());
condition.getEnd().addNext(fcb);
fcb.addFalseNext(nopend);
fcb.addTrueNext(body.getBegin());
+
+ for(Iterator contit=continueset.iterator();contit.hasNext();) {
+ FlatNode fn=(FlatNode)contit.next();
+ contit.remove();
+ fn.addNext(backedge);
+ }
+ for(Iterator breakit=breakset.iterator();breakit.hasNext();) {
+ FlatNode fn=(FlatNode)breakit.next();
+ breakit.remove();
+ fn.addNext(nopend);
+ }
+ breakset=oldbs;
+ continueset=oldcs;
return new NodePair(begin,nopend);
} else if (ln.getType()==LoopNode.DOWHILELOOP) {
TempDescriptor cond_temp=TempDescriptor.tempFactory("condition", new TypeDescriptor(TypeDescriptor.BOOLEAN));
FlatNop nopend=new FlatNop();
FlatBackEdge backedge=new FlatBackEdge();
- body.getEnd().addNext(condition.getBegin());
+ if (body.getEnd()!=null)
+ body.getEnd().addNext(condition.getBegin());
condition.getEnd().addNext(fcb);
fcb.addFalseNext(nopend);
fcb.addTrueNext(backedge);
backedge.addNext(body.getBegin());
+
+ for(Iterator contit=continueset.iterator();contit.hasNext();) {
+ FlatNode fn=(FlatNode)contit.next();
+ contit.remove();
+ fn.addNext(condition.getBegin());
+ }
+ for(Iterator breakit=breakset.iterator();breakit.hasNext();) {
+ FlatNode fn=(FlatNode)breakit.next();
+ breakit.remove();
+ fn.addNext(nopend);
+ }
+ breakset=oldbs;
+ continueset=oldcs;
return new NodePair(begin,nopend);
} else throw new Error();
}
}
FlatReturnNode rnflat=new FlatReturnNode(retval);
+ rnflat.addNext(fe);
FlatNode ln=rnflat;
if (state.THREAD&&currmd.getModifiers().isSynchronized()) {
MethodDescriptor memd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
if (cond!=null) {
cond.getEnd().addNext(ln);
- return new NodePair(cond.getBegin(),rnflat);
+ return new NodePair(cond.getBegin(),null);
} else
- return new NodePair(ln,rnflat);
+ return new NodePair(ln,null);
}
private NodePair flattenTaskExitNode(TaskExitNode ten) {
FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.TASKEXIT);
+ ffan.setTaskExitIndex(ten.getTaskExitIndex());
updateFlagActionNode(ffan, ten.getFlagEffects());
NodePair fcn=flattenConstraintCheck(ten.getChecks());
ffan.addNext(fcn.getBegin());
FlatReturnNode rnflat=new FlatReturnNode(null);
+ rnflat.addNext(fe);
fcn.getEnd().addNext(rnflat);
- return new NodePair(ffan, rnflat);
+ return new NodePair(ffan, null);
}
private NodePair flattenConstraintCheck(Vector ccs) {
return flattenBlockNode(sbn.getBlockNode());
}
+ private NodePair flattenSynchronizedNode(SynchronizedNode sbn) {
+ TempDescriptor montmp=TempDescriptor.tempFactory("monitor",sbn.getExpr().getType());
+ NodePair npexp=flattenExpressionNode(sbn.getExpr(), montmp);
+ NodePair npblock=flattenBlockNode(sbn.getBlockNode());
+
+ MethodDescriptor menmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorEnter");
+ FlatCall fcen=new FlatCall(menmd, null, montmp, new TempDescriptor[0]);
+
+ MethodDescriptor mexmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
+ FlatCall fcex=new FlatCall(mexmd, null, montmp, new TempDescriptor[0]);
+
+ npexp.getEnd().addNext(fcen);
+ fcen.addNext(npblock.getBegin());
+ npblock.getEnd().addNext(fcex);
+ return new NodePair(npexp.getBegin(), fcex);
+ }
+
private NodePair flattenAtomicNode(AtomicNode sbn) {
NodePair np=flattenBlockNode(sbn.getBlockNode());
FlatAtomicEnterNode faen=new FlatAtomicEnterNode();
return new NodePair(faen, faexn);
}
+ private NodePair flattenSESENode(SESENode sn) {
+ if( sn.isStart() ) {
+ FlatSESEEnterNode fsen=new FlatSESEEnterNode(sn);
+ sn.setFlatEnter(fsen);
+ return new NodePair(fsen, fsen);
+ }
+
+ FlatSESEExitNode fsexn=new FlatSESEExitNode(sn);
+ sn.setFlatExit(fsexn);
+ FlatSESEEnterNode fsen=sn.getStart().getFlatEnter();
+ fsexn.setFlatEnter(fsen);
+ sn.getStart().getFlatEnter().setFlatExit( fsexn );
+ return new NodePair(fsexn, fsexn);
+ }
+
+ private NodePair flattenContinueBreakNode(ContinueBreakNode cbn) {
+ FlatNop fn=new FlatNop();
+ if (cbn.isBreak())
+ breakset.add(fn);
+ else
+ continueset.add(fn);
+ return new NodePair(fn,null);
+ }
+
+ private NodePair flattenInstanceOfNode(InstanceOfNode tn, TempDescriptor out_temp) {
+ TempDescriptor expr_temp=TempDescriptor.tempFactory("expr",tn.getExpr().getType());
+ NodePair cond=flattenExpressionNode(tn.getExpr(), expr_temp);
+ FlatInstanceOfNode fion=new FlatInstanceOfNode(tn.getExprType(), expr_temp, out_temp);
+ cond.getEnd().addNext(fion);
+ return new NodePair(cond.getBegin(),fion);
+ }
+
+ private NodePair flattenArrayInitializerNode(ArrayInitializerNode ain, TempDescriptor out_temp) {
+ /*
+ TempDescriptor expr_temp=TempDescriptor.tempFactory("arry_init",ain.getType());
+
+ // create a new array of size equal to the array initializer
+ //FlatNode first=null;
+ //FlatNode last=null;
+ TempDescriptor[] temps=new TempDescriptor[ain.numVarInitializers()];
+
+ for (int i=0; i<con.numArgs(); i++) {
+ ExpressionNode en=con.getArg(i);
+ TempDescriptor tmp=TempDescriptor.tempFactory("arg",en.getType());
+ temps[i]=tmp;
+ NodePair np=flattenExpressionNode(en, tmp);
+ if (first==null)
+ first=np.getBegin();
+ else
+ last.addNext(np.getBegin());
+ last=np.getEnd();
+
+ TempDescriptor tmp2=(i==0) ?
+ out_temp :
+ TempDescriptor.tempFactory("arg",en.getType());
+ }
+ FlatNew fn=new FlatNew(td, out_temp, temps[0], con.isGlobal(), con.getDisjointId());
+ last.addNext(fn);
+
+
+ // assign each element of the new array to the flattened expression
+
+
+ FlatOpNode fonAssignArray=new FlatOpNode(out_temp, newarry_temp, null, new Operation(Operation.ASSIGN));
+ */
+ //return new NodePair( , fonAssignArray );
+ ain.printNode(0);
+ System.out.println( "Array initializers not implemented yet." );
+ System.exit( -1 );
+ return null;
+ }
+
+ private NodePair flattenTertiaryNode(TertiaryNode tn, TempDescriptor out_temp) {
+ TempDescriptor cond_temp=TempDescriptor.tempFactory("tert_cond",new TypeDescriptor(TypeDescriptor.BOOLEAN));
+ TempDescriptor true_temp=TempDescriptor.tempFactory("tert_true",tn.getTrueExpr().getType());
+ TempDescriptor fals_temp=TempDescriptor.tempFactory("tert_fals",tn.getFalseExpr().getType());
+
+ NodePair cond=flattenExpressionNode(tn.getCond(),cond_temp);
+ FlatCondBranch fcb=new FlatCondBranch(cond_temp);
+
+ NodePair trueExpr=flattenExpressionNode(tn.getTrueExpr(),true_temp);
+ FlatOpNode fonT=new FlatOpNode(out_temp, true_temp, null, new Operation(Operation.ASSIGN));
+
+ NodePair falseExpr=flattenExpressionNode(tn.getFalseExpr(),fals_temp);
+ FlatOpNode fonF=new FlatOpNode(out_temp, fals_temp, null, new Operation(Operation.ASSIGN));
+
+ FlatNop nopend=new FlatNop();
+
+ cond.getEnd().addNext(fcb);
+
+ fcb.addTrueNext(trueExpr.getBegin());
+ fcb.addFalseNext(falseExpr.getBegin());
+
+ trueExpr.getEnd().addNext(fonT);
+ fonT.addNext(nopend);
+
+ falseExpr.getEnd().addNext(fonF);
+ fonF.addNext(nopend);
+
+ return new NodePair(cond.getBegin(), nopend);
+ }
+
private NodePair flattenBlockStatementNode(BlockStatementNode bsn) {
switch(bsn.kind()) {
case Kind.BlockExpressionNode:
case Kind.AtomicNode:
return flattenAtomicNode((AtomicNode)bsn);
+ case Kind.SynchronizedNode:
+ return flattenSynchronizedNode((SynchronizedNode)bsn);
+
+ case Kind.SESENode:
+ return flattenSESENode((SESENode)bsn);
+
+ case Kind.ContinueBreakNode:
+ return flattenContinueBreakNode((ContinueBreakNode)bsn);
}
throw new Error();
}