Make SPECjbb compile again
[IRC.git] / Robust / src / IR / Tree / BuildIR.java
index 91370d913721969e8a32e23d6eec1c409692cc5e..8b7d2585a4dd197c26e13a59ea6df9a8ac382edd 100644 (file)
@@ -1,6 +1,7 @@
 package IR.Tree;
 import IR.*;
 import Util.Lattice;
+import Util.Pair;
 
 import java.io.File;
 import java.util.*;
@@ -48,7 +49,7 @@ public class BuildIR {
     }
 
     ParseNode ipn = pn.getChild("imports").getChild("import_decls_list");
-    if (ipn != null) {
+    if ((ipn != null) && !state.MGC) {
       ParseNodeVector pnv = ipn.getChildren();
       for (int i = 0; i < pnv.size(); i++) {
         ParseNode pnimport = pnv.elementAt(i);
@@ -70,7 +71,7 @@ public class BuildIR {
 
     ParseNode ppn=pn.getChild("packages").getChild("package");
     String packageName = null;
-    if (ppn!=null) {
+    if ((ppn!=null) && !state.MGC){
       NameDescriptor nd = parseClassName(ppn.getChild("name"));
       packageName = nd.getPathFromRootToHere();
       //Trick -> import the package directory as a multi-import and it'll
@@ -632,18 +633,28 @@ public class BuildIR {
     Lattice<String> locOrder =
       new Lattice<String>("_top_","_bottom_");
     Set<String> spinLocSet=new HashSet<String>();
+    String thisLoc=null;
     for (int i = 0; i < pnv.size(); i++) {
       ParseNode loc = pnv.elementAt(i);
       if(isNode(loc,"location_property")) {
-        String spinLoc=loc.getChildren().elementAt(0).getLabel();
-        spinLocSet.add(spinLoc);
+        if(loc.getFirstChild().getLabel().equals("location_multi")){
+          String spinLoc=loc.getFirstChild().getFirstChild().getLabel();
+          spinLocSet.add(spinLoc);
+        }else{
+          thisLoc=loc.getFirstChild().getFirstChild().getLabel();
+        }
       } else {
-        String lowerLoc=loc.getChildren().elementAt(0).getLabel();
-        String higherLoc= loc.getChildren().elementAt(1).getLabel();
-        locOrder.put(higherLoc, lowerLoc);
-        if (locOrder.isIntroducingCycle(higherLoc)) {
-          throw new Error("Error: the order relation " + lowerLoc + " < " + higherLoc
-                          + " introduces a cycle.");
+        if(loc.getChildren().size()==1){
+          String locIentifier=loc.getChildren().elementAt(0).getLabel();
+          locOrder.put(locIentifier);
+        }else{
+          String lowerLoc=loc.getChildren().elementAt(0).getLabel();
+          String higherLoc= loc.getChildren().elementAt(1).getLabel();
+          locOrder.put(higherLoc, lowerLoc);
+          if (locOrder.isIntroducingCycle(higherLoc)) {
+            throw new Error("Error: the order relation " + lowerLoc + " < " + higherLoc
+                + " introduces a cycle.");
+          }
         }
       }
     }
@@ -656,7 +667,10 @@ public class BuildIR {
                           locID + "' is not defined in the hierarchy of the class '"+cd +"'.");
         }
       }
-      state.addLocationPropertySet(cd, spinLocSet);
+      state.addLocationProperty(new Pair(cd,"spin"), spinLocSet);
+    }
+    if(thisLoc!=null){
+      state.addLocationProperty(new Pair(cd,"this"), thisLoc);
     }
     state.addLocationOrder(cd, locOrder);
   }
@@ -851,7 +865,6 @@ public class BuildIR {
 
     ParseNode tn=pn.getChild("type");
     TypeDescriptor t=parseTypeDescriptor(tn);
-    assignAnnotationsToType(m,t);
     ParseNode vn=pn.getChild("variables").getChild("variable_declarators_list");
     ParseNodeVector pnv=vn.getChildren();
     boolean isglobal=pn.getChild("global")!=null;
@@ -910,6 +923,7 @@ public class BuildIR {
       }
 
       cn.addField(new FieldDescriptor(m, arrayt, identifier, en, isglobal));
+      assignAnnotationsToType(m,arrayt);
     }
   }
 
@@ -1379,12 +1393,7 @@ public class BuildIR {
       blockstatements.add(tdn);
     } else if (isNode(pn,"local_variable_declaration")) {
 
-      ParseNode mn=pn.getChild("modifiers");
       TypeDescriptor t=parseTypeDescriptor(pn);
-      if(mn!=null) {
-        Modifiers m=parseModifiersList(mn);
-        assignAnnotationsToType(m, t);
-      }
       ParseNode vn=pn.getChild("variable_declarators_list");
       ParseNodeVector pnv=vn.getChildren();
       for(int i=0; i<pnv.size(); i++) {
@@ -1409,6 +1418,13 @@ public class BuildIR {
 
         DeclarationNode dn=new DeclarationNode(new VarDescriptor(arrayt, identifier),en);
         dn.setNumLine(tmp.getLine());
+        
+        ParseNode mn=pn.getChild("modifiers");
+        if(mn!=null) {
+          // here, modifers parse node has the list of annotations
+          Modifiers m=parseModifiersList(mn);
+          assignAnnotationsToType(m, arrayt);
+        }
 
         blockstatements.add(dn);
       }