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;
paramtable=new SymbolTable();
thisvd=null;
isstaticblock = false;
+ this.isinvokedbystatic = false;
+ this.isdefaultconstructor = false;
}
public Modifiers getModifiers() {
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;
}
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;
}
for(int i=0; i<numParameters(); i++) {
st+=getParamType(i).getSafeDescriptor();
if ((i+1)<numParameters())
- st+="_";
+ st+="_";
}
return st;
}
return modifier.isStatic();
}
+ public boolean isAbstract() {
+ return modifier.isAbstract();
+ }
+
public boolean isConstructor() {
- return (returntype==null);
+ return (returntype==null) && !isstaticblock;
}
public TypeDescriptor getReturnType() {
else throw new Error();
}
+ public String getSafeSymbol() {
+ return safename.replace(".","___________").replace("$","___DOLLAR___");
+ }
+
public String toString() {
String st="";
String type="";
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;
+ }
+
}