changes to MGC class library
[IRC.git] / Robust / src / IR / Virtual.java
index 8402b83e3d493646a247ebeda7ad203309d2e829..61347496bd6dc531740fd0e23f0b461831dda47f 100644 (file)
@@ -53,9 +53,9 @@ public class Virtual {
     while(classit.hasNext()) {
       ClassDescriptor cd=(ClassDescriptor)classit.next();
       if (state.DSM||state.SINGLETM)
-       numberLocality(cd);
+        numberLocality(cd);
       else
-       numberMethods(cd);
+        numberMethods(cd);
     }
     classit=state.getClassSymbolTable().getDescriptorsIterator();
     while(classit.hasNext()) {
@@ -76,42 +76,42 @@ public class Virtual {
       start=numberLocality(superdesc);
 
     if (locality.getClassBindings(cd)!=null)
-      for(Iterator<LocalityBinding> lbit=locality.getClassBindings(cd).iterator(); lbit.hasNext();) {
-       LocalityBinding lb=lbit.next();
-       MethodDescriptor md=lb.getMethod();
-       //Is it a static method or constructor
-       if (md.isStatic()||md.getReturnType()==null)
-         continue;
-
-       if (superdesc!=null) {
-         Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
-         boolean foundmatch=false;
-         for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) {
-           MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-           if (md.matches(matchmd)) {
-             Set<LocalityBinding> lbset=locality.getMethodBindings(matchmd);
-             if (lbset!=null)
-               for(Iterator<LocalityBinding> suplbit=lbset.iterator(); suplbit.hasNext();) {
-                 LocalityBinding suplb=suplbit.next();
-                 if (lb.contextMatches(suplb)) {
-                   foundmatch=true;
-                   localitynumber.put(lb, localitynumber.get(suplb));
-                   break;
-                 }
-               }
-             break;
-           }
-         }
-         if (!foundmatch)
-           localitynumber.put(lb, new Integer(start++));
-       } else {
-         localitynumber.put(lb, new Integer(start++));
-       }
+      for(Iterator<LocalityBinding> lbit=locality.getClassBindings(cd).iterator(); lbit.hasNext(); ) {
+        LocalityBinding lb=lbit.next();
+        MethodDescriptor md=lb.getMethod();
+        //Is it a static method or constructor
+        if (md.isStatic()||md.getReturnType()==null)
+          continue;
+
+        if (superdesc!=null) {
+          Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
+          boolean foundmatch=false;
+          for(Iterator matchit=possiblematches.iterator(); matchit.hasNext(); ) {
+            MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+            if (md.matches(matchmd)) {
+              Set<LocalityBinding> lbset=locality.getMethodBindings(matchmd);
+              if (lbset!=null)
+                for(Iterator<LocalityBinding> suplbit=lbset.iterator(); suplbit.hasNext(); ) {
+                  LocalityBinding suplb=suplbit.next();
+                  if (lb.contextMatches(suplb)) {
+                    foundmatch=true;
+                    localitynumber.put(lb, localitynumber.get(suplb));
+                    break;
+                  }
+                }
+              break;
+            }
+          }
+          if (!foundmatch)
+            localitynumber.put(lb, new Integer(start++));
+        } else {
+          localitynumber.put(lb, new Integer(start++));
+        }
       }
     classmethodcount.put(cd, new Integer(start));
     return start;
   }
-  
+
   private int numberMethodsIF(ClassDescriptor cd) {
     if(!cd.isInterface()) {
       return 0;
@@ -125,17 +125,17 @@ public class Virtual {
       ClassDescriptor superif = (ClassDescriptor)it_sifs.next();
       mnum += numberMethodsIF(superif);
     }
-    for(Iterator it=cd.getMethods(); it.hasNext();) {
+    for(Iterator it=cd.getMethods(); it.hasNext(); ) {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
         continue;
 
       if (!callgraph.isCallable(md)&&!callgraph.isCalled(md))
-       continue;
+        continue;
       boolean foundmatch=false;
       // check if there is a matched method that has been assigned method num
       Set possiblematches_if = if_methods.getSet(md.getSymbol());
-      for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext();) {
+      for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext(); ) {
         MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
         if (md.matches(matchmd)) {
           int num=methodnumber.get(matchmd);
@@ -145,9 +145,9 @@ public class Virtual {
         }
       }
       if (!foundmatch) {
-       methodnumber.put(md, new Integer(if_starts++));
-       if_methods.add(md);
-       mnum++;
+        methodnumber.put(md, new Integer(if_starts++));
+        if_methods.add(md);
+        mnum++;
       }
     }
     classmethodcount.put(cd, new Integer(mnum));
@@ -164,43 +164,43 @@ public class Virtual {
       mnum = numberMethods(superdesc);
       start += mnum;
     }
-    methodit:
-    for(Iterator it=cd.getMethods(); it.hasNext();) {
+methodit:
+    for(Iterator it=cd.getMethods(); it.hasNext(); ) {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
         continue;
       if (!callgraph.isCallable(md)&&!callgraph.isCalled(md))
-       continue;
+        continue;
       // check if there is a matched method in methods defined in interfaces
       Set possiblematches_if=if_methods.getSet(md.getSymbol());
-      for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext();) {
+      for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext(); ) {
         MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
         if (md.matches(matchmd)) {
-         int num;
-         if (!methodnumber.containsKey(matchmd)) {
-           num=start++;
-           mnum++;
-           methodnumber.put(matchmd,num);
-         } else
-           num = methodnumber.get(matchmd);
+          int num;
+          if (!methodnumber.containsKey(matchmd)) {
+            num=start++;
+            mnum++;
+            methodnumber.put(matchmd,num);
+          } else
+            num = methodnumber.get(matchmd);
           methodnumber.put(md, new Integer(num));
-         continue methodit;
+          continue methodit;
         }
       }
       if (superdesc!=null) {
         Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
-        for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) {
+        for(Iterator matchit=possiblematches.iterator(); matchit.hasNext(); ) {
           MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
           if (md.matches(matchmd)) {
-           int num;
-           if (!methodnumber.containsKey(matchmd)) {
-             num=start++;
-             mnum++;
-             methodnumber.put(matchmd,num);
-           } else
-             num = methodnumber.get(matchmd);
+            int num;
+            if (!methodnumber.containsKey(matchmd)) {
+              num=start++;
+              mnum++;
+              methodnumber.put(matchmd,num);
+            } else
+              num = methodnumber.get(matchmd);
             methodnumber.put(md, new Integer(num));
-           continue methodit;
+            continue methodit;
           }
         }
       }