summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dist/docs/readme.txt1
-rw-r--r--src/de/fernflower/main/DecompilerContext.java2
-rw-r--r--src/de/fernflower/main/extern/IFernflowerPreferences.java3
-rw-r--r--src/de/fernflower/modules/decompiler/exps/ConstExprent.java39
4 files changed, 36 insertions, 9 deletions
diff --git a/dist/docs/readme.txt b/dist/docs/readme.txt
index e51a5de..b37c779 100644
--- a/dist/docs/readme.txt
+++ b/dist/docs/readme.txt
@@ -51,6 +51,7 @@ occ (0): ouput copyright comment
ner (1): assume return not throwing exceptions
den (1): decompile enumerations
rgn (1): remove getClass() invocation, when it is part of a qualified new statement
+lit (0): output numeric and character literals "as-is"
bto (1): interpret int 1 as boolean true (workaround to a compiler bug)
nns (1): allow for not set synthetic attribute (workaround to a compiler bug)
uto (1): consider nameless types as java.lang.Object (workaround to a compiler architecture flaw)
diff --git a/src/de/fernflower/main/DecompilerContext.java b/src/de/fernflower/main/DecompilerContext.java
index 99001a0..213898a 100644
--- a/src/de/fernflower/main/DecompilerContext.java
+++ b/src/de/fernflower/main/DecompilerContext.java
@@ -76,7 +76,7 @@ public class DecompilerContext {
mapDefault.put(IFernflowerPreferences.DECOMPILE_ENUM, "1");
mapDefault.put(IFernflowerPreferences.FINALLY_DEINLINE, "1");
mapDefault.put(IFernflowerPreferences.REMOVE_GETCLASS_NEW, "1");
-
+ mapDefault.put(IFernflowerPreferences.LITERALS_AS_IS, "0");
mapDefault.put(IFernflowerPreferences.BOOLEAN_TRUE_ONE, "1");
mapDefault.put(IFernflowerPreferences.SYNTHETIC_NOT_SET, "1");
mapDefault.put(IFernflowerPreferences.UNDEFINED_PARAM_TYPE_OBJECT, "1");
diff --git a/src/de/fernflower/main/extern/IFernflowerPreferences.java b/src/de/fernflower/main/extern/IFernflowerPreferences.java
index 35b17de..5037107 100644
--- a/src/de/fernflower/main/extern/IFernflowerPreferences.java
+++ b/src/de/fernflower/main/extern/IFernflowerPreferences.java
@@ -28,7 +28,8 @@ public interface IFernflowerPreferences {
public static final String NO_EXCEPTIONS_RETURN = "ner";
public static final String DECOMPILE_ENUM = "den";
public static final String REMOVE_GETCLASS_NEW = "rgn";
- public static final String BOOLEAN_TRUE_ONE = "bto";
+ public static final String LITERALS_AS_IS = "bto";
+ public static final String BOOLEAN_TRUE_ONE = "bto";
public static final String SYNTHETIC_NOT_SET = "nns";
public static final String UNDEFINED_PARAM_TYPE_OBJECT = "uto";
public static final String USE_DEBUG_VARNAMES = "udv";
diff --git a/src/de/fernflower/modules/decompiler/exps/ConstExprent.java b/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
index 2187c49..26d7355 100644
--- a/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
@@ -101,7 +101,8 @@ public class ConstExprent extends Exprent {
}
public String toJava(int indent) {
-
+ boolean literal = DecompilerContext.getOption(IFernflowerPreferences.LITERALS_AS_IS);
+
if(consttype.type != CodeConstants.TYPE_NULL && value == null) {
return ExprProcessor.getCastTypeName(consttype);
} else {
@@ -112,7 +113,7 @@ public class ConstExprent extends Exprent {
Integer val = (Integer)value;
String ret = escapes.get(val);
if(ret == null) {
- if(val.intValue() >= 32 && val.intValue() < 127) {
+ if(literal || val.intValue() >= 32 && val.intValue() < 127) {
ret = String.valueOf((char)val.intValue());
} else {
ret = InterpreterUtil.charToUnicodeLiteral(val);
@@ -126,8 +127,10 @@ public class ConstExprent extends Exprent {
case CodeConstants.TYPE_INT:
int ival = ((Integer)value).intValue();
- String intfield;
- if(ival == Integer.MAX_VALUE) {
+ String intfield;
+ if(literal) {
+ return value.toString();
+ } else if(ival == Integer.MAX_VALUE) {
intfield = "MAX_VALUE";
} else if(ival == Integer.MIN_VALUE) {
intfield = "MIN_VALUE";
@@ -139,7 +142,9 @@ public class ConstExprent extends Exprent {
long lval = ((Long)value).longValue();
String longfield;
- if(lval == Long.MAX_VALUE) {
+ if(literal) {
+ return value.toString()+"L";
+ } else if(lval == Long.MAX_VALUE) {
longfield = "MAX_VALUE";
} else if(lval == Long.MIN_VALUE) {
longfield = "MIN_VALUE";
@@ -151,7 +156,17 @@ public class ConstExprent extends Exprent {
double dval = ((Double)value).doubleValue();
String doublefield;
- if(Double.isNaN(dval)) {
+ if(literal) {
+ if(Double.isNaN(dval)) {
+ return "0.0D / 0.0";
+ } else if(dval == Double.POSITIVE_INFINITY) {
+ return "1.0D / 0.0";
+ } else if(dval == Double.NEGATIVE_INFINITY) {
+ return "-1.0D / 0.0";
+ } else {
+ return value.toString() + "D";
+ }
+ } else if(Double.isNaN(dval)) {
doublefield = "NaN";
} else if(dval == Double.POSITIVE_INFINITY) {
doublefield = "POSITIVE_INFINITY";
@@ -169,7 +184,17 @@ public class ConstExprent extends Exprent {
float fval = ((Float)value).floatValue();
String floatfield;
- if(Float.isNaN(fval)) {
+ if(literal) {
+ if(Double.isNaN(fval)) {
+ return "0.0F / 0.0";
+ } else if(fval == Double.POSITIVE_INFINITY) {
+ return "1.0F / 0.0";
+ } else if(fval == Double.NEGATIVE_INFINITY) {
+ return "-1.0F / 0.0";
+ } else {
+ return value.toString() + "F";
+ }
+ } else if(Float.isNaN(fval)) {
floatfield = "NaN";
} else if(fval == Float.POSITIVE_INFINITY) {
floatfield = "POSITIVE_INFINITY";