Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public boolean isLanguage(StructClass cl) {
StructAnnotationAttribute attr = cl.getAttribute((Key<StructAnnotationAttribute>) key);
for (AnnotationExprent anno : attr.getAnnotations()) {
if (anno.getClassName().equals("kotlin/Metadata")) {
setContextVariables(cl);
// Line removed as it slows down decompilation significantly, and it doesn't seem to break anything
//TODO double-check if it breaks anything
// setContextVariables(cl);
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public KotlinWriter() {
javadocProvider = (IFabricJavadocProvider) DecompilerContext.getProperty(IFabricJavadocProvider.PROPERTY_NAME);
}

@Override
public boolean endsWithSemicolon(Exprent expr) {
return false;
}

private boolean invokeProcessors(TextBuffer buffer, ClassNode node) {
ClassWrapper wrapper = node.getWrapper();
if (wrapper == null) {
Expand Down
6 changes: 3 additions & 3 deletions plugins/kotlin/testData/results/pkg/TestAnyType.dec
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package pkg
public class TestAnyType {
public fun test(param: Any): Int {
if (param is java.lang.String) {// 5
return (param as java.lang.String).length();// 6
return (param as java.lang.String).length()// 6
} else {
System.out.println(param);// 9
return 0;// 11
System.out.println(param)// 9
return 0// 11
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions plugins/kotlin/testData/results/pkg/TestBitwiseFunctions.dec
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ package pkg

public class TestBitwiseFunctions {
public fun and(a: Int, b: Int): Int {
return a and b;// 5
return a and b// 5
}

public fun or(a: Int, b: Int): Int {
return a or b;// 9
return a or b// 9
}

public fun xor(a: Int, b: Int): Int {
return a xor b;// 13
return a xor b// 13
}

public fun shl(a: Int, b: Int): Int {
return a shl b;// 17
return a shl b// 17
}

public fun shr(a: Int, b: Int): Int {
return a shr b;// 21
return a shr b// 21
}

public fun ushr(a: Int, b: Int): Int {
return a ushr b;// 25
return a ushr b// 25
}
}

Expand Down
20 changes: 10 additions & 10 deletions plugins/kotlin/testData/results/pkg/TestClassDec.dec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package pkg

public class TestClassDec {
public fun pkg.TestClassDec.Vec2iVal.dot(v: pkg.TestClassDec.Vec2iVal): Int {
return `$this$dot`.getX() * v.getX() + `$this$dot`.getY() * v.getY();// 11
return `$this$dot`.getX() * v.getX() + `$this$dot`.getY() * v.getY()// 11
}

public fun test() {
new TestClassDec.EmptyDec();
val vec: TestClassDec.Vec2iVal = new TestClassDec.Vec2iVal(1, 2);// 16
val vec1: TestClassDec.Vec2iVal = new TestClassDec.Vec2iVal(2, 4);// 17
System.out.println(vec.getX());// 19
System.out.println(this.dot(vec, vec1));// 20
new TestClassDec.EmptyDec()
val vec: TestClassDec.Vec2iVal = new TestClassDec.Vec2iVal(1, 2)// 16
val vec1: TestClassDec.Vec2iVal = new TestClassDec.Vec2iVal(2, 4)// 17
System.out.println(vec.getX())// 19
System.out.println(this.dot(vec, vec1))// 20
}// 21

public class EmptyDec
Expand All @@ -22,8 +22,8 @@ public class TestClassDec {
public final val y: Int

init {
this.x = x;// 7
this.y = y;
this.x = x// 7
this.y = y
}
}

Expand All @@ -35,8 +35,8 @@ public class TestClassDec {
internal set

init {
this.x = x;// 6
this.y = y;
this.x = x// 6
this.y = y
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ public class TestClassicStringInterpolation {
public final val x: Int = 5// 16

public fun stringInterpolation(x: Int, y: String) {
System.out.println("$x $y");// 5
System.out.println("$x $y")// 5
}// 6

public fun testConstant(x: Int) {
System.out.println("$x 5");// 9
System.out.println("$x 5")// 9
}// 10

public fun testExpression(x: Int) {
System.out.println("$x ${x + 1}");// 13
System.out.println("$x ${x + 1}")// 13
}// 14

public fun testProperty() {
System.out.println("${this.x}!");// 18
System.out.println("${this.x}!")// 18
}// 19

public fun testLiteralClass() {
System.out.println("${TestClassicStringInterpolation::class.java}!");// 22
System.out.println("${TestClassicStringInterpolation::class.java}!")// 22
}// 23
}

Expand Down
10 changes: 5 additions & 5 deletions plugins/kotlin/testData/results/pkg/TestCompanionObject.dec
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package pkg

public class TestCompanionObject {
public fun notInCompanion() {
System.out.println("notInCompanion");// 5
System.out.println("notInCompanion")// 5
}// 6

@JvmStatic
@JvmSynthetic
fun `access$getCompanionVal$cp`(): java.lang.String {
return companionVal;
return companionVal
}

@JvmStatic
@JvmSynthetic
fun `access$getCompanionValJvmStatic$cp`(): java.lang.String {
return companionValJvmStatic;// 3
return companionValJvmStatic// 3
}

public companion object {
Expand All @@ -24,11 +24,11 @@ public class TestCompanionObject {
public final val companionValJvmStatic: String

public fun inCompanion() {
System.out.println("inCompanion");// 15
System.out.println("inCompanion")// 15
}// 16

public fun inCompanionJvmStatic() {
System.out.println("inCompanionJvmStatic");// 20
System.out.println("inCompanionJvmStatic")// 20
}// 21
}
}
Expand Down
12 changes: 6 additions & 6 deletions plugins/kotlin/testData/results/pkg/TestComparison.dec
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ package pkg

public class TestComparison {
public fun test2(a: Any, b: Any): Boolean {
return a == b;// 5
return a == b// 5
}

public fun test3(a: Any, b: Any): Boolean {
return a === b;// 9
return a === b// 9
}

public fun testNull2(a: Any?): Boolean {
return a == null;// 13
return a == null// 13
}

public fun testNull3(a: Any?): Boolean {
return a == null;// 17
return a == null// 17
}

public fun testNullDouble2(a: Any?, b: Any?): Boolean {
return a == b;// 21
return a == b// 21
}

public fun testNullDouble3(a: Any?, b: Any?): Boolean {
return a === b;// 25
return a === b// 25
}
}

Expand Down
8 changes: 4 additions & 4 deletions plugins/kotlin/testData/results/pkg/TestCompileTimeErrors.dec
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ package pkg

public class TestCompileTimeErrors {
public fun <I, O> test(i: I): O where O : I, O : pkg.TestCompileTimeErrors.Test {
throw new NotImplementedError(null, 1, null);// 10
throw new NotImplementedError(null, 1, null)// 10
}

public fun test2(i: Int?): pkg.TestCompileTimeErrors.Test? {
return if (i == null) null else new TestCompileTimeErrors.Test(i) {
private final Integer testValue;

{
this.testValue = `$i`;// 16
this.testValue = `$i`// 16
}// 14

public Integer getTestValue() {
return this.testValue;// 15
return this.testValue// 15
}

/** @deprecated */
// $VF: synthetic method
public static void getTestValue$annotations() {
}
};
}
}

public interface Test {
Expand Down
4 changes: 2 additions & 2 deletions plugins/kotlin/testData/results/pkg/TestConstructors.dec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package pkg

public class TestConstructors private constructor() {
public constructor(a: Int) : this() {// 4
System.out.println("a = $a");// 5
System.out.println("a = $a")// 5
}// 6

public constructor(a: Int, b: Int) : this(a) {// 8
System.out.println("b = $b");// 9
System.out.println("b = $b")// 9
}// 10
}

Expand Down
26 changes: 13 additions & 13 deletions plugins/kotlin/testData/results/pkg/TestContracts.dec
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class TestContracts {
}

if (x == null) {// 13
throw new IllegalStateException("x is null".toString());
throw new IllegalStateException("x is null".toString())
} else {
return x;// 14
return x// 14
}
}

Expand All @@ -24,7 +24,7 @@ public class TestContracts {
returns(false) implies ((a && !b || (!a && b)
}

return if (a && b) null else a || b;// 24
return if (a && b) null else a || b// 24
}

public fun testTypeContract(x: Any?): Int {
Expand All @@ -33,9 +33,9 @@ public class TestContracts {
}

if (x !is Int) {// 31
throw new IllegalStateException("x is not Int".toString());
throw new IllegalStateException("x is not Int".toString())
} else {
return (x as java.lang.Number).intValue();// 32
return (x as java.lang.Number).intValue()// 32
}
}

Expand All @@ -44,32 +44,32 @@ public class TestContracts {
callsInPlace(f, InvocationKind.EXACTLY_ONCE)
}

return (f.invoke() as java.lang.Number).intValue();// 39
return (f.invoke() as java.lang.Number).intValue()// 39
}

public fun testFunctionalContract2(f: () -> Int, b: Boolean): Int {
contract {
callsInPlace(f, InvocationKind.AT_MOST_ONCE)
}

return if (b) (f.invoke() as java.lang.Number).intValue() else 0;// 46
return if (b) (f.invoke() as java.lang.Number).intValue() else 0// 46
}

public fun testFunctionalContract3(f: () -> Int, i: Int): Int {
contract {
callsInPlace(f)
}

val var3: java.lang.Iterable = (new IntRange(0, i)) as java.lang.Iterable;
var var4: Int = 0;
val var5: java.util.Iterator = var3.iterator();
val var3: java.lang.Iterable = (new IntRange(0, i)) as java.lang.Iterable
var var4: Int = 0
val var5: java.util.Iterator = var3.iterator()

while (var5.hasNext()) {
val var6: Int = (var5 as IntIterator).nextInt();
var4 += (f.invoke() as java.lang.Number).intValue();
val var6: Int = (var5 as IntIterator).nextInt()
var4 += (f.invoke() as java.lang.Number).intValue()
}

return var4;// 53
return var4// 53
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class TestConvertedK2JOps {
public final val any: Any = new Object()

public fun codeConstructs() {
System.out.println("Hello, world!");// 10
System.out.println("Hello, world!")// 10
}// 12
}

Expand Down
Loading