My changes to add interface affect to FieldShadow
authorjzhou <jzhou>
Sat, 26 Feb 2011 00:28:37 +0000 (00:28 +0000)
committerjzhou <jzhou>
Sat, 26 Feb 2011 00:28:37 +0000 (00:28 +0000)
Robust/src/IR/Flat/BuildCodeMGC.java
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/IR/Flat/FieldShadow.java

index 77ca64e09dfcfdfbfe47208f35e255cc57f5063b..c0accd80458796a62b8b14509efb43f2dafd1506 100644 (file)
@@ -55,6 +55,9 @@ public class BuildCodeMGC extends BuildCode {
       e.printStackTrace();
       System.exit(-1);
     }
+    
+    /* Fix field safe symbols due to shadowing */
+    FieldShadow.handleFieldShadow(state);
 
     /* Build the virtual dispatch tables */
     super.buildVirtualTables(outvirtual);
index 6ca8e8b80cf67d791328c70f5c8d4ba7632747f1..8da73cd467529431d84b715a36008bb764536afe 100644 (file)
@@ -130,9 +130,15 @@ public class BuildCodeMultiCore extends BuildCode {
       e.printStackTrace();
       System.exit(-1);
     }
+    
+    /* Fix field safe symbols due to shadowing */
+    FieldShadow.handleFieldShadow(state);
 
     /* Build the virtual dispatch tables */
     super.buildVirtualTables(outvirtual);
+    
+    /* Tag the methods that are invoked by static blocks */
+    super.tagMethodInvokedByStaticBlock();
 
     /* Output includes */
     outmethodheader.println("#ifndef METHODHEADERS_H");
index 2f5f9abbc4800b47f4178a02a18201609b8419b1..a420774e1be5061c8cd11a0bd3b1515c018449a8 100644 (file)
@@ -15,8 +15,23 @@ public class FieldShadow {
   private static void handleClass(ClassDescriptor cd, State state, HashMap<ClassDescriptor, HashMap<String, Integer>> namemap) {
     if (cd.getSuperDesc()!=null&&!namemap.containsKey(cd.getSuperDesc()))
       handleClass(cd.getSuperDesc(), state, namemap);
+    
+    Iterator it_sifs = cd.getSuperInterfaces();
+    while(it_sifs.hasNext()) {
+      ClassDescriptor sif = (ClassDescriptor)it_sifs.next();
+      if (!namemap.containsKey(sif))
+        handleClass(sif, state, namemap);
+    }
+    
     HashMap<String, Integer> supermap=cd.getSuperDesc()!=null?namemap.get(cd.getSuperDesc()):new HashMap<String, Integer>();
     
+    Vector<HashMap<String, Integer>> superifmaps = new Vector<HashMap<String, Integer>>();
+    it_sifs = cd.getSuperInterfaces();
+    while(it_sifs.hasNext()) {
+      ClassDescriptor sif = (ClassDescriptor)it_sifs.next();
+      superifmaps.addElement(namemap.get(sif));
+    }
+    
     HashMap<String, Integer> fieldmap=new HashMap<String, Integer>();
     namemap.put(cd, fieldmap);
     
@@ -28,6 +43,8 @@ public class FieldShadow {
        fieldmap.put(fd.getSymbol(), new Integer(newint));
        fd.changeSafeSymbol(newint);
       } else {
+        // the fields in interfaces are defaultely static & final, so do not need to 
+        // check them, they will always have the interface name as prefix
        fieldmap.put(fd.getSymbol(), new Integer(0));
       }
     }