summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-06-26 15:52:47 +0200
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-06-26 15:52:47 +0200
commit4df7866a5c5ef56c763f844848d24438bb4555e4 (patch)
treecbabdb053d1488c7e6e10316a8139b4583dae23e /src
parentb13dee2567853b059ff0c1125b78f860667f5bd7 (diff)
downloadfernflower-4df7866a5c5ef56c763f844848d24438bb4555e4.tar
fernflower-4df7866a5c5ef56c763f844848d24438bb4555e4.tar.gz
fernflower-4df7866a5c5ef56c763f844848d24438bb4555e4.tar.lz
fernflower-4df7866a5c5ef56c763f844848d24438bb4555e4.tar.xz
fernflower-4df7866a5c5ef56c763f844848d24438bb4555e4.zip
"ascii" option documented and used for both string and character literals
Diffstat (limited to 'src')
-rw-r--r--src/de/fernflower/main/DecompilerContext.java3
-rw-r--r--src/de/fernflower/modules/decompiler/exps/ConstExprent.java10
2 files changed, 7 insertions, 6 deletions
diff --git a/src/de/fernflower/main/DecompilerContext.java b/src/de/fernflower/main/DecompilerContext.java
index 7dd8616..63de9ba 100644
--- a/src/de/fernflower/main/DecompilerContext.java
+++ b/src/de/fernflower/main/DecompilerContext.java
@@ -77,7 +77,8 @@ public class DecompilerContext {
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.ASCII_STRING_CHARACTERS, "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/modules/decompiler/exps/ConstExprent.java b/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
index 43aad3e..2d63fcb 100644
--- a/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
@@ -102,6 +102,7 @@ public class ConstExprent extends Exprent {
public String toJava(int indent) {
boolean literal = DecompilerContext.getOption(IFernflowerPreferences.LITERALS_AS_IS);
+ boolean ascii = DecompilerContext.getOption(IFernflowerPreferences.ASCII_STRING_CHARACTERS);
if(consttype.type != CodeConstants.TYPE_NULL && value == null) {
return ExprProcessor.getCastTypeName(consttype);
@@ -113,7 +114,7 @@ public class ConstExprent extends Exprent {
Integer val = (Integer)value;
String ret = escapes.get(val);
if(ret == null) {
- if(literal || val.intValue() >= 32 && val.intValue() < 127) {
+ if(!ascii || val.intValue() >= 32 && val.intValue() < 127) {
ret = String.valueOf((char)val.intValue());
} else {
ret = InterpreterUtil.charToUnicodeLiteral(val);
@@ -212,7 +213,7 @@ public class ConstExprent extends Exprent {
return "null";
case CodeConstants.TYPE_OBJECT:
if(consttype.equals(VarType.VARTYPE_STRING)) {
- return "\""+convertStringToJava(value.toString())+"\"";
+ return "\""+convertStringToJava(value.toString(), ascii)+"\"";
} else if(consttype.equals(VarType.VARTYPE_CLASS)) {
String strval = value.toString();
@@ -231,8 +232,7 @@ public class ConstExprent extends Exprent {
throw new RuntimeException("invalid constant type");
}
- private String convertStringToJava(String value) {
-
+ private String convertStringToJava(String value, boolean ascii) {
char[] arr = value.toCharArray();
StringBuilder buffer = new StringBuilder(arr.length);
@@ -263,7 +263,7 @@ public class ConstExprent extends Exprent {
buffer.append("\\\'");
break;
default:
- if(!DecompilerContext.getOption(IFernflowerPreferences.ASCII_STRING_CHARACTERS) || (c >= 32 && c < 127)) {
+ if(!ascii || (c >= 32 && c < 127)) {
buffer.append(c);
} else {
buffer.append(InterpreterUtil.charToUnicodeLiteral(c));