changes: propagating line number references to flatnodes
authoryeom <yeom>
Thu, 17 Mar 2011 19:18:55 +0000 (19:18 +0000)
committeryeom <yeom>
Thu, 17 Mar 2011 19:18:55 +0000 (19:18 +0000)
Robust/src/IR/Flat/BuildFlat.java
Robust/src/IR/Flat/FlatNode.java
Robust/src/IR/Tree/BuildIR.java

index 14e8f46f4f8bd7a15b2b583bb4370a202cfe6e85..148f089a0b678b9fe10b54b34717e6b0c4be07ed 100644 (file)
@@ -58,6 +58,7 @@ public class BuildFlat {
     }
 
     FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.PRE);
+    ffan.setNumLine(bn.getNumLine());
     ffan.addNext(fn);
 
     FlatMethod fm=new FlatMethod(td, fe);
@@ -185,7 +186,9 @@ public class BuildFlat {
       BlockNode bn=state.getMethodBody(currmd);
 
       if (state.DSM&&currmd.getModifiers().isAtomic()) {
-       curran=new FlatAtomicEnterNode();
+        FlatAtomicEnterNode faen=new FlatAtomicEnterNode();
+        faen.setNumLine(bn.getNumLine());
+       curran = faen;
       } else
        curran=null;
       if ((state.THREAD||state.MGC)&&currmd.getModifiers().isSynchronized()) {
@@ -211,6 +214,7 @@ public class BuildFlat {
     for(int j = 0; j < this.lockStack.size(); j++) {
       TempDescriptor thistd = this.lockStack.elementAt(j);
       FlatCall fc = new FlatCall(memd, null, thistd, new TempDescriptor[0]);
+      fc.setNumLine(bn.getNumLine());
       if(first == null)  {
         first = end = fc;
       } else {
@@ -226,6 +230,7 @@ public class BuildFlat {
          while(!this.lockStack.isEmpty()) {
            TempDescriptor thistd = this.lockStack.pop();
            FlatCall fcunlock = new FlatCall(memdex, null, thistd, new TempDescriptor[0]);
+           fcunlock.setNumLine(bn.getNumLine());
            end.addNext(fcunlock);
            end = fcunlock;
          }
@@ -267,6 +272,7 @@ public class BuildFlat {
       }
 
       FlatMethod fm=new FlatMethod(currmd, fe);
+      fm.setNumLine(bn.getNumLine());
       fm.addNext(fn);
       if (!currmd.isStatic())
        fm.addParameterTemp(getTempforParam(currmd.getThis()));
@@ -314,17 +320,20 @@ public class BuildFlat {
     TempDescriptor tmp=TempDescriptor.tempFactory("tocast",cn.getExpression().getType());
     NodePair np=flattenExpressionNode(cn.getExpression(), tmp);
     FlatCastNode fcn=new FlatCastNode(cn.getType(), tmp, out_temp);
+    fcn.setNumLine(cn.getNumLine());
     np.getEnd().addNext(fcn);
     return new NodePair(np.getBegin(),fcn);
   }
 
   private NodePair flattenLiteralNode(LiteralNode ln,TempDescriptor out_temp) {
     FlatLiteralNode fln=new FlatLiteralNode(ln.getType(), ln.getValue(), out_temp);
+    fln.setNumLine(ln.getNumLine());
     return new NodePair(fln,fln);
   }
 
   private NodePair flattenOffsetNode(OffsetNode ofn, TempDescriptor out_temp) {
     FlatOffsetNode fln = new FlatOffsetNode(ofn.getClassType(), ofn.getField(), out_temp);
+    fln.setNumLine(ofn.getNumLine());
     return new NodePair(fln, fln);
   }
 
@@ -340,7 +349,9 @@ public class BuildFlat {
        if (fd.getType().iswrapper()) {
          TempDescriptor wrap_tmp=TempDescriptor.tempFactory("wrapper_obj",fd.getType());
          FlatNode fnwrapper=new FlatNew(fd.getType(), wrap_tmp, con.isGlobal());
+         fnwrapper.setNumLine(con.getNumLine());
          FlatSetFieldNode fsfn=new FlatSetFieldNode(out_temp, fd, wrap_tmp);
+         fsfn.setNumLine(con.getNumLine());
          last.addNext(fnwrapper);
          fnwrapper.addNext(fsfn);
          last=fsfn;
@@ -361,11 +372,13 @@ public class BuildFlat {
       MethodDescriptor md=con.getConstructor();
       //Call to constructor
       FlatCall fc=new FlatCall(md, null, out_temp, temps);
+      fc.setNumLine(con.getNumLine());
       last.addNext(fc);
       last=fc;
       if (td.getClassDesc().hasFlags()) {
        //          if (con.getFlagEffects()!=null) {
        FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.NEWOBJECT);
+       ffan.setNumLine(con.getNumLine());
        FlagEffects fes=con.getFlagEffects();
        TempDescriptor flagtemp=out_temp;
        if (fes!=null) {
@@ -511,9 +524,12 @@ public class BuildFlat {
 
     FlatCall fc;
     if(md.getReturnType()==null||md.getReturnType().isVoid())
-      fc=new FlatCall(md, null, thisarg, temps);
+      fc=new FlatCall(md, null, thisarg, temps);      
     else
       fc=new FlatCall(md, out_temp, thisarg, temps);
+    
+    fc.setNumLine(min.getNumLine());
+    
     if (first==null) {
       first=fc;
     } else
@@ -527,11 +543,13 @@ public class BuildFlat {
       // static field dereference with class name
       tmp = new TempDescriptor(fan.getExpression().getType().getClassDesc().getSymbol(), fan.getExpression().getType());
       FlatFieldNode fn=new FlatFieldNode(fan.getField(),tmp,out_temp);
+      fn.setNumLine(fan.getNumLine());
       return new NodePair(fn,fn);
     } else {
       tmp=TempDescriptor.tempFactory("temp",fan.getExpression().getType());
       NodePair npe=flattenExpressionNode(fan.getExpression(),tmp);
       FlatFieldNode fn=new FlatFieldNode(fan.getField(),tmp,out_temp);
+      fn.setNumLine(fan.getNumLine());
       npe.getEnd().addNext(fn);
       return new NodePair(npe.getBegin(),fn);
     }
@@ -548,10 +566,12 @@ public class BuildFlat {
       arraytmp=TempDescriptor.tempFactory("temp", aan.getExpression().getType().dereference());
     }
     FlatNode fn=new FlatElementNode(tmp,tmpindex,arraytmp);
+    fn.setNumLine(aan.getNumLine());
     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);
+      ffn.setNumLine(aan.getNumLine());
       fn.addNext(ffn);
       fn=ffn;
     }
@@ -578,7 +598,9 @@ public class BuildFlat {
     //Get src value
     if (an.getSrc()!=null) {
       if(an.getSrc().getEval() != null) {
-        first = last = new FlatLiteralNode(an.getSrc().getType(), an.getSrc().getEval().longValue(), src_tmp);
+        FlatLiteralNode fln=new FlatLiteralNode(an.getSrc().getType(), an.getSrc().getEval().longValue(), src_tmp);
+        fln.setNumLine(an.getSrc().getNumLine());
+        first = last =fln;
       } else {
         NodePair np_src=flattenExpressionNode(an.getSrc(),src_tmp);
         first=np_src.getBegin();
@@ -586,6 +608,7 @@ public class BuildFlat {
       }
     } else if (!pre) {
       FlatLiteralNode fln=new FlatLiteralNode(new TypeDescriptor(TypeDescriptor.INT),new Integer(1),src_tmp);
+      fln.setNumLine(an.getNumLine());
       first=fln;
       last=fln;
     }
@@ -618,6 +641,7 @@ public class BuildFlat {
        TempDescriptor src_tmp2=pre ? TempDescriptor.tempFactory("src",an.getDest().getType()) : out_temp;
        TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
        FlatFieldNode ffn=new FlatFieldNode(fan.getField(), dst_tmp, src_tmp2);
+       ffn.setNumLine(an.getNumLine());
        last.addNext(ffn);
        last=ffn;
 
@@ -625,11 +649,13 @@ public class BuildFlat {
          ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
          MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
          FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
+         fc.setNumLine(an.getNumLine());
          src_tmp=tmp;
          last.addNext(fc);
          last=fc;
        } else {
          FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
+         fon.setNumLine(an.getNumLine());
          src_tmp=tmp;
          last.addNext(fon);
          last=fon;
@@ -637,10 +663,12 @@ public class BuildFlat {
       }
 
       FlatSetFieldNode fsfn=new FlatSetFieldNode(dst_tmp, fan.getField(), src_tmp);
+      fsfn.setNumLine(en.getNumLine());
       last.addNext(fsfn);
       last=fsfn;
       if (pre) {
        FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
+       fon2.setNumLine(an.getNumLine());
        fsfn.addNext(fon2);
        last=fon2;
       }
@@ -672,12 +700,15 @@ public class BuildFlat {
          TypeDescriptor arrayeltype=aan.getExpression().getType().dereference();
          TempDescriptor src_tmp3=TempDescriptor.tempFactory("src3",arrayeltype);
          FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp3);
+         fen.setNumLine(aan.getNumLine());
          FlatFieldNode ffn=new FlatFieldNode((FieldDescriptor)arrayeltype.getClassDesc().getFieldTable().get("value"),src_tmp3,src_tmp2);
+         ffn.setNumLine(aan.getNumLine());
          last.addNext(fen);
          fen.addNext(ffn);
          last=ffn;
        } else {
          FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp2);
+         fen.setNumLine(aan.getNumLine());
          last.addNext(fen);
          last=fen;
        }
@@ -685,11 +716,13 @@ public class BuildFlat {
          ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
          MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
          FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
+         fc.setNumLine(an.getNumLine());
          src_tmp=tmp;
          last.addNext(fc);
          last=fc;
        } else {
          FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
+         fon.setNumLine(an.getNumLine());
          src_tmp=tmp;
          last.addNext(fon);
          last=fon;
@@ -700,17 +733,21 @@ public class BuildFlat {
        TypeDescriptor arrayeltype=aan.getExpression().getType().dereference();
        TempDescriptor src_tmp3=TempDescriptor.tempFactory("src3",arrayeltype);
        FlatElementNode fen=new FlatElementNode(dst_tmp, index_tmp, src_tmp3);
+       fen.setNumLine(aan.getNumLine());
        FlatSetFieldNode fsfn=new FlatSetFieldNode(src_tmp3,(FieldDescriptor)arrayeltype.getClassDesc().getFieldTable().get("value"),src_tmp);
+       fsfn.setNumLine(aan.getExpression().getNumLine());
        last.addNext(fen);
        fen.addNext(fsfn);
        last=fsfn;
       } else { 
        FlatSetElementNode fsen=new FlatSetElementNode(dst_tmp, index_tmp, src_tmp);
+       fsen.setNumLine(aan.getNumLine());
        last.addNext(fsen);
        last=fsen;
       }
       if (pre) {
        FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
+       fon2.setNumLine(an.getNumLine());
        last.addNext(fon2);
        last=fon2;
       }
@@ -748,6 +785,7 @@ public class BuildFlat {
          TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
 
          FlatFieldNode ffn=new FlatFieldNode(fan.getField(), dst_tmp, src_tmp2);
+         ffn.setNumLine(an.getNumLine());
          last.addNext(ffn);
          last=ffn;
 
@@ -756,11 +794,13 @@ public class BuildFlat {
            ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
            MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
            FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
+           fc.setNumLine(an.getNumLine());
            src_tmp=tmp;
            last.addNext(fc);
            last=fc;
          } else {
            FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
+           fon.setNumLine(an.getNumLine());
            src_tmp=tmp;
            last.addNext(fon);
            last=fon;
@@ -769,10 +809,12 @@ public class BuildFlat {
 
 
        FlatSetFieldNode fsfn=new FlatSetFieldNode(dst_tmp, fan.getField(), src_tmp);
+       fsfn.setNumLine(en.getNumLine());
        last.addNext(fsfn);
        last=fsfn;
        if (pre) {
          FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
+         fon2.setNumLine(an.getNumLine());
          fsfn.addNext(fon2);
          last=fon2;
        }
@@ -797,6 +839,7 @@ public class BuildFlat {
           ftmp=getTempforVar(nn.getVar());
         }
         FlatFieldNode ffn=new FlatFieldNode(nn.getField(), ftmp, src_tmp2);
+        ffn.setNumLine(an.getNumLine());
 
            if (first==null)
              first=ffn;
@@ -810,11 +853,13 @@ public class BuildFlat {
              ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
              MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
              FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
+             fc.setNumLine(an.getNumLine());
              src_tmp=tmp;
              last.addNext(fc);
              last=fc;
            } else {
              FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
+             fon.setNumLine(an.getNumLine());
              src_tmp=tmp;
              last.addNext(fon);
              last=fon;
@@ -825,8 +870,10 @@ public class BuildFlat {
       if(nn.getClassDesc()!=null) {
         // this is a static field access inside of a static block
         fsfn=new FlatSetFieldNode(new TempDescriptor("sfsb", nn.getClassType()), nn.getField(), src_tmp);
+        fsfn.setNumLine(nn.getNumLine());
       } else {
         fsfn=new FlatSetFieldNode(getTempforVar(nn.getVar()), nn.getField(), src_tmp);
+        fsfn.setNumLine(nn.getNumLine());
       }
          if (first==null) {
            first=fsfn;
@@ -836,6 +883,7 @@ public class BuildFlat {
          last=fsfn;
          if (pre) {
            FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
+           fon2.setNumLine(an.getNumLine());
            fsfn.addNext(fon2);
            last=fon2;
          }
@@ -850,6 +898,7 @@ public class BuildFlat {
            TempDescriptor tmp=TempDescriptor.tempFactory("srctmp3_",an.getDest().getType());
            if (!pre) {
              FlatOpNode fon=new FlatOpNode(out_temp, src_tmp2, null, new Operation(Operation.ASSIGN));
+             fon.setNumLine(an.getNumLine());
              if (first==null)
                first=fon;
              else
@@ -862,6 +911,7 @@ public class BuildFlat {
              ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
              MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat2", new TypeDescriptor[] {new TypeDescriptor(stringcd), new TypeDescriptor(stringcd)});
              FlatCall fc=new FlatCall(concatmd, tmp, null, new TempDescriptor[] {src_tmp2, src_tmp});
+             fc.setNumLine(an.getNumLine());
              if (first==null)
                first=fc;
              else
@@ -870,6 +920,7 @@ public class BuildFlat {
              last=fc;
            } else {
              FlatOpNode fon=new FlatOpNode(tmp, src_tmp2, src_tmp, base);
+             fon.setNumLine(an.getNumLine());
              if (first==null)
                first=fon;
              else
@@ -880,11 +931,13 @@ public class BuildFlat {
          }
 
          FlatOpNode fon=new FlatOpNode(getTempforVar(nn.getVar()), src_tmp, null, new Operation(Operation.ASSIGN));
+         fon.setNumLine(an.getNumLine());
 
          last.addNext(fon);
          last=fon;
          if (pre) {
            FlatOpNode fon2=new FlatOpNode(out_temp, src_tmp, null, new Operation(Operation.ASSIGN));
+           fon2.setNumLine(an.getNumLine());
            fon.addNext(fon2);
            last=fon2;
          }
@@ -910,6 +963,7 @@ public class BuildFlat {
       tmp=getTempforVar(nn.getVar());
       }
       FlatFieldNode ffn=new FlatFieldNode(nn.getField(), tmp, out_temp);
+      ffn.setNumLine(nn.getNumLine());
       return new NodePair(ffn,ffn);
     } else {
       TempDescriptor tmp=getTempforVar(nn.isTag() ? nn.getTagVar() : nn.getVar());
@@ -918,6 +972,7 @@ public class BuildFlat {
        out_temp.setTag(tmp.getTag());
       }
       FlatOpNode fon=new FlatOpNode(out_temp, tmp, null, new Operation(Operation.ASSIGN));
+      fon.setNumLine(nn.getNumLine());
       return new NodePair(fon,fon);
     }
   }
@@ -941,8 +996,11 @@ public class BuildFlat {
     if (op.getOp()==Operation.LOGIC_OR) {
       /* Need to do shortcircuiting */
       FlatCondBranch fcb=new FlatCondBranch(temp_left);
+      fcb.setNumLine(on.getNumLine());
       FlatOpNode fon1=new FlatOpNode(out_temp,temp_left,null,new Operation(Operation.ASSIGN));
+      fon1.setNumLine(on.getNumLine());
       FlatOpNode fon2=new FlatOpNode(out_temp,temp_right,null,new Operation(Operation.ASSIGN));
+      fon2.setNumLine(on.getNumLine());
       FlatNop fnop=new FlatNop();
       left.getEnd().addNext(fcb);
       fcb.addFalseNext(right.getBegin());
@@ -954,8 +1012,11 @@ public class BuildFlat {
     } else if (op.getOp()==Operation.LOGIC_AND) {
       /* Need to do shortcircuiting */
       FlatCondBranch fcb=new FlatCondBranch(temp_left);
+      fcb.setNumLine(on.getNumLine());
       FlatOpNode fon1=new FlatOpNode(out_temp,temp_left,null,new Operation(Operation.ASSIGN));
+      fon1.setNumLine(on.getNumLine());
       FlatOpNode fon2=new FlatOpNode(out_temp,temp_right,null,new Operation(Operation.ASSIGN));
+      fon2.setNumLine(on.getNumLine());
       FlatNop fnop=new FlatNop();
       left.getEnd().addNext(fcb);
       fcb.addTrueNext(right.getBegin());
@@ -969,12 +1030,14 @@ public class BuildFlat {
       ClassDescriptor stringcd=typeutil.getClass(TypeUtil.StringClass);
       MethodDescriptor concatmd=typeutil.getMethod(stringcd, "concat", new TypeDescriptor[] {new TypeDescriptor(stringcd)});
       FlatCall fc=new FlatCall(concatmd, out_temp, temp_left, new TempDescriptor[] {temp_right});
+      fc.setNumLine(on.getNumLine());
       left.getEnd().addNext(right.getBegin());
       right.getEnd().addNext(fc);
       return new NodePair(left.getBegin(), fc);
     }
 
     FlatOpNode fon=new FlatOpNode(out_temp,temp_left,temp_right,op);
+    fon.setNumLine(on.getNumLine());
     left.getEnd().addNext(right.getBegin());
     right.getEnd().addNext(fon);
     return new NodePair(left.getBegin(),fon);
@@ -1040,6 +1103,7 @@ public class BuildFlat {
     TagDescriptor tag=tvd.getTag();
     TempDescriptor tmp=getTempforVar(tvd);
     FlatTagDeclaration ftd=new FlatTagDeclaration(tag, tmp);
+    ftd.setNumLine(dn.getNumLine());
     return new NodePair(ftd,ftd);
   }
 
@@ -1089,6 +1153,7 @@ public class BuildFlat {
     TempDescriptor cond_temp=TempDescriptor.tempFactory("condition",new TypeDescriptor(TypeDescriptor.BOOLEAN));
     NodePair cond=flattenExpressionNode(isn.getCondition(),cond_temp);
     FlatCondBranch fcb=new FlatCondBranch(cond_temp);
+    fcb.setNumLine(isn.getNumLine());
     NodePair true_np=flattenBlockNode(isn.getTrueBlock());
     NodePair false_np;
     FlatNop nopend=new FlatNop();
@@ -1150,9 +1215,11 @@ public class BuildFlat {
           Operation op=new Operation(Operation.EQUAL);
           left=flattenExpressionNode(sln.getCondition(), temp_left);
           FlatOpNode fon=new FlatOpNode(cond_tmp, temp_left, cond_temp, op);
+          fon.setNumLine(sln.getNumLine());
           left.getEnd().addNext(fon);
 
           FlatCondBranch fcb=new FlatCondBranch(cond_tmp);
+          fcb.setNumLine(bn.getNumLine());
           fcb.setTrueProb(State.TRUEPROB);
 
           FlatNop nop=new FlatNop();
@@ -1215,6 +1282,7 @@ public class BuildFlat {
       NodePair body=flattenBlockNode(ln.getBody());
       FlatNode begin=initializer.getBegin();
       FlatCondBranch fcb=new FlatCondBranch(cond_temp);
+      fcb.setNumLine(ln.getNumLine());
       fcb.setTrueProb(State.TRUEPROB);
       fcb.setLoop();
       FlatNop nopend=new FlatNop();
@@ -1249,6 +1317,7 @@ public class BuildFlat {
       NodePair body=flattenBlockNode(ln.getBody());
       FlatNode begin=condition.getBegin();
       FlatCondBranch fcb=new FlatCondBranch(cond_temp);
+      fcb.setNumLine(ln.getNumLine());
       fcb.setTrueProb(State.TRUEPROB);
       fcb.setLoop();
       FlatNop nopend=new FlatNop();
@@ -1281,6 +1350,7 @@ public class BuildFlat {
       NodePair body=flattenBlockNode(ln.getBody());
       FlatNode begin=body.getBegin();
       FlatCondBranch fcb=new FlatCondBranch(cond_temp);
+      fcb.setNumLine(ln.getNumLine());
       fcb.setTrueProb(State.TRUEPROB);
       fcb.setLoop();
       FlatNop nopend=new FlatNop();
@@ -1318,6 +1388,7 @@ public class BuildFlat {
     }
 
     FlatReturnNode rnflat=new FlatReturnNode(retval);
+    rnflat.setNumLine(rntree.getNumLine());
     rnflat.addNext(fe);
     FlatNode ln=rnflat;
     if ((state.THREAD||state.MGC)&&!this.lockStack.isEmpty()) {
@@ -1326,6 +1397,7 @@ public class BuildFlat {
       for(int j = this.lockStack.size(); j > 0; j--) {
         TempDescriptor thistd = this.lockStack.elementAt(j-1);
         FlatCall fcunlock = new FlatCall(memdex, null, thistd, new TempDescriptor[0]);
+        fcunlock.setNumLine(rntree.getNumLine());
         if(end != null) {
           end.addNext(fcunlock);
         }
@@ -1354,6 +1426,7 @@ public class BuildFlat {
     NodePair fcn=flattenConstraintCheck(ten.getChecks());
     ffan.addNext(fcn.getBegin());
     FlatReturnNode rnflat=new FlatReturnNode(null);
+    rnflat.setNumLine(ten.getNumLine());
     rnflat.addNext(fe);
     fcn.getEnd().addNext(rnflat);
     return new NodePair(ffan, null);
@@ -1407,9 +1480,12 @@ public class BuildFlat {
 
     MethodDescriptor menmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorEnter");
     FlatCall fcen=new FlatCall(menmd, null, montmp, new TempDescriptor[0]);
+    fcen.setNumLine(sbn.getNumLine());
 
     MethodDescriptor mexmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
     FlatCall fcex=new FlatCall(mexmd, null, montmp, new TempDescriptor[0]);
+    fcex.setNumLine(sbn.getNumLine());
+    
     this.lockStack.pop();
 
     if(first != null) {
@@ -1432,6 +1508,7 @@ public class BuildFlat {
   private NodePair flattenAtomicNode(AtomicNode sbn) {
     NodePair np=flattenBlockNode(sbn.getBlockNode());
     FlatAtomicEnterNode faen=new FlatAtomicEnterNode();
+    faen.setNumLine(sbn.getNumLine());
     FlatAtomicExitNode faexn=new FlatAtomicExitNode(faen);
     faen.addNext(np.getBegin());
     np.getEnd().addNext(faexn);
@@ -1446,6 +1523,7 @@ public class BuildFlat {
   private NodePair flattenSESENode(SESENode sn) {
     if( sn.isStart() ) {
       FlatSESEEnterNode fsen=new FlatSESEEnterNode(sn);
+      fsen.setNumLine(sn.getNumLine());
       sn.setFlatEnter(fsen);
       return new NodePair(fsen, fsen);
     }
@@ -1472,6 +1550,7 @@ public class BuildFlat {
     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);
+    fion.setNumLine(tn.getNumLine());
     cond.getEnd().addNext(fion);
     return new NodePair(cond.getBegin(),fion);
   }
@@ -1487,6 +1566,7 @@ public class BuildFlat {
     FlatNode last=null;
     TempDescriptor tmp=TempDescriptor.tempFactory("arg", new TypeDescriptor(TypeDescriptor.INT));
     FlatLiteralNode fln_tmp=new FlatLiteralNode(tmp.getType(), new Integer(ain.numVarInitializers()), tmp);
+    fln_tmp.setNumLine(ain.getNumLine());
     first = last=fln_tmp;
     
     // create the new array
@@ -1502,12 +1582,14 @@ public class BuildFlat {
       // index=i
       TempDescriptor index=TempDescriptor.tempFactory("index", new TypeDescriptor(TypeDescriptor.INT));
       FlatLiteralNode fln=new FlatLiteralNode(index.getType(), new Integer(i), index);
+      fln.setNumLine(ain.getNumLine());
       // calculate the initial value
       NodePair np_init = flattenExpressionNode(var_init_node, tmp_init);
       // TODO wrapper class process is missing now
       /*if(td.isArray() && td.dereference().iswrapper()) {
       }*/
       FlatSetElementNode fsen=new FlatSetElementNode(tmp_toinit, index, tmp_init);
+      fsen.setNumLine(ain.getNumLine());
       last.addNext(fln);
       fln.addNext(np_init.getBegin());
       np_init.getEnd().addNext(fsen);
@@ -1524,12 +1606,15 @@ public class BuildFlat {
 
     NodePair cond=flattenExpressionNode(tn.getCond(),cond_temp);
     FlatCondBranch fcb=new FlatCondBranch(cond_temp);
+    fcb.setNumLine(tn.getNumLine());
 
     NodePair trueExpr=flattenExpressionNode(tn.getTrueExpr(),true_temp);
     FlatOpNode fonT=new FlatOpNode(out_temp, true_temp, null, new Operation(Operation.ASSIGN));
+    fonT.setNumLine(tn.getNumLine());
 
     NodePair falseExpr=flattenExpressionNode(tn.getFalseExpr(),fals_temp);
     FlatOpNode fonF=new FlatOpNode(out_temp, fals_temp, null, new Operation(Operation.ASSIGN));
+    fonF.setNumLine(tn.getNumLine());
 
     FlatNop nopend=new FlatNop();
 
index 2605623410359f5b9885275741d27af70c95915f..12e9be9156dc3d495d82869651af145f5acc13ba 100644 (file)
@@ -9,7 +9,7 @@ public class FlatNode {
   protected Vector prev;
   static int idcounter=0;
   public final int nodeid;
-  public int lineNum;
+  public int numLine;
 
   public FlatNode() {
     next=new Vector();
@@ -137,11 +137,11 @@ public class FlatNode {
     prev=null;
   }
   
-  public void setLineNum(int lineNum){
-    this.lineNum=lineNum;
+  public void setNumLine(int lineNum){
+    this.numLine=lineNum;
   }
   
-  public int getLineNume(){
-    return this.lineNum;
+  public int getNumLine(){
+    return this.numLine;
   }
 }
index ef028a6186ffbdef024131b54d27fe529777c87f..5a1a7652cea9c6fd6417772eb778f27cffc0bfb8 100644 (file)
@@ -691,6 +691,7 @@ public void parseInitializers(ClassDescriptor cn){
           BlockNode bn=new BlockNode();
           NameNode nn=new NameNode(new NameDescriptor(identifier));
           AssignmentNode an=new AssignmentNode(nn,en,new AssignOperation(1));
+          an.setNumLine(pn.getLine());
           bn.addBlockStatement(new BlockExpressionNode(an));
           if(isfirst) {
             state.addTreeCode(md,bn);
@@ -749,14 +750,18 @@ public void parseInitializers(ClassDescriptor cn){
                isNode(pn,"postdec")) {
       ParseNode left=pn.getFirstChild();
       AssignOperation op=new AssignOperation(pn.getLabel());
-      return new AssignmentNode(parseExpression(left),null,op);
+      AssignmentNode an=new AssignmentNode(parseExpression(left),null,op);
+      an.setNumLine(pn.getLine());
+      return an;
 
     } else if (isNode(pn,"preinc")||
                isNode(pn,"predec")) {
       ParseNode left=pn.getFirstChild();
       AssignOperation op=isNode(pn,"preinc") ? new AssignOperation(AssignOperation.PLUSEQ) : new AssignOperation(AssignOperation.MINUSEQ);
-      return new AssignmentNode(parseExpression(left),
-                                new LiteralNode("integer",new Integer(1)),op);
+      AssignmentNode an=new AssignmentNode(parseExpression(left),
+          new LiteralNode("integer",new Integer(1)),op);
+      an.setNumLine(pn.getLine());
+      return an;
     } else if (isNode(pn,"literal")) {
       String literaltype=pn.getTerminal();
       ParseNode literalnode=pn.getChild(literaltype);
@@ -773,6 +778,7 @@ public void parseInitializers(ClassDescriptor cn){
        disjointId = pn.getChild("disjoint").getTerminal();
       }
       CreateObjectNode con=new CreateObjectNode(td, isglobal, disjointId);
+      con.setNumLine(pn.getLine());
       for(int i=0; i<args.size(); i++) {
        con.addArgument((ExpressionNode)args.get(i));
       }
@@ -804,6 +810,7 @@ public void parseInitializers(ClassDescriptor cn){
       for(int i=0; i<(args.size()+num); i++)
        td=td.makeArray(state);
       CreateObjectNode con=new CreateObjectNode(td, isglobal, disjointId);
+      con.setNumLine(pn.getLine());
       for(int i=0; i<args.size(); i++) {
        con.addArgument((ExpressionNode)args.get(i));
       }
@@ -816,17 +823,23 @@ public void parseInitializers(ClassDescriptor cn){
       for(int i=0; i<num; i++)
     td=td.makeArray(state);
       CreateObjectNode con=new CreateObjectNode(td, false, null);
+      con.setNumLine(pn.getLine());
       ParseNode ipn = pn.getChild("initializer");     
       Vector initializers=parseVariableInitializerList(ipn);
       ArrayInitializerNode ain = new ArrayInitializerNode(initializers);
+      ain.setNumLine(pn.getLine());
       con.addArrayInitializer(ain);
       return con;
     } else if (isNode(pn,"name")) {
       NameDescriptor nd=parseName(pn);
-      return new NameNode(nd);
+      NameNode nn=new NameNode(nd);
+      nn.setNumLine(pn.getLine());
+      return nn;
     } else if (isNode(pn,"this")) {
       NameDescriptor nd=new NameDescriptor("this");
-      return new NameNode(nd);
+      NameNode nn=new NameNode(nd);
+      nn.setNumLine(pn.getLine());
+      return nn;
     } else if (isNode(pn,"isavailable")) {
       NameDescriptor nd=new NameDescriptor(pn.getTerminal());
       return new OpNode(new NameNode(nd),null,new Operation(Operation.ISAVAILABLE));
@@ -834,6 +847,7 @@ public void parseInitializers(ClassDescriptor cn){
       NameDescriptor nd=parseName(pn.getChild("name"));
       Vector args=parseArgumentList(pn);
       MethodInvokeNode min=new MethodInvokeNode(nd);
+      min.setNumLine(pn.getLine());
       for(int i=0; i<args.size(); i++) {
        min.addArgument((ExpressionNode)args.get(i));
       }
@@ -843,6 +857,7 @@ public void parseInitializers(ClassDescriptor cn){
       ExpressionNode exp=parseExpression(pn.getChild("base").getFirstChild());
       Vector args=parseArgumentList(pn);
       MethodInvokeNode min=new MethodInvokeNode(methodid,exp);
+      min.setNumLine(pn.getLine());
       for(int i=0; i<args.size(); i++) {
        min.addArgument((ExpressionNode)args.get(i));
       }
@@ -850,40 +865,57 @@ public void parseInitializers(ClassDescriptor cn){
     } else if (isNode(pn,"fieldaccess")) {
       ExpressionNode en=parseExpression(pn.getChild("base").getFirstChild());
       String fieldname=pn.getChild("field").getTerminal();
-      return new FieldAccessNode(en,fieldname);
+      
+      FieldAccessNode fan=new FieldAccessNode(en,fieldname);
+      fan.setNumLine(pn.getLine());
+      return fan;
     } else if (isNode(pn,"arrayaccess")) {
       ExpressionNode en=parseExpression(pn.getChild("base").getFirstChild());
       ExpressionNode index=parseExpression(pn.getChild("index").getFirstChild());
-      return new ArrayAccessNode(en,index);
+      ArrayAccessNode aan=new ArrayAccessNode(en,index);
+      aan.setNumLine(pn.getLine());
+      return aan;
     } else if (isNode(pn,"cast1")) {
       try {
-       return new CastNode(parseTypeDescriptor(pn.getChild("type")),parseExpression(pn.getChild("exp").getFirstChild()));
+  CastNode cn=new CastNode(parseTypeDescriptor(pn.getChild("type")),parseExpression(pn.getChild("exp").getFirstChild()));
+  cn.setNumLine(pn.getLine());      
+       return cn;
       } catch (Exception e) {
        System.out.println(pn.PPrint(1,true));
        e.printStackTrace();
        throw new Error();
       }
     } else if (isNode(pn,"cast2")) {
-      return new CastNode(parseExpression(pn.getChild("type").getFirstChild()),parseExpression(pn.getChild("exp").getFirstChild()));
+      CastNode cn=new CastNode(parseExpression(pn.getChild("type").getFirstChild()),parseExpression(pn.getChild("exp").getFirstChild()));
+      cn.setNumLine(pn.getLine());
+      return cn;
     } 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()) );
+      
+      TertiaryNode tn=new TertiaryNode(parseExpression(pn.getChild("cond").getFirstChild()),
+          parseExpression(pn.getChild("trueexpr").getFirstChild()),
+          parseExpression(pn.getChild("falseexpr").getFirstChild()) );
+      tn.setNumLine(pn.getLine());
+      
+      return tn;
     } else if (isNode(pn, "instanceof")) {
       ExpressionNode exp=parseExpression(pn.getChild("exp").getFirstChild());
       TypeDescriptor t=parseTypeDescriptor(pn);
-      return new InstanceOfNode(exp,t);
+      InstanceOfNode ion=new InstanceOfNode(exp,t);
+      ion.setNumLine(pn.getLine());
+      return ion;
     } else if (isNode(pn, "array_initializer")) {  
       Vector initializers=parseVariableInitializerList(pn);
       return new ArrayInitializerNode(initializers);
     } else if (isNode(pn, "class_type")) {
       TypeDescriptor td=parseTypeDescriptor(pn);
-      return new ClassTypeNode(td);
+      ClassTypeNode ctn=new ClassTypeNode(td);
+      ctn.setNumLine(pn.getLine());
+      return ctn;
     } else if (isNode(pn, "empty")) {
       return null;
     } else {
@@ -951,6 +983,7 @@ public void parseInitializers(ClassDescriptor cn){
     ParseNodeVector pnv=pn.getChild("args").getChildren();
 
     AssignmentNode an=new AssignmentNode(parseExpression(pnv.elementAt(0)),parseExpression(pnv.elementAt(1)),ao);
+    an.setNumLine(pn.getLine());
     return an;
   }
 
@@ -961,6 +994,7 @@ public void parseInitializers(ClassDescriptor cn){
     MethodDescriptor md=parseMethodHeader(headern);
     try {
       BlockNode bn=parseBlock(bodyn);
+      bn.setNumLine(pn.getLine()); // assume that method header is located at the beginning of method body
       cn.addMethod(md);
       state.addTreeCode(md,bn);
 
@@ -1007,6 +1041,7 @@ public void parseInitializers(ClassDescriptor cn){
       NameDescriptor nd=new NameDescriptor("super");
       Vector args=parseArgumentList(sin);
       MethodInvokeNode min=new MethodInvokeNode(nd);
+      min.setNumLine(sin.getLine());
       for(int i=0; i<args.size(); i++) {
        min.addArgument((ExpressionNode)args.get(i));
       }
@@ -1018,10 +1053,12 @@ public void parseInitializers(ClassDescriptor cn){
       NameDescriptor nd=new NameDescriptor(cn.getSymbol());
       Vector args=parseArgumentList(eci);
       MethodInvokeNode min=new MethodInvokeNode(nd);
+      min.setNumLine(eci.getLine());
       for(int i=0; i<args.size(); i++) {
        min.addArgument((ExpressionNode)args.get(i));
       }
       BlockExpressionNode ben=new BlockExpressionNode(min);
+      ben.setNumLine(eci.getLine());
       bn.addFirstBlockStatement(ben);
     }
     state.addTreeCode(md,bn);
@@ -1108,7 +1145,10 @@ public void parseInitializers(ClassDescriptor cn){
       String name=pn.getChild("single").getTerminal();
       String type=pn.getChild("type").getTerminal();
 
-      blockstatements.add(new TagDeclarationNode(name, type));
+      TagDeclarationNode tdn=new TagDeclarationNode(name, type);
+      tdn.setNumLine(pn.getLine());
+      
+      blockstatements.add(tdn);
     } else if (isNode(pn,"local_variable_declaration")) {
       
       ParseNode mn=pn.getChild("modifiers");         
@@ -1138,21 +1178,31 @@ public void parseInitializers(ClassDescriptor cn){
        ExpressionNode en=null;
        if (epn!=null)
          en=parseExpression(epn.getFirstChild());
+       
+       DeclarationNode dn=new DeclarationNode(new VarDescriptor(arrayt, identifier),en);
+       dn.setNumLine(tmp.getLine());
 
-       blockstatements.add(new DeclarationNode(new VarDescriptor(arrayt, identifier),en));
+       blockstatements.add(dn);
       }
     } else if (isNode(pn,"nop")) {
       /* Do Nothing */
     } else if (isNode(pn,"expression")) {
-      blockstatements.add(new BlockExpressionNode(parseExpression(pn.getFirstChild())));
+      BlockExpressionNode ben=new BlockExpressionNode(parseExpression(pn.getFirstChild()));
+      ben.setNumLine(pn.getLine());
+      blockstatements.add(ben);
     } else if (isNode(pn,"ifstatement")) {
-      blockstatements.add(new IfStatementNode(parseExpression(pn.getChild("condition").getFirstChild()),
-                                              parseSingleBlock(pn.getChild("statement").getFirstChild()),
-                                              pn.getChild("else_statement")!=null ? parseSingleBlock(pn.getChild("else_statement").getFirstChild()) : null));
+      IfStatementNode isn=new IfStatementNode(parseExpression(pn.getChild("condition").getFirstChild()),
+          parseSingleBlock(pn.getChild("statement").getFirstChild()),
+          pn.getChild("else_statement")!=null ? parseSingleBlock(pn.getChild("else_statement").getFirstChild()) : null);
+      isn.setNumLine(pn.getLine());
+      
+      blockstatements.add(isn);
     } else if (isNode(pn,"switch_statement")) {
       // TODO add version for normal Java later
-      blockstatements.add(new SwitchStatementNode(parseExpression(pn.getChild("condition").getFirstChild()),
-          parseSingleBlock(pn.getChild("statement").getFirstChild())));
+      SwitchStatementNode ssn=new SwitchStatementNode(parseExpression(pn.getChild("condition").getFirstChild()),
+          parseSingleBlock(pn.getChild("statement").getFirstChild()));
+      ssn.setNumLine(pn.getLine());
+      blockstatements.add(ssn);
     } else if (isNode(pn,"switch_block_list")) {
       // TODO add version for normal Java later
       ParseNodeVector pnv=pn.getChildren();
@@ -1166,14 +1216,21 @@ public void parseInitializers(ClassDescriptor cn){
           for(int j=0; j<labelv.size(); j++) {
             ParseNode labeldecl=labelv.elementAt(j);
             if(isNode(labeldecl, "switch_label")) {
-              slv.addElement(new SwitchLabelNode(parseExpression(labeldecl.getChild("constant_expression").getFirstChild()), false));
+              SwitchLabelNode sln=new SwitchLabelNode(parseExpression(labeldecl.getChild("constant_expression").getFirstChild()), false);
+              sln.setNumLine(labeldecl.getLine());
+              slv.addElement(sln);
             } else if(isNode(labeldecl, "default_switch_label")) {
-              slv.addElement(new SwitchLabelNode(null, true));
+              SwitchLabelNode sln=new SwitchLabelNode(null, true);
+              sln.setNumLine(labeldecl.getLine());
+              slv.addElement(sln);
             }
           }
           
-          blockstatements.add(new SwitchBlockNode(slv, 
-              parseSingleBlock(sblockdecl.getChild("switch_statements").getFirstChild())));
+          SwitchBlockNode sbn=new SwitchBlockNode(slv, 
+              parseSingleBlock(sblockdecl.getChild("switch_statements").getFirstChild()));
+          sbn.setNumLine(sblockdecl.getLine());
+          
+          blockstatements.add(sbn);
           
         }
       }
@@ -1201,21 +1258,28 @@ public void parseInitializers(ClassDescriptor cn){
       Vector ccs=null;
       if (pn.getChild("cons_checks")!=null)
        ccs=parseChecks(pn.getChild("cons_checks"));
-
-      blockstatements.add(new TaskExitNode(vfe, ccs, this.m_taskexitnum++));
+      TaskExitNode ten=new TaskExitNode(vfe, ccs, this.m_taskexitnum++);
+      ten.setNumLine(pn.getLine());
+      blockstatements.add(ten);
     } else if (isNode(pn,"atomic")) {
       BlockNode bn=parseBlockHelper(pn);
-      blockstatements.add(new AtomicNode(bn));
+      AtomicNode an=new AtomicNode(bn);
+      an.setNumLine(pn.getLine());
+      blockstatements.add(an);
     } else if (isNode(pn,"synchronized")) {
       BlockNode bn=parseBlockHelper(pn.getChild("block"));
       ExpressionNode en=parseExpression(pn.getChild("expr").getFirstChild());
-      blockstatements.add(new SynchronizedNode(en, bn));
+      SynchronizedNode sn=new SynchronizedNode(en, bn);
+      sn.setNumLine(pn.getLine());
+      blockstatements.add(sn);
     } else if (isNode(pn,"return")) {
       if (isEmpty(pn.getTerminal()))
        blockstatements.add(new ReturnNode());
       else {
        ExpressionNode en=parseExpression(pn.getFirstChild());
-       blockstatements.add(new ReturnNode(en));
+       ReturnNode rn=new ReturnNode(en);
+       rn.setNumLine(pn.getLine());
+       blockstatements.add(rn);
       }
     } else if (isNode(pn,"block_statement_list")) {
       BlockNode bn=parseBlockHelper(pn);
@@ -1239,7 +1303,9 @@ public void parseInitializers(ClassDescriptor cn){
         // no condition clause, make a 'true' expression as the condition
         condition = (ExpressionNode)new LiteralNode("boolean", new Boolean(true));
       }
-      blockstatements.add(new LoopNode(init,condition,update,body));
+      LoopNode ln=new LoopNode(init,condition,update,body);
+      ln.setNumLine(pn.getLine());
+      blockstatements.add(ln);
     } else if (isNode(pn,"whilestatement")) {
       ExpressionNode condition=parseExpression(pn.getChild("condition").getFirstChild());
       BlockNode body=parseSingleBlock(pn.getChild("statement").getFirstChild());
@@ -1261,6 +1327,7 @@ public void parseInitializers(ClassDescriptor cn){
       String stID=null;
       if( pnID != null ) { stID=pnID.getFirstChild().getTerminal(); }
       SESENode start=new SESENode(stID);
+      start.setNumLine(pn.getLine());
       SESENode end  =new SESENode(stID);
       start.setEnd( end   );
       end.setStart( start );
@@ -1268,9 +1335,13 @@ public void parseInitializers(ClassDescriptor cn){
       blockstatements.addAll(parseSESEBlock(blockstatements,pn.getChild("body").getFirstChild()));
       blockstatements.add(end);
     } else if (isNode(pn,"continue")) {
-      blockstatements.add(new ContinueBreakNode(false));
+      ContinueBreakNode cbn=new ContinueBreakNode(false);
+      cbn.setNumLine(pn.getLine());
+      blockstatements.add(cbn);
     } else if (isNode(pn,"break")) {
-      blockstatements.add(new ContinueBreakNode(true));
+      ContinueBreakNode cbn=new ContinueBreakNode(true);
+      cbn.setNumLine(pn.getLine());
+      blockstatements.add(cbn);
 
     } else if (isNode(pn,"genreach")) {
       String graphName = pn.getChild("graphName").getTerminal();