use of soot.SootClass in project robovm by robovm.
the class ObjCBlockPlugin method getBlockTargetMethod.
protected static SootMethod getBlockTargetMethod(SootMethod method, int paramIndex) {
soot.Type type = method.getParameterType(paramIndex);
if (!(type instanceof RefType)) {
throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type");
}
SootClass blockType = ((RefType) type).getSootClass();
if (!blockType.isInterface()) {
throw new CompilerException("@Block annotated parameter " + (paramIndex + 1) + " of method " + method + " must be of interface type");
}
List<SootMethod> allMethods = collectAbstractMethods(blockType);
if (allMethods.isEmpty()) {
throw new CompilerException("No abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method);
}
if (allMethods.size() > 1) {
throw new CompilerException("More than 1 abstract method found in interface " + blockType + " used in @Block annotated parameter " + (paramIndex + 1) + " of method " + method);
}
return allMethods.get(0);
}
use of soot.SootClass in project robovm by robovm.
the class SootClassType method getEnclosingMethod.
private SootMethodType getEnclosingMethod(boolean constructor) {
EnclosingMethodTag emTag = (EnclosingMethodTag) sootClass.getTag("EnclosingMethodTag");
if (emTag != null) {
String clsName = emTag.getEnclosingClass();
String name = emTag.getEnclosingMethod();
String desc = emTag.getEnclosingMethodSig();
if (clsName != null && name != null && desc != null) {
if ((constructor && name.equals("<init>")) || (!constructor && !name.equals("<init>") && !name.equals("<clinit>"))) {
SootClass cls = SootResolver.v().makeClassRef(clsName);
if (!cls.isPhantom()) {
for (SootMethod m : cls.getMethods()) {
String mDesc = org.robovm.compiler.Types.getDescriptor(m);
if (m.getName().equals(name) && desc.equals(mDesc)) {
return new SootMethodType(m);
}
}
}
}
}
}
return null;
}
use of soot.SootClass in project robovm by robovm.
the class AnnotationsTest method testCopyParameterAnnotationsNoParams.
@Test
public void testCopyParameterAnnotationsNoParams() {
SootClass sc = toSootClass(getClass());
SootMethod src = sc.getMethodByName("src1");
SootMethod dest = sc.getMethodByName("dest1");
copyParameterAnnotations(src, dest, 0, 0, 0, Visibility.Any);
assertEquals("void dest1()", toString(dest));
}
use of soot.SootClass in project robovm by robovm.
the class AnnotationsTest method testCopyParameterAnnotationsOnlyInvisibleNoShift.
@Test
public void testCopyParameterAnnotationsOnlyInvisibleNoShift() {
SootClass sc = toSootClass(getClass());
SootMethod src = sc.getMethodByName("src9");
SootMethod dest = sc.getMethodByName("dest9");
copyParameterAnnotations(src, dest, 0, 2, 0, Visibility.RuntimeVisible);
assertEquals("void dest9(int, @E int)", toString(dest));
}
use of soot.SootClass in project robovm by robovm.
the class AnnotationsTest method testCopyParameterAnnotationsSingleAllNoShift.
@Test
public void testCopyParameterAnnotationsSingleAllNoShift() {
SootClass sc = toSootClass(getClass());
SootMethod src = sc.getMethodByName("src3");
SootMethod dest = sc.getMethodByName("dest3");
copyParameterAnnotations(src, dest, 0, 2, 0, Visibility.Any);
assertEquals("void dest3(@A int, @B int)", toString(dest));
}
Aggregations