added staticFlag, equals

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@100 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 37d77aeb6e
commit 474c229d66
  1. 43
      jode/jode/type/MethodType.java

@ -24,11 +24,21 @@ package jode;
* @author Jochen Hoenicke * @author Jochen Hoenicke
*/ */
public class MethodType { public class MethodType {
Type[] argumentTypes; final Type[] parameterTypes;
Type returnType; final Type returnType;
Type elementType; final boolean staticFlag;
public MethodType(String signature) { public MethodType(boolean isStatic, Class[] argTypes, Class retType) {
this.staticFlag = isStatic;
parameterTypes = new Type[argTypes.length];
for (int i=0; i < argTypes.length; i++)
parameterTypes[i] = Type.tType(argTypes[i]);
returnType = Type.tType(retType);
}
public MethodType(boolean isStatic, String signature) {
this.staticFlag = isStatic;
int index = 1, types = 0; int index = 1, types = 0;
while (signature.charAt(index) != ')') { while (signature.charAt(index) != ')') {
types++; types++;
@ -38,7 +48,7 @@ public class MethodType {
index = signature.indexOf(';', index); index = signature.indexOf(';', index);
index++; index++;
} }
argumentTypes = new Type[types]; parameterTypes = new Type[types];
index = 1; index = 1;
types = 0; types = 0;
@ -49,17 +59,34 @@ public class MethodType {
if (signature.charAt(index) == 'L') if (signature.charAt(index) == 'L')
index = signature.indexOf(';', index); index = signature.indexOf(';', index);
index++; index++;
argumentTypes[types++] parameterTypes[types++]
= Type.tType(signature.substring(lastindex,index)); = Type.tType(signature.substring(lastindex,index));
} }
returnType = Type.tType(signature.substring(index+1)); returnType = Type.tType(signature.substring(index+1));
} }
public Type[] getArgumentTypes() { public boolean isStatic() {
return argumentTypes; return staticFlag;
}
public Type[] getParameterTypes() {
return parameterTypes;
} }
public Type getReturnType() { public Type getReturnType() {
return returnType; return returnType;
} }
public boolean equals(Object o) {
MethodType mt;
if (!(o instanceof InvokeOperator)
|| !returnType.equals((mt = (MethodType)o).returnType)
|| staticFlag != mt.staticFlag
|| parameterTypes.length != mt.parameterTypes.length)
return false;
for (int i=0; i<parameterTypes.length; i++)
if (!parameterTypes[i].equals(mt.parameterTypes))
return false;
return true;
}
} }

Loading…
Cancel
Save