add support for super calls...ie...super.foo()
authorbdemsky <bdemsky>
Sat, 26 Mar 2011 02:35:36 +0000 (02:35 +0000)
committerbdemsky <bdemsky>
Sat, 26 Mar 2011 02:35:36 +0000 (02:35 +0000)
Robust/src/Analysis/Pointer/Pointer.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildFlat.java
Robust/src/IR/Flat/FlatCall.java
Robust/src/IR/Tree/MethodInvokeNode.java
Robust/src/IR/Tree/SemanticCheck.java

index 3e30f2c44aa88b399c03950c1efc4e4b672fe3f5..8deb3b2252a7c0564d8d4896651f92a56f0cfb26 100644 (file)
@@ -655,7 +655,7 @@ public class Pointer implements HeapAnalysis{
     TempDescriptor tmpthis=fcall.getThis();
     MethodDescriptor md=fcall.getMethod();
     HashSet<MethodDescriptor> targets=new HashSet<MethodDescriptor>();
-    if (md.isStatic()) {
+    if (md.isStatic()||fcall.getSuper()) {
       targets.add(md);
     } else {
       //Compute Edges
@@ -714,6 +714,10 @@ public class Pointer implements HeapAnalysis{
            returnDelta=new Delta(null, false);
            Vector<FlatNode> exitblocknodes=block.getExit().nodes();
            FlatExit fexit=(FlatExit)exitblocknodes.get(exitblocknodes.size()-1);
+           if (graphMap.get(fexit)==null) {
+             System.out.println(fcall);
+             System.out.println(fm);
+           }
            buildInitDelta(graphMap.get(fexit), returnDelta);
            if (!returnDelta.heapedgeadd.isEmpty()||!returnDelta.heapedgeremove.isEmpty()||!returnDelta.varedgeadd.isEmpty()) {
              returnDelta.setBlock(new PPoint(callblock, callindex));
index 39ff5ba7c196f8c300a132fc73fa0c63a7b90de4..f6803b08ca0f47586c75ac05ac1e380dd5318f62 100644 (file)
@@ -2523,7 +2523,7 @@ public class BuildCode {
       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)) {
+    if (md.isStatic()||md.getReturnType()==null||singleCall(fc.getThis().getType().getClassDesc(),md)||fc.getSuper()) {
       //no
       output.print(cn.getSafeSymbol()+md.getSafeSymbol()+"_"+mdstring);
     } else {
index 148f089a0b678b9fe10b54b34717e6b0c4be07ed..14987216e5fafdb17afda6269161b89317425fb1 100644 (file)
@@ -524,9 +524,9 @@ public class BuildFlat {
 
     FlatCall fc;
     if(md.getReturnType()==null||md.getReturnType().isVoid())
-      fc=new FlatCall(md, null, thisarg, temps);      
+      fc=new FlatCall(md, null, thisarg, temps, min.getSuper());
     else
-      fc=new FlatCall(md, out_temp, thisarg, temps);
+      fc=new FlatCall(md, out_temp, thisarg, temps, min.getSuper());
     
     fc.setNumLine(min.getNumLine());
     
index f2ca858ea6a2a932961a991cde20a1d486f51e29..be50e3609722c6ae94727b660ee0016c9be29ee6 100644 (file)
@@ -6,12 +6,18 @@ public class FlatCall extends FlatNode {
   TempDescriptor this_temp;
   TempDescriptor dst;
   MethodDescriptor method;
+  boolean isSuper;
 
   public FlatCall(MethodDescriptor md, TempDescriptor dst, TempDescriptor this_temp, TempDescriptor[] args) {
+    this(md, dst, this_temp, args, false);
+  }
+
+  public FlatCall(MethodDescriptor md, TempDescriptor dst, TempDescriptor this_temp, TempDescriptor[] args, boolean isSuper) {
     this.method=md;
     this.dst=dst;
     this.this_temp=this_temp;
     this.args=args;
+    this.isSuper=isSuper;
   }
   public void rewriteUse(TempMap t) {
     for(int i=0;i<args.length;i++)
@@ -30,6 +36,9 @@ public class FlatCall extends FlatNode {
     
     return new FlatCall(method, ndst, nthis, nargs);
   }
+  public boolean getSuper() {
+    return isSuper;
+  }
 
   public MethodDescriptor getMethod() {
     return method;
index 8c9bcd79a185cc3a745738a3be36227322fd25e9..7fbe7f67a6ef0a4e4c595a98a62923a1a15b4e65 100644 (file)
@@ -10,6 +10,7 @@ public class MethodInvokeNode extends ExpressionNode {
   NameDescriptor basename;
   ExpressionNode en;
   MethodDescriptor md;
+  boolean isSuper;
 
   public MethodInvokeNode(NameDescriptor name) {
     methodid=name.getIdentifier();
@@ -19,6 +20,7 @@ public class MethodInvokeNode extends ExpressionNode {
     argumentlist=new Vector();
     en=null;
     md=null;
+    isSuper=false;
   }
 
   public MethodInvokeNode(String methodid, ExpressionNode exp) {
@@ -27,6 +29,15 @@ public class MethodInvokeNode extends ExpressionNode {
     argumentlist=new Vector();
     md=null;
     this.basename=null;
+    isSuper=false;
+  }
+
+  public void setSuper() {
+    isSuper=true;
+  }
+
+  public boolean getSuper() {
+    return isSuper;
   }
 
   public NameDescriptor getBaseName() {
index cc4e04636bdaf5f7d4275ac80af2a05a00ab40eb..9b68aa0bedd03c8b3c8324715d47f34686563dd8 100644 (file)
@@ -1155,6 +1155,7 @@ NextMethod:
       if (rootname.equals("super")) {
        ClassDescriptor supercd=((MethodDescriptor)md).getClassDesc().getSuperDesc();
        typetolookin=new TypeDescriptor(supercd);
+       min.setSuper();
       } else if (rootname.equals("this")) {
         if(isstatic) {
           throw new Error("use this object in static method md = "+ md.toString());