changes + annotation generation
[IRC.git] / Robust / src / IR / MethodDescriptor.java
index cda2616d738b4472993ad9af8eb1100e4ec74a7d..d8e2ea0d739f583aa5e578eb48f2b7137a149151 100644 (file)
@@ -22,6 +22,11 @@ public class MethodDescriptor extends Descriptor {
   protected boolean isstaticblock;  // flag to indicate if this is a static block
   protected boolean isinvokedbystatic;  // flag to indicate if this method is invoked by some static block
 
+  protected boolean isdefaultconstructor; // flag to indicate if this is a default constructor
+  
+  private int lineNum;
+
+
   public MethodDescriptor(Modifiers m, TypeDescriptor rt, String identifier) {
     super(identifier);
     this.modifier=m;
@@ -33,6 +38,8 @@ public class MethodDescriptor extends Descriptor {
     paramtable=new SymbolTable();
     thisvd=null;
     isstaticblock = false;
+    this.isinvokedbystatic = false;
+    this.isdefaultconstructor = false;
   }
 
   public Modifiers getModifiers() {
@@ -48,10 +55,10 @@ public class MethodDescriptor extends Descriptor {
     for(int i=0; i<numParameters(); i++) {
       Descriptor d1=getParameter(i);
       Descriptor d2=md.getParameter(i);
-      TypeDescriptor td1=(d1 instanceof TagVarDescriptor) ? ((TagVarDescriptor)d1).getType() : ((VarDescriptor)d1).getType();
-      TypeDescriptor td2=(d2 instanceof TagVarDescriptor) ? ((TagVarDescriptor)d2).getType() : ((VarDescriptor)d2).getType();
+      TypeDescriptor td1=(d1 instanceof TagVarDescriptor)?((TagVarDescriptor)d1).getType():((VarDescriptor)d1).getType();
+      TypeDescriptor td2=(d2 instanceof TagVarDescriptor)?((TagVarDescriptor)d2).getType():((VarDescriptor)d2).getType();
       if (!td1.equals(td2))
-       return false;
+        return false;
     }
     return true;
   }
@@ -78,19 +85,19 @@ public class MethodDescriptor extends Descriptor {
   public boolean isGlobal() {
     return isglobal;
   }
-  
+
   public boolean isStaticBlock() {
     return isstaticblock;
   }
-  
+
   public void setAsStaticBlock() {
     isstaticblock = true;
   }
-  
+
   public boolean isInvokedByStatic() {
     return this.isinvokedbystatic;
   }
-  
+
   public void setIsInvokedByStatic(boolean isinvokedbystatic) {
     this.isinvokedbystatic = isinvokedbystatic;
   }
@@ -113,7 +120,7 @@ public class MethodDescriptor extends Descriptor {
     for(int i=0; i<numParameters(); i++) {
       st+=getParamType(i).getSafeDescriptor();
       if ((i+1)<numParameters())
-       st+="_";
+        st+="_";
     }
     return st;
   }
@@ -122,8 +129,12 @@ public class MethodDescriptor extends Descriptor {
     return modifier.isStatic();
   }
 
+  public boolean isAbstract() {
+    return modifier.isAbstract();
+  }
+
   public boolean isConstructor() {
-    return (returntype==null);
+    return (returntype==null) && !isstaticblock;
   }
 
   public TypeDescriptor getReturnType() {
@@ -187,6 +198,10 @@ public class MethodDescriptor extends Descriptor {
     else throw new Error();
   }
 
+  public String getSafeSymbol() {
+    return safename.replace(".","___________").replace("$","___DOLLAR___");
+  }
+
   public String toString() {
     String st="";
     String type="";
@@ -199,9 +214,42 @@ public class MethodDescriptor extends Descriptor {
     for(int i=0; i<params.size(); i++) {
       st+=getParamType(i)+" "+getParamName(i);
       if ((i+1)!=params.size())
-       st+=", ";
+        st+=", ";
     }
     st+=")";
     return st;
   }
+
+  public boolean isDefaultConstructor() {
+    return this.isdefaultconstructor;
+  }
+
+  public void setDefaultConstructor() {
+    this.isdefaultconstructor = true;
+  }
+  
+  public String getMethodDeclaration(){
+    String st="";
+    String type="";
+      if (returntype != null)
+        st = modifier.toString() + returntype.toString() + " " + type + identifier + "(";
+      else
+        st = modifier.toString() + identifier + "(";
+      for (int i = 0; i < params.size(); i++) {
+        st += getParamType(i) + " " + getParamName(i);
+        if ((i + 1) != params.size())
+          st += ", ";
+      }
+      st += ")";
+      return st;
+  }
+  
+  public void setLineNum(int n){
+    lineNum=n;
+  }
+  public int getLineNum(){
+    return lineNum;
+  }
+  
 }