associate assignment nodes that writes to the same height location with corresponding...
[IRC.git] / Robust / src / IR / Flat / BuildFlat.java
index dab3af931e3e79e2102fa359149fe8f45eef5109..bc6c613fbb23061fb9fb5a1ff35af84d7d4d986b 100644 (file)
@@ -309,10 +309,6 @@ public class BuildFlat {
       NodePair np=flattenBlockStatementNode(bn.get(i));
       FlatNode np_begin=np.getBegin();
       FlatNode np_end=np.getEnd();
-      if(bn.getLabel()!=null) {
-        // interim implementation to have the labeled statement
-        state.fn2labelMap.put(np_begin, bn.getLabel());
-      }
       if (begin==null) {
         begin=np_begin;
       }
@@ -692,6 +688,7 @@ public class BuildFlat {
 
       FlatSetFieldNode fsfn=new FlatSetFieldNode(dst_tmp, fan.getField(), src_tmp);
       fsfn.setNumLine(en.getNumLine());
+      addMapNode2FlatNodeSet(an,fsfn);
       last.addNext(fsfn);
       last=fsfn;
       if (pre) {
@@ -787,6 +784,7 @@ public class BuildFlat {
         last.addNext(fon2);
         last=fon2;
       }
+      addMapNode2FlatNodeSet(an,last);
       return new NodePair(first, last);
     } else if (an.getDest().kind()==Kind.NameNode) {
       //We could be assigning a field or variable
@@ -853,6 +851,7 @@ public class BuildFlat {
 
         FlatSetFieldNode fsfn=new FlatSetFieldNode(dst_tmp, fan.getField(), src_tmp);
         fsfn.setNumLine(en.getNumLine());
+        addMapNode2FlatNodeSet(an,fsfn);
         last.addNext(fsfn);
         last=fsfn;
         if (pre) {
@@ -925,6 +924,7 @@ public class BuildFlat {
             fsfn=new FlatSetFieldNode(getTempforVar(nn.getVar()), nn.getField(), src_tmp);
             fsfn.setNumLine(nn.getNumLine());
           }
+          addMapNode2FlatNodeSet(an,fsfn);
           if (first==null) {
             first=fsfn;
           } else {
@@ -991,6 +991,7 @@ public class BuildFlat {
 
           FlatOpNode fon=new FlatOpNode(getTempforVar(nn.getVar()), src_tmp, null, new Operation(Operation.ASSIGN));
           fon.setNumLine(an.getNumLine());
+          addMapNode2FlatNodeSet(an,fon);
 
           last.addNext(fon);
           last=fon;
@@ -1342,6 +1343,7 @@ public class BuildFlat {
   }
 
   private NodePair flattenLoopNode(LoopNode ln) {
+    
     HashSet oldbs=breakset;
     HashSet oldcs=continueset;
     breakset=new HashSet();
@@ -1358,6 +1360,7 @@ public class BuildFlat {
       fcb.setNumLine(ln.getNumLine());
       fcb.setTrueProb(State.TRUEPROB);
       fcb.setLoop();
+      fcb.setLoopEntrance(condition.getBegin());
       FlatNop nopend=new FlatNop();
       FlatBackEdge backedge=new FlatBackEdge();
 
@@ -1383,6 +1386,9 @@ public class BuildFlat {
       }
       breakset=oldbs;
       continueset=oldcs;
+      if(ln.getLabel()!=null){
+        state.fn2labelMap.put(condition.getBegin(), ln.getLabel());
+      }
       return new NodePair(begin,nopend);
     } else if (ln.getType()==LoopNode.WHILELOOP) {
       TempDescriptor cond_temp=TempDescriptor.tempFactory("condition", new TypeDescriptor(TypeDescriptor.BOOLEAN));
@@ -1393,6 +1399,7 @@ public class BuildFlat {
       fcb.setNumLine(ln.getNumLine());
       fcb.setTrueProb(State.TRUEPROB);
       fcb.setLoop();
+      fcb.setLoopEntrance(begin);
       FlatNop nopend=new FlatNop();
       FlatBackEdge backedge=new FlatBackEdge();
 
@@ -1416,6 +1423,9 @@ public class BuildFlat {
       }
       breakset=oldbs;
       continueset=oldcs;
+      if(ln.getLabel()!=null){
+        state.fn2labelMap.put(begin, ln.getLabel());
+      }      
       return new NodePair(begin,nopend);
     } else if (ln.getType()==LoopNode.DOWHILELOOP) {
       TempDescriptor cond_temp=TempDescriptor.tempFactory("condition", new TypeDescriptor(TypeDescriptor.BOOLEAN));
@@ -1426,6 +1436,7 @@ public class BuildFlat {
       fcb.setNumLine(ln.getNumLine());
       fcb.setTrueProb(State.TRUEPROB);
       fcb.setLoop();
+      fcb.setLoopEntrance(begin);
       FlatNop nopend=new FlatNop();
       FlatBackEdge backedge=new FlatBackEdge();
 
@@ -1448,6 +1459,9 @@ public class BuildFlat {
       }
       breakset=oldbs;
       continueset=oldcs;
+      if(ln.getLabel()!=null){
+        state.fn2labelMap.put(begin, ln.getLabel());
+      }
       return new NodePair(begin,nopend);
     } else throw new Error();
   }
@@ -1599,6 +1613,11 @@ public class BuildFlat {
     return new NodePair(fgrn, fgrn);
   }
 
+  private NodePair flattenGenDefReachNode(GenDefReachNode gdrn) {
+    FlatGenDefReachNode fgdrn = new FlatGenDefReachNode(gdrn.getOutputName() );
+    return new NodePair(fgdrn, fgdrn);
+  }
+
   private NodePair flattenSESENode(SESENode sn) {
     if( sn.isStart() ) {
       FlatSESEEnterNode fsen=new FlatSESEEnterNode(sn);
@@ -1752,6 +1771,9 @@ public class BuildFlat {
     case Kind.GenReachNode:
       return flattenGenReachNode((GenReachNode)bsn);
 
+    case Kind.GenDefReachNode:
+      return flattenGenDefReachNode((GenDefReachNode)bsn);
+
     case Kind.ContinueBreakNode:
       return flattenContinueBreakNode((ContinueBreakNode)bsn);
     }