Enable interface for mgc version.
[IRC.git] / Robust / src / IR / Virtual.java
index aea9ac7f14053f896a61b9420740e7e0f96688c1..907ce865c8e4ac7a29a5f18c23cf587fcb09bc3a 100644 (file)
@@ -97,6 +97,15 @@ public class Virtual {
     int start=0;
     if (superdesc!=null)
       start=numberMethods(superdesc);
+    if(state.MGC) {
+      // TODO add version for normal Java later
+      // check the inherited interfaces
+      Iterator it_sifs = cd.getSuperInterfaces();
+      while(it_sifs.hasNext()) {
+        ClassDescriptor superif = (ClassDescriptor)it_sifs.next();
+        start += numberMethods(superif); // TODO Can there be duplicated methods from multiple ancestors?
+      }
+    }
     for(Iterator it=cd.getMethods(); it.hasNext();) {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
@@ -113,6 +122,26 @@ public class Virtual {
            break;
          }
        }
+    if(state.MGC) {
+      // TODO add version for normal Java later
+      if(!foundmatch) {
+        // check if there is a matched method in inherited interfaces
+        Iterator it_sifs = cd.getSuperInterfaces();
+        while(it_sifs.hasNext() && !foundmatch) {
+          ClassDescriptor superif = (ClassDescriptor)it_sifs.next();
+          Set possiblematches_if=superif.getMethodTable().getSet(md.getSymbol());
+          for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext();) {
+            MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+            if (md.matches(matchmd)) {
+              int num=((Integer)methodnumber.get(matchmd)).intValue();
+              methodnumber.put(md, new Integer(num));
+              foundmatch=true;
+              break;
+            }
+          }
+        }
+      }
+    }
        if (!foundmatch)
          methodnumber.put(md, new Integer(start++));
       } else {