summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStiver <stiver.mail@gmail.com>2014-08-17 19:09:28 +0200
committerStiver <stiver.mail@gmail.com>2014-08-17 19:09:28 +0200
commite098fbf6693faf8dae6a9f102f57c32457a84275 (patch)
treeb0c68859d2ae6e50df37b9efea594a329f69ba99
parent929056d727dedc26c9ddcbb5d8a4a269a12d95e8 (diff)
downloadfernflower-e098fbf6693faf8dae6a9f102f57c32457a84275.tar
fernflower-e098fbf6693faf8dae6a9f102f57c32457a84275.tar.gz
fernflower-e098fbf6693faf8dae6a9f102f57c32457a84275.tar.lz
fernflower-e098fbf6693faf8dae6a9f102f57c32457a84275.tar.xz
fernflower-e098fbf6693faf8dae6a9f102f57c32457a84275.zip
Unified the types of 'case' values in a switch statement
-rw-r--r--src/de/fernflower/modules/decompiler/exps/SwitchExprent.java19
-rw-r--r--src/de/fernflower/modules/decompiler/stats/SwitchStatement.java8
2 files changed, 21 insertions, 6 deletions
diff --git a/src/de/fernflower/modules/decompiler/exps/SwitchExprent.java b/src/de/fernflower/modules/decompiler/exps/SwitchExprent.java
index 31b7af0..9516600 100644
--- a/src/de/fernflower/modules/decompiler/exps/SwitchExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/SwitchExprent.java
@@ -48,6 +48,10 @@ public class SwitchExprent extends Exprent {
return swexpr;
}
+ public VarType getExprType() {
+ return value.getExprType();
+ }
+
public CheckTypesResult checkExprTypeBounds() {
CheckTypesResult result = new CheckTypesResult();
@@ -81,12 +85,17 @@ public class SwitchExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o == this) return true;
- if(o == null || !(o instanceof SwitchExprent)) return false;
+ if(o == this) {
+ return true;
+ }
+
+ if(o == null || !(o instanceof SwitchExprent)) {
+ return false;
+ }
- SwitchExprent sw = (SwitchExprent)o;
- return InterpreterUtil.equalObjects(value, sw.getValue());
- }
+ SwitchExprent sw = (SwitchExprent) o;
+ return InterpreterUtil.equalObjects(value, sw.getValue());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == value) {
diff --git a/src/de/fernflower/modules/decompiler/stats/SwitchStatement.java b/src/de/fernflower/modules/decompiler/stats/SwitchStatement.java
index f3d2231..166a3dd 100644
--- a/src/de/fernflower/modules/decompiler/stats/SwitchStatement.java
+++ b/src/de/fernflower/modules/decompiler/stats/SwitchStatement.java
@@ -31,6 +31,7 @@ import de.fernflower.modules.decompiler.StatEdge;
import de.fernflower.modules.decompiler.exps.ConstExprent;
import de.fernflower.modules.decompiler.exps.Exprent;
import de.fernflower.modules.decompiler.exps.SwitchExprent;
+import de.fernflower.struct.gen.VarType;
import de.fernflower.util.InterpreterUtil;
public class SwitchStatement extends Statement {
@@ -126,6 +127,8 @@ public class SwitchStatement extends Statement {
buf.append(indstr+headexprent.get(0).toJava(indent)+" {" + new_line_separator);
+ VarType switch_type = headexprent.get(0).getExprType();
+
for(int i=0;i<caseStatements.size();i++) {
Statement stat = caseStatements.get(i);
@@ -136,7 +139,10 @@ public class SwitchStatement extends Statement {
if(edges.get(j) == default_edge) {
buf.append(indstr+"default:" + new_line_separator);
} else {
- buf.append(indstr+"case "+ values.get(j).toJava(indent)+":" + new_line_separator);
+ ConstExprent value = (ConstExprent)values.get(j).copy();
+ value.setConsttype(switch_type);
+
+ buf.append(indstr+"case "+ value.toJava(indent)+":" + new_line_separator);
}
}