From e098fbf6693faf8dae6a9f102f57c32457a84275 Mon Sep 17 00:00:00 2001 From: Stiver Date: Sun, 17 Aug 2014 19:09:28 +0200 Subject: [PATCH] Unified the types of 'case' values in a switch statement --- .../decompiler/exps/SwitchExprent.java | 19 ++++++++++++++----- .../decompiler/stats/SwitchStatement.java | 8 +++++++- 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