use of soot.SootClass in project robovm by robovm.
the class MarshalerLookup method findMarshalersOnOuterClasses.
private void findMarshalersOnOuterClasses(SootClass sc, List<Marshaler> result, Set<String> visited, Set<String> seen) {
SootClass outer = getOuterClass(sc);
if (outer != null) {
findMarshalersOnClasses(outer, result, visited, seen);
findMarshalersOnInterfaces(outer, result, visited, seen);
findMarshalersOnOuterClasses(outer, result, visited, seen);
}
}
use of soot.SootClass in project robovm by robovm.
the class ObjCMemberPlugin method findOverriddenMethods.
private List<SootMethod> findOverriddenMethods(SootClass sootClass, SootMethod method) {
SootClass supercls = sootClass.getSuperclass();
while (!supercls.getType().equals(org_robovm_objc_ObjCObject.getType())) {
try {
SootMethod m = supercls.getMethod(method.getName(), method.getParameterTypes(), method.getReturnType());
if (overrides(method, m) && !hasAnnotation(m, NOT_IMPLEMENTED)) {
return Collections.singletonList(m);
}
} catch (RuntimeException e) {
// Soot throws RuntimeException if method not found
}
supercls = supercls.getSuperclass();
}
/*
* Method doesn't override any method in superclasses. Check interfaces
* as well. There may be several methods in interfaces which this method
* overrides. We have to return all of them as we cannot assume that
* first one found has the @Method or @Property annotation.
*/
List<SootMethod> candidates = new ArrayList<>();
findOverriddenMethodsOnInterfaces(sootClass, method, candidates);
return candidates;
}
use of soot.SootClass in project robovm by robovm.
the class TypeEncoder method getStructMembers.
private List<Member> getStructMembers(SootClass clazz, boolean is64bit) {
List<Member> members = new ArrayList<>();
if (clazz.hasSuperclass()) {
SootClass superclass = clazz.getSuperclass();
if (!superclass.getName().equals("org.robovm.rt.bro.Struct")) {
members.addAll(getStructMembers(clazz, is64bit));
}
}
for (SootMethod method : clazz.getMethods()) {
int offset = getStructMemberOffset(method);
if (offset != -1) {
if (!method.isNative() && !method.isStatic()) {
// thrown by the ClassCompiler later on.
continue;
}
Type type;
int idx;
if (method.getParameterCount() == 0) {
type = method.getReturnType();
idx = -1;
} else if (method.getParameterCount() == 1) {
type = method.getParameterType(0);
idx = 0;
} else {
// throw by the ClassCompiler later on.
continue;
}
Member member = new Member();
member.offset = offset;
member.type = encodeOne(method, type, idx, is64bit);
members.add(member);
}
}
return members;
}
use of soot.SootClass in project robovm by robovm.
the class VTableTest method testB.
@Test
public void testB() {
SootClass scJLO = getSootClass("java.lang.Object");
SootClass scA = getSootClass("org.robovm.compiler.a.A");
SootClass scB = getSootClass("org.robovm.compiler.b.B");
VTable.Cache cache = new VTable.Cache();
VTable vtableJLO = cache.get(scJLO);
VTable vtableA = cache.get(scA);
VTable vtableB = cache.get(scB);
assertEquals(16, vtableB.size());
Entry toStringEntry = vtableB.findEntry("toString", "()Ljava/lang/String;");
assertEquals(scA.getName(), toStringEntry.getDeclaringClass());
Entry superToStringEntry = vtableA.findEntry("toString", "()Ljava/lang/String;");
assertSame(toStringEntry, superToStringEntry);
Entry equalsEntry = vtableB.findEntry("equals", "(Ljava/lang/Object;)Z");
assertEquals(scA.getName(), equalsEntry.getDeclaringClass());
Entry superEqualsEntry = vtableA.findEntry("equals", "(Ljava/lang/Object;)Z");
assertSame(superEqualsEntry, equalsEntry);
Entry cloneEntry = vtableB.findEntry("clone", "()Ljava/lang/Object;");
assertEquals(scJLO.getName(), cloneEntry.getDeclaringClass());
Entry superCloneEntry = vtableJLO.findEntry("clone", "()Ljava/lang/Object;");
assertSame(superCloneEntry, cloneEntry);
Entry fooInAEntry = vtableB.findEntry("org.robovm.compiler.a", "foo", "()V");
assertEquals(scA.getName(), fooInAEntry.getDeclaringClass());
assertEquals(11, fooInAEntry.getIndex());
Entry fooInBEntry = vtableB.findEntry("org.robovm.compiler.b", "foo", "()V");
assertEquals(scB.getName(), fooInBEntry.getDeclaringClass());
assertEquals(14, fooInBEntry.getIndex());
assertNotSame(fooInAEntry, fooInBEntry);
Entry fooIVEntry = vtableB.findEntry("foo", "(I)V");
assertEquals(scB.getName(), fooIVEntry.getDeclaringClass());
Entry superFooIVEntry = vtableA.findEntry("foo", "(I)V");
assertEquals(superFooIVEntry.getIndex(), fooIVEntry.getIndex());
assertNotSame(superFooIVEntry, fooIVEntry);
Entry barInAEntry = vtableB.findEntry("org.robovm.compiler.a", "bar", "()V");
assertEquals(scA.getName(), barInAEntry.getDeclaringClass());
assertEquals(12, barInAEntry.getIndex());
Entry barInBEntry = vtableB.findEntry("org.robovm.compiler.b", "bar", "()V");
assertEquals(scB.getName(), barInBEntry.getDeclaringClass());
assertEquals(15, barInBEntry.getIndex());
assertNotSame(barInAEntry, barInBEntry);
}
use of soot.SootClass in project robovm by robovm.
the class VTableTest method testD.
@Test
public void testD() {
SootClass scA = getSootClass("org.robovm.compiler.a.A");
SootClass scB = getSootClass("org.robovm.compiler.b.B");
SootClass scD = getSootClass("org.robovm.compiler.b.D");
VTable.Cache cache = new VTable.Cache();
VTable vtableB = cache.get(scB);
VTable vtableD = cache.get(scD);
assertEquals(vtableB.size(), vtableD.size());
Entry barInAEntry = vtableD.findEntry("org.robovm.compiler.a", "bar", "()V");
assertEquals(scA.getName(), barInAEntry.getDeclaringClass());
assertEquals(12, barInAEntry.getIndex());
Entry barInDEntry = vtableD.findEntry("org.robovm.compiler.b", "bar", "()V");
assertEquals(scD.getName(), barInDEntry.getDeclaringClass());
assertEquals(15, barInDEntry.getIndex());
assertNotSame(barInAEntry, barInDEntry);
Entry barInBEntry = vtableD.findEntry("org.robovm.compiler.b", "bar", "()V");
assertSame(barInBEntry, barInDEntry);
}
Aggregations