fixed bug with wrong method being called in inheritance situations
authorbdemsky <bdemsky>
Sat, 4 Nov 2006 03:29:30 +0000 (03:29 +0000)
committerbdemsky <bdemsky>
Sat, 4 Nov 2006 03:29:30 +0000 (03:29 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/MethodDescriptor.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/IR/TypeUtil.java

index e3394adc5ff1e9e152c6defa3bb92885030bbd93..e33fc83c81b055f1cef92ace49e018aca3c5fbdd 100644 (file)
@@ -1027,6 +1027,8 @@ public class BuildCode {
 
        if (fc.getReturnTemp()!=null)
            output.print(generateTemp(fm,fc.getReturnTemp())+"=");
+
+       /* Do we need to do virtual dispatch? */
        if (md.isStatic()||md.getReturnType()==null||singleCall(fc.getThis().getType().getClassDesc(),md)) {
            output.print(cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor());
        } else {
index 115e30736a6df7558e5c4faabb292ce48902140d..979a4b6467e6fd835f15bf69f0a124d5563b4e24 100644 (file)
@@ -136,10 +136,13 @@ public class MethodDescriptor extends Descriptor {
 
     public String toString() {
        String st="";
+       String type="";
+       if (cd!=null)
+           type=cd+".";
        if (returntype!=null)
-           st=modifier.toString()+returntype.toString()+" "+identifier+"(";
+           st=modifier.toString()+returntype.toString()+" "+type+identifier+"(";
        else
-           st=modifier.toString()+" "+identifier+"(";
+           st=modifier.toString()+" "+type+identifier+"(";
        for(int i=0;i<params.size();i++) {
            st+=getParamType(i)+" "+getParamName(i);
            if ((i+1)!=params.size())
index 7509695717ceff69a2612fbcbe79f35ef108b3ff..7dcb5eb1f8b8917f96accd6f86a62e3892c6fdf7 100644 (file)
@@ -576,6 +576,10 @@ public class SemanticCheck {
        }
        if (!typeutil.isSuperorType(md2.getReturnType(), md1.getReturnType()))
                return false;
+
+       if (!typeutil.isSuperorType(md2.getClassDesc(), md1.getClassDesc()))
+               return false;
+
        return true;
     }
 
@@ -663,7 +667,6 @@ public class SemanticCheck {
                checkExpressionNode(md, nametable, min.getExpression(), null);
            }
        }
-
     }
 
 
index da25f219da1321803eabcfe91cf3f96302983ca5..9e09427e342f29694140e4d719ba6c9eb7cf2d9e 100644 (file)
@@ -150,8 +150,8 @@ public class TypeUtil {
            throw new Error();
     }
 
-
-    private boolean isSuperorType(ClassDescriptor possiblesuper, ClassDescriptor cd2) {
+    
+    public boolean isSuperorType(ClassDescriptor possiblesuper, ClassDescriptor cd2) {
        if (possiblesuper==cd2)
            return true;
        else