Improve the switch rewriting
- Split switch into ifs and/or switches (not just ifs and one switch)
- Ensure debug information is kept during rewriting
Saves ~7 KB on framework and ~64 KB on GMS Core V10.
Change-Id: I7d4f94ead500ee69ee3cd3d1a667804e9791f670
diff --git a/src/test/debugTestResources/Locals.java b/src/test/debugTestResources/Locals.java
index 890cb85..109c43e 100644
--- a/src/test/debugTestResources/Locals.java
+++ b/src/test/debugTestResources/Locals.java
@@ -262,6 +262,44 @@
return -1;
}
+ public static int switchRewriteToIfs(int x) {
+ {
+ int t = x + 1;
+ x = t;
+ x = x + x;
+ }
+ switch (x) {
+ case 0:
+ return 0;
+ case 100:
+ return 1;
+ }
+ return -1;
+ }
+
+ public static int switchRewriteToSwitches(int x) {
+ {
+ int t = x + 1;
+ x = t;
+ x = x + x;
+ }
+ switch (x) {
+ case 0:
+ return 0;
+ case 1:
+ return 0;
+ case 2:
+ return 0;
+ case 100:
+ return 1;
+ case 101:
+ return 1;
+ case 102:
+ return 1;
+ }
+ return -1;
+ }
+
public static void main(String[] args) {
noLocals();
unusedLocals();
@@ -278,5 +316,7 @@
tempInCase(42);
localSwap(1, 2);
argumentLiveAtReturn(-1);
+ switchRewriteToIfs(1);
+ switchRewriteToSwitches(1);
}
}