more development
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@858 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
5028ac9b85
commit
47cae95830
|
@ -10,7 +10,11 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.types.generics;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
|
||||
/**
|
||||
* Under construction.
|
||||
|
@ -97,5 +101,10 @@ public class ClassTypeSignature extends TypeSignature {
|
|||
public boolean isBaseType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IClass lookupClass(ClassHierarchy cha, ClassTypeSignature sig) {
|
||||
TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Application, sig.getRawName());
|
||||
return cha.lookupClass(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -166,6 +166,11 @@ public class FormalTypeParameter extends Signature {
|
|||
return interfaceBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param klass
|
||||
* @return the formal type parameters, or null if none
|
||||
* @throws InvalidClassFileException
|
||||
*/
|
||||
public static FormalTypeParameter[] getTypeParameters(IClass klass) throws InvalidClassFileException {
|
||||
if (klass instanceof ShrikeClass) {
|
||||
ShrikeClass sc = (ShrikeClass) klass;
|
||||
|
|
|
@ -39,9 +39,15 @@ public class MethodTypeSignature extends Signature {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null if no arguments
|
||||
*/
|
||||
public TypeSignature[] getArguments() {
|
||||
String typeSig = rawString().replaceAll(".*\\(","\\(").replaceAll("\\).*", "\\)");
|
||||
String[] args = TypeSignature.parseForTypeSignatures(typeSig);
|
||||
if (args == null) {
|
||||
return null;
|
||||
}
|
||||
TypeSignature[] result = new TypeSignature[args.length];
|
||||
for (int i = 0; i<args.length; i++) {
|
||||
result[i] = TypeSignature.make(args[i]);
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.types.generics;
|
||||
|
||||
import com.ibm.wala.classLoader.ShrikeClass;
|
||||
import com.ibm.wala.shrikeCT.InvalidClassFileException;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
/**
|
||||
* TypeVariableSignature: T identifier ;
|
||||
*
|
||||
|
@ -55,4 +59,32 @@ public class TypeVariableSignature extends TypeSignature {
|
|||
public boolean isBaseType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param v
|
||||
* @param klass
|
||||
* @return -1 if there is no match
|
||||
*/
|
||||
public static int getTypeVariablePosition(TypeVariableSignature v, ShrikeClass klass) {
|
||||
try {
|
||||
ClassSignature sig = klass.getClassSignature();
|
||||
if (sig == null) {
|
||||
return -1;
|
||||
}
|
||||
FormalTypeParameter[] fp = sig.getFormalTypeParameters();
|
||||
for (int i = 0; i < fp.length; i++) {
|
||||
FormalTypeParameter f = fp[i];
|
||||
if (f.getIdentifier().equals(v.getIdentifier())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
Assertions.UNREACHABLE();
|
||||
return -1;
|
||||
} catch (InvalidClassFileException e) {
|
||||
e.printStackTrace();
|
||||
Assertions.UNREACHABLE();
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue