Search in sources :

Example 41 with SootClass

use of soot.SootClass in project robovm by robovm.

the class VTableTest method testA.

@Test
public void testA() {
    SootClass sc = getSootClass("org.robovm.compiler.a.A");
    VTable.Cache cache = new VTable.Cache();
    VTable vtable = cache.get(sc);
    assertEquals(14, vtable.size());
    Entry toStringEntry = vtable.findEntry("toString", "()Ljava/lang/String;");
    assertEquals(sc.getName(), toStringEntry.getDeclaringClass());
    Entry superToStringEntry = cache.get(getSootClass("java.lang.Object")).findEntry("toString", "()Ljava/lang/String;");
    assertEquals(superToStringEntry.getIndex(), toStringEntry.getIndex());
    assertNotSame(toStringEntry, superToStringEntry);
    Entry equalsEntry = vtable.findEntry("equals", "(Ljava/lang/Object;)Z");
    assertEquals(sc.getName(), equalsEntry.getDeclaringClass());
    Entry superEqualsEntry = cache.get(getSootClass("java.lang.Object")).findEntry("equals", "(Ljava/lang/Object;)Z");
    assertEquals(superEqualsEntry.getIndex(), equalsEntry.getIndex());
    assertNotSame(superEqualsEntry, equalsEntry);
    Entry cloneEntry = vtable.findEntry("clone", "()Ljava/lang/Object;");
    assertEquals("java.lang.Object", cloneEntry.getDeclaringClass());
    Entry superCloneEntry = cache.get(getSootClass("java.lang.Object")).findEntry("clone", "()Ljava/lang/Object;");
    assertSame(superCloneEntry, cloneEntry);
    assertNull(vtable.findEntry("foo", "()V"));
    Entry fooEntry = vtable.findEntry("org.robovm.compiler.a", "foo", "()V");
    assertEquals(sc.getName(), fooEntry.getDeclaringClass());
    assertEquals(11, fooEntry.getIndex());
}
Also used : Entry(org.robovm.compiler.VTable.Entry) SootClass(soot.SootClass) Test(org.junit.Test)

Example 42 with SootClass

use of soot.SootClass in project robovm by robovm.

the class AnnotationsTest method testCopyParameterAnnotationsTwiceMultipleSubsetWithShift.

@Test
public void testCopyParameterAnnotationsTwiceMultipleSubsetWithShift() {
    SootClass sc = toSootClass(getClass());
    SootMethod src = sc.getMethodByName("src8");
    SootMethod dest = sc.getMethodByName("dest8");
    copyParameterAnnotations(src, dest, 0, 2, 0, Visibility.Any);
    copyParameterAnnotations(src, dest, 2, 3, 1, Visibility.Any);
    assertEquals("void dest8(@A @B @C int, @B @C @D int, int, @C @D @E int)", toString(dest));
}
Also used : SootMethod(soot.SootMethod) SootClass(soot.SootClass) Test(org.junit.Test)

Example 43 with SootClass

use of soot.SootClass in project robovm by robovm.

the class AnnotationsTest method testCopyParameterAnnotationsSingleLastNoShift.

@Test
public void testCopyParameterAnnotationsSingleLastNoShift() {
    SootClass sc = toSootClass(getClass());
    SootMethod src = sc.getMethodByName("src5");
    SootMethod dest = sc.getMethodByName("dest5");
    copyParameterAnnotations(src, dest, 1, 2, 0, Visibility.Any);
    assertEquals("void dest5(int, @B int)", toString(dest));
}
Also used : SootMethod(soot.SootMethod) SootClass(soot.SootClass) Test(org.junit.Test)

Example 44 with SootClass

use of soot.SootClass in project robovm by robovm.

the class AnnotationsTest method testCopyParameterAnnotationsMultipleSubsetWithShift.

@Test
public void testCopyParameterAnnotationsMultipleSubsetWithShift() {
    SootClass sc = toSootClass(getClass());
    SootMethod src = sc.getMethodByName("src7");
    SootMethod dest = sc.getMethodByName("dest7");
    copyParameterAnnotations(src, dest, 0, 3, 1, Visibility.Any);
    assertEquals("void dest7(int, @A @B @C int, @B @C @D int, @C @D @E int)", toString(dest));
}
Also used : SootMethod(soot.SootMethod) SootClass(soot.SootClass) Test(org.junit.Test)

Example 45 with SootClass

use of soot.SootClass in project robovm by robovm.

the class AnnotationsTest method testCopyParameterAnnotationsSingleFirstNoShift.

@Test
public void testCopyParameterAnnotationsSingleFirstNoShift() {
    SootClass sc = toSootClass(getClass());
    SootMethod src = sc.getMethodByName("src4");
    SootMethod dest = sc.getMethodByName("dest4");
    copyParameterAnnotations(src, dest, 0, 1, 0, Visibility.Any);
    assertEquals("void dest4(@A int, int)", toString(dest));
}
Also used : SootMethod(soot.SootMethod) SootClass(soot.SootClass) Test(org.junit.Test)

Aggregations

SootClass (soot.SootClass)48 SootMethod (soot.SootMethod)30 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)9 PrimType (soot.PrimType)9 RefType (soot.RefType)8 SootField (soot.SootField)7 HashSet (java.util.HashSet)6 ConstantBitcast (org.robovm.compiler.llvm.ConstantBitcast)4 Global (org.robovm.compiler.llvm.Global)4 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)4 Type (org.robovm.compiler.llvm.Type)4 File (java.io.File)3 CompilerException (org.robovm.compiler.CompilerException)3 Entry (org.robovm.compiler.VTable.Entry)3 ArrayType (org.robovm.compiler.llvm.ArrayType)3 NullConstant (org.robovm.compiler.llvm.NullConstant)3 PointerType (org.robovm.compiler.llvm.PointerType)3 StructureConstant (org.robovm.compiler.llvm.StructureConstant)3 StructureConstantBuilder (org.robovm.compiler.llvm.StructureConstantBuilder)3