[java-decompiler] utility classes reorganized
This commit is contained in:
@@ -27,6 +27,7 @@ import org.jetbrains.java.decompiler.struct.match.MatchEngine;
|
||||
import org.jetbrains.java.decompiler.struct.match.MatchNode;
|
||||
import org.jetbrains.java.decompiler.struct.match.MatchNode.RuleValue;
|
||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
import org.jetbrains.java.decompiler.util.TextUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
@@ -131,11 +132,11 @@ public class ConstExprent extends Exprent {
|
||||
String ret = ESCAPES.get(val);
|
||||
if (ret == null) {
|
||||
char c = (char)val.intValue();
|
||||
if (c >= 32 && c < 127 || !ascii && InterpreterUtil.isPrintableUnicode(c)) {
|
||||
if (c >= 32 && c < 127 || !ascii && TextUtil.isPrintableUnicode(c)) {
|
||||
ret = String.valueOf(c);
|
||||
}
|
||||
else {
|
||||
ret = InterpreterUtil.charToUnicodeLiteral(c);
|
||||
ret = TextUtil.charToUnicodeLiteral(c);
|
||||
}
|
||||
}
|
||||
return new TextBuffer(ret).enclose("\'", "\'");
|
||||
@@ -307,11 +308,11 @@ public class ConstExprent extends Exprent {
|
||||
buffer.append("\\\'");
|
||||
break;
|
||||
default:
|
||||
if (c >= 32 && c < 127 || !ascii && InterpreterUtil.isPrintableUnicode(c)) {
|
||||
if (c >= 32 && c < 127 || !ascii && TextUtil.isPrintableUnicode(c)) {
|
||||
buffer.append(c);
|
||||
}
|
||||
else {
|
||||
buffer.append(InterpreterUtil.charToUnicodeLiteral(c));
|
||||
buffer.append(TextUtil.charToUnicodeLiteral(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
|
||||
import org.jetbrains.java.decompiler.main.rels.MethodWrapper;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
|
||||
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair;
|
||||
import org.jetbrains.java.decompiler.struct.attr.StructLocalVariableTableAttribute;
|
||||
import org.jetbrains.java.decompiler.struct.consts.LinkConstant;
|
||||
import org.jetbrains.java.decompiler.struct.gen.FieldDescriptor;
|
||||
import org.jetbrains.java.decompiler.struct.gen.VarType;
|
||||
@@ -30,7 +31,6 @@ import org.jetbrains.java.decompiler.struct.match.MatchEngine;
|
||||
import org.jetbrains.java.decompiler.struct.match.MatchNode;
|
||||
import org.jetbrains.java.decompiler.struct.match.MatchNode.RuleValue;
|
||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
import org.jetbrains.java.decompiler.util.StructUtils;
|
||||
import org.jetbrains.java.decompiler.util.TextUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -38,7 +38,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class FieldExprent extends Exprent {
|
||||
|
||||
private final String name;
|
||||
private final String classname;
|
||||
private final boolean isStatic;
|
||||
@@ -85,7 +84,15 @@ public class FieldExprent extends Exprent {
|
||||
}
|
||||
|
||||
private boolean isAmbiguous() {
|
||||
return StructUtils.getCurrentMethodLocalVariableNames().contains(name);
|
||||
MethodWrapper method = (MethodWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_METHOD_WRAPPER);
|
||||
if (method != null) {
|
||||
StructLocalVariableTableAttribute attr = method.methodStruct.getLocalVariableAttr();
|
||||
if (attr != null) {
|
||||
return attr.getMapVarNames().containsValue(name);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,5 +222,4 @@ public class FieldExprent extends Exprent {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,8 +25,7 @@ import org.jetbrains.java.decompiler.modules.decompiler.exps.IfExprent;
|
||||
import org.jetbrains.java.decompiler.struct.match.IMatchable;
|
||||
import org.jetbrains.java.decompiler.struct.match.MatchEngine;
|
||||
import org.jetbrains.java.decompiler.struct.match.MatchNode;
|
||||
import org.jetbrains.java.decompiler.struct.match.IMatchable.MatchProperties;
|
||||
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||
import org.jetbrains.java.decompiler.util.TextUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -205,7 +204,7 @@ public class IfStatement extends Statement {
|
||||
}
|
||||
|
||||
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
|
||||
String indstr = InterpreterUtil.getIndentString(indent);
|
||||
String indstr = TextUtil.getIndentString(indent);
|
||||
TextBuffer buf = new TextBuffer();
|
||||
|
||||
buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer));
|
||||
|
||||
Reference in New Issue
Block a user