Skip to content

Instantly share code, notes, and snippets.

@DarkDimius
Last active September 6, 2016 13:35
Show Gist options
  • Save DarkDimius/39e8cfe4b24150ca04bd2d622ac8beac to your computer and use it in GitHub Desktop.
Save DarkDimius/39e8cfe4b24150ca04bd2d622ac8beac to your computer and use it in GitHub Desktop.
case class CC(a: Int, b: Object)
object Lists{
def foo(x: Any): Int = {
val (a, b) = x match {
case CC(s @ 1, CC(t, _)) =>
(s , 2)
case _ => (42, 43)
}
a + b
}
def booleans(a: Object) = {
val (b1, b2) = (a.isInstanceOf[CC], a.isInstanceOf[List[Int]])
(b1, b2) match {
case (true, true) => true
case (false, false) => true
case _ => false
}
}
}
/*
* Unable to fully structure code
* Enabled aggressive block sorting
* Lifted jumps to return sites
*/
public int foo(Object x) {
var4_2 = x;
if (!(var4_2 instanceof CC)) ** GOTO lbl-1000
var5_3 = (CC)var4_2;
var6_4 = var5_3.a();
var7_5 = var5_3.b();
if (1 == var6_4 && var7_5 instanceof CC) {
var8_6 = new Tuple2.mcII.sp(1, 2);
} else lbl-1000: // 2 sources:
{
var8_6 = new Tuple2.mcII.sp(42, 43);
}
var3_7 = var8_6;
if (var3_7 == null) throw new MatchError((Object)var3_7);
a = var3_7._1$mcI$sp();
b = var3_7._2$mcI$sp();
var2_11 = var11_10 = new Tuple2.mcII.sp(a, b);
a = var2_11._1$mcI$sp();
b = var2_11._2$mcI$sp();
return a + b;
}
/*
* Enabled force condition propagation
* Lifted jumps to return sites
*/
public boolean booleans(Object a) {
boolean b2;
boolean b22;
Tuple2.mcZZ.sp sp2 = new Tuple2.mcZZ.sp(a instanceof CC, a instanceof List);
if (sp2 == null) throw new MatchError((Object)sp2);
boolean b1 = sp2._1$mcZ$sp();
Tuple2.mcZZ.sp sp3 = new Tuple2.mcZZ.sp(b1, b2 = sp2._2$mcZ$sp());
Tuple2.mcZZ.sp sp4 = sp3;
boolean b12 = sp4._1$mcZ$sp();
Tuple2.mcZZ.sp sp5 = new Tuple2.mcZZ.sp(b12, b22 = sp4._2$mcZ$sp());
if (sp5 != null) {
boolean bl = sp5._1$mcZ$sp();
boolean bl2 = sp5._2$mcZ$sp();
if (bl && bl2) {
return true;
}
}
if (sp5 == null) return false;
boolean bl = sp5._1$mcZ$sp();
boolean bl3 = sp5._2$mcZ$sp();
if (false != bl) return false;
if (false != bl3) return false;
return true;
}
public int foo(Object x) {
var3_2 = x;
if (!(var3_2 instanceof CC)) ** GOTO lbl-1000
var4_3 = (CC)var3_2;
var5_4 = CC$.MODULE$.unapply((CC)var3_2);
s = var5_4._1();
var7_6 = var5_4._2();
if (1 != s) ** GOTO lbl-1000
var8_7 = s;
if (var7_6 instanceof CC) {
var9_8 = (CC)var7_6;
var10_9 = CC$.MODULE$.unapply((CC)var7_6);
var11_10 = var10_9._2();
v0 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToInteger((int)1), (Object)BoxesRunTime.boxToInteger((int)2));
} else lbl-1000: // 3 sources:
{
v0 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToInteger((int)42), (Object)BoxesRunTime.boxToInteger((int)43));
}
var2_11 = v0;
a = BoxesRunTime.unboxToInt((Object)var2_11._1());
b = BoxesRunTime.unboxToInt((Object)var2_11._2());
return a + b;
}
/*
* Enabled force condition propagation
* Lifted jumps to return sites
*/
public boolean booleans(Object a) {
Tuple2 tuple2 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToBoolean((boolean)(a instanceof CC)), (Object)BoxesRunTime.boxToBoolean((boolean)(a instanceof List)));
boolean b1 = BoxesRunTime.unboxToBoolean((Object)tuple2._1());
boolean b2 = BoxesRunTime.unboxToBoolean((Object)tuple2._2());
Tuple2 tuple22 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToBoolean((boolean)b1), (Object)BoxesRunTime.boxToBoolean((boolean)b2));
Option option = Tuple2..MODULE$.unapply(tuple22);
if (option.isDefined()) {
Tuple2 tuple23 = (Tuple2)option.get();
boolean bl = BoxesRunTime.unboxToBoolean((Object)tuple23._1());
boolean bl2 = BoxesRunTime.unboxToBoolean((Object)tuple23._2());
if (bl) {
boolean bl3 = bl;
if (bl2) {
boolean bl4 = bl2;
return true;
}
}
}
Option option2 = Tuple2..MODULE$.unapply(tuple22);
if (!option2.isDefined()) return false;
Tuple2 tuple24 = (Tuple2)option2.get();
boolean bl = BoxesRunTime.unboxToBoolean((Object)tuple24._1());
boolean bl5 = BoxesRunTime.unboxToBoolean((Object)tuple24._2());
if (bl) return false;
boolean bl6 = bl;
if (bl5) return false;
boolean bl7 = bl5;
return true;
}
public int foo(Object x) {
CC cC;
int n = 0;
int n2 = 0;
if (x instanceof CC && 1 == (cC = (CC)x)._1() && cC._2() instanceof CC) {
n = 1;
n2 = 2;
} else {
n = 42;
n2 = 43;
}
return n + n2;
}
public boolean booleans(Object a) {
boolean bl = a instanceof CC;
boolean bl2 = a instanceof List;
if (bl && bl2 || !bl && !bl2) {
return true;
}
return false;
}
public int foo(java.lang.Object);
Code:
0: iconst_0
1: istore_2
2: iconst_0
3: istore_3
4: aload_1
5: instanceof #20 // class CC
8: ifeq 44
11: aload_1
12: checkcast #20 // class CC
15: astore 4
17: iconst_1
18: aload 4
20: invokevirtual #24 // Method CC._1:()I
23: if_icmpne 44
26: aload 4
28: invokevirtual #28 // Method CC._2:()Ljava/lang/Object;
31: instanceof #20 // class CC
34: ifeq 44
37: iconst_1
38: istore_2
39: iconst_2
40: istore_3
41: goto 50
44: bipush 42
46: istore_2
47: bipush 43
49: istore_3
50: iload_2
51: iload_3
52: iadd
53: ireturn
public boolean booleans(java.lang.Object);
Code:
0: aload_1
1: instanceof #20 // class CC
4: istore_2
5: aload_1
6: instanceof #34 // class scala/collection/immutable/List
9: istore_3
10: iload_2
11: ifeq 18
14: iload_3
15: ifne 26
18: iload_2
19: ifne 28
22: iload_3
23: ifne 28
26: iconst_1
27: ireturn
28: iconst_0
29: ireturn
/*
* Enabled force condition propagation
* Lifted jumps to return sites
*/
public int foo(Object x) {
void b;
int a;
if (x instanceof CC) {
CC cC = (CC)x;
int n = cC.a();
Object object = cC.b();
if (1 == n && object instanceof CC) {
return a + b;
}
}
int n = 43;
a = 42;
return a + b;
}
public boolean booleans(Object a) {
boolean bl = a instanceof List;
boolean bl2 = a instanceof CC;
boolean bl3 = true == bl2 && true == bl ? true : false == bl2 && false == bl;
return bl3;
}
public int foo(java.lang.Object);
Code:
0: aload_1
1: instanceof #17 // class CC
4: ifeq 45
7: aload_1
8: checkcast #17 // class CC
11: astore_2
12: aload_2
13: invokevirtual #21 // Method CC.a:()I
16: istore_3
17: aload_2
18: invokevirtual #25 // Method CC.b:()Ljava/lang/Object;
21: astore 4
23: iconst_1
24: iload_3
25: if_icmpne 45
28: aload 4
30: instanceof #17 // class CC
33: ifeq 45
36: iconst_1
37: iconst_2
38: istore 6
40: istore 5
42: goto 53
45: bipush 42
47: bipush 43
49: istore 6
51: istore 5
53: iload 5
55: iload 6
57: iadd
58: ireturn
public boolean booleans(java.lang.Object);
Code:
0: aload_1
1: instanceof #17 // class CC
4: aload_1
5: instanceof #32 // class scala/collection/immutable/List
8: istore 4
10: istore_3
11: iconst_1
12: iload_3
13: if_icmpne 27
16: iconst_1
17: iload 4
19: if_icmpne 27
22: iconst_1
23: istore_2
24: goto 45
27: iconst_0
28: iload_3
29: if_icmpne 43
32: iconst_0
33: iload 4
35: if_icmpne 43
38: iconst_1
39: istore_2
40: goto 45
43: iconst_0
44: istore_2
45: iload_2
46: ireturn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment