mirror of
https://github.com/moparisthebest/fernflower
synced 2024-11-23 09:42:18 -05:00
option to pass numeric literals undecoded
This commit is contained in:
parent
5c8ad60f12
commit
0a66fa8925
1
dist/docs/readme.txt
vendored
1
dist/docs/readme.txt
vendored
@ -51,6 +51,7 @@ occ (0): ouput copyright comment
|
|||||||
ner (1): assume return not throwing exceptions
|
ner (1): assume return not throwing exceptions
|
||||||
den (1): decompile enumerations
|
den (1): decompile enumerations
|
||||||
rgn (1): remove getClass() invocation, when it is part of a qualified new statement
|
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)
|
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)
|
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)
|
uto (1): consider nameless types as java.lang.Object (workaround to a compiler architecture flaw)
|
||||||
|
@ -76,7 +76,7 @@ public class DecompilerContext {
|
|||||||
mapDefault.put(IFernflowerPreferences.DECOMPILE_ENUM, "1");
|
mapDefault.put(IFernflowerPreferences.DECOMPILE_ENUM, "1");
|
||||||
mapDefault.put(IFernflowerPreferences.FINALLY_DEINLINE, "1");
|
mapDefault.put(IFernflowerPreferences.FINALLY_DEINLINE, "1");
|
||||||
mapDefault.put(IFernflowerPreferences.REMOVE_GETCLASS_NEW, "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.BOOLEAN_TRUE_ONE, "1");
|
||||||
mapDefault.put(IFernflowerPreferences.SYNTHETIC_NOT_SET, "1");
|
mapDefault.put(IFernflowerPreferences.SYNTHETIC_NOT_SET, "1");
|
||||||
mapDefault.put(IFernflowerPreferences.UNDEFINED_PARAM_TYPE_OBJECT, "1");
|
mapDefault.put(IFernflowerPreferences.UNDEFINED_PARAM_TYPE_OBJECT, "1");
|
||||||
|
@ -28,6 +28,7 @@ public interface IFernflowerPreferences {
|
|||||||
public static final String NO_EXCEPTIONS_RETURN = "ner";
|
public static final String NO_EXCEPTIONS_RETURN = "ner";
|
||||||
public static final String DECOMPILE_ENUM = "den";
|
public static final String DECOMPILE_ENUM = "den";
|
||||||
public static final String REMOVE_GETCLASS_NEW = "rgn";
|
public static final String REMOVE_GETCLASS_NEW = "rgn";
|
||||||
|
public static final String LITERALS_AS_IS = "bto";
|
||||||
public static final String BOOLEAN_TRUE_ONE = "bto";
|
public static final String BOOLEAN_TRUE_ONE = "bto";
|
||||||
public static final String SYNTHETIC_NOT_SET = "nns";
|
public static final String SYNTHETIC_NOT_SET = "nns";
|
||||||
public static final String UNDEFINED_PARAM_TYPE_OBJECT = "uto";
|
public static final String UNDEFINED_PARAM_TYPE_OBJECT = "uto";
|
||||||
|
@ -101,6 +101,7 @@ public class ConstExprent extends Exprent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toJava(int indent) {
|
public String toJava(int indent) {
|
||||||
|
boolean literal = DecompilerContext.getOption(IFernflowerPreferences.LITERALS_AS_IS);
|
||||||
|
|
||||||
if(consttype.type != CodeConstants.TYPE_NULL && value == null) {
|
if(consttype.type != CodeConstants.TYPE_NULL && value == null) {
|
||||||
return ExprProcessor.getCastTypeName(consttype);
|
return ExprProcessor.getCastTypeName(consttype);
|
||||||
@ -112,7 +113,7 @@ public class ConstExprent extends Exprent {
|
|||||||
Integer val = (Integer)value;
|
Integer val = (Integer)value;
|
||||||
String ret = escapes.get(val);
|
String ret = escapes.get(val);
|
||||||
if(ret == null) {
|
if(ret == null) {
|
||||||
if(val.intValue() >= 32 && val.intValue() < 127) {
|
if(literal || val.intValue() >= 32 && val.intValue() < 127) {
|
||||||
ret = String.valueOf((char)val.intValue());
|
ret = String.valueOf((char)val.intValue());
|
||||||
} else {
|
} else {
|
||||||
ret = InterpreterUtil.charToUnicodeLiteral(val);
|
ret = InterpreterUtil.charToUnicodeLiteral(val);
|
||||||
@ -127,7 +128,9 @@ public class ConstExprent extends Exprent {
|
|||||||
int ival = ((Integer)value).intValue();
|
int ival = ((Integer)value).intValue();
|
||||||
|
|
||||||
String intfield;
|
String intfield;
|
||||||
if(ival == Integer.MAX_VALUE) {
|
if(literal) {
|
||||||
|
return value.toString();
|
||||||
|
} else if(ival == Integer.MAX_VALUE) {
|
||||||
intfield = "MAX_VALUE";
|
intfield = "MAX_VALUE";
|
||||||
} else if(ival == Integer.MIN_VALUE) {
|
} else if(ival == Integer.MIN_VALUE) {
|
||||||
intfield = "MIN_VALUE";
|
intfield = "MIN_VALUE";
|
||||||
@ -139,7 +142,9 @@ public class ConstExprent extends Exprent {
|
|||||||
long lval = ((Long)value).longValue();
|
long lval = ((Long)value).longValue();
|
||||||
|
|
||||||
String longfield;
|
String longfield;
|
||||||
if(lval == Long.MAX_VALUE) {
|
if(literal) {
|
||||||
|
return value.toString()+"L";
|
||||||
|
} else if(lval == Long.MAX_VALUE) {
|
||||||
longfield = "MAX_VALUE";
|
longfield = "MAX_VALUE";
|
||||||
} else if(lval == Long.MIN_VALUE) {
|
} else if(lval == Long.MIN_VALUE) {
|
||||||
longfield = "MIN_VALUE";
|
longfield = "MIN_VALUE";
|
||||||
@ -151,7 +156,17 @@ public class ConstExprent extends Exprent {
|
|||||||
double dval = ((Double)value).doubleValue();
|
double dval = ((Double)value).doubleValue();
|
||||||
|
|
||||||
String doublefield;
|
String doublefield;
|
||||||
|
if(literal) {
|
||||||
if(Double.isNaN(dval)) {
|
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";
|
doublefield = "NaN";
|
||||||
} else if(dval == Double.POSITIVE_INFINITY) {
|
} else if(dval == Double.POSITIVE_INFINITY) {
|
||||||
doublefield = "POSITIVE_INFINITY";
|
doublefield = "POSITIVE_INFINITY";
|
||||||
@ -169,7 +184,17 @@ public class ConstExprent extends Exprent {
|
|||||||
float fval = ((Float)value).floatValue();
|
float fval = ((Float)value).floatValue();
|
||||||
|
|
||||||
String floatfield;
|
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";
|
floatfield = "NaN";
|
||||||
} else if(fval == Float.POSITIVE_INFINITY) {
|
} else if(fval == Float.POSITIVE_INFINITY) {
|
||||||
floatfield = "POSITIVE_INFINITY";
|
floatfield = "POSITIVE_INFINITY";
|
||||||
|
Loading…
Reference in New Issue
Block a user