Hiding synthetic fields (IDEA-132625)
This commit is contained in:
@@ -30,6 +30,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class DecompilerContext {
|
public class DecompilerContext {
|
||||||
public static final String CURRENT_CLASS = "CURRENT_CLASS";
|
public static final String CURRENT_CLASS = "CURRENT_CLASS";
|
||||||
|
public static final String CURRENT_CLASS_WRAPPER = "CURRENT_CLASS_WRAPPER";
|
||||||
public static final String CURRENT_CLASS_NODE = "CURRENT_CLASS_NODE";
|
public static final String CURRENT_CLASS_NODE = "CURRENT_CLASS_NODE";
|
||||||
public static final String CURRENT_METHOD = "CURRENT_METHOD";
|
public static final String CURRENT_METHOD = "CURRENT_METHOD";
|
||||||
public static final String CURRENT_METHOD_DESCRIPTOR = "CURRENT_METHOD_DESCRIPTOR";
|
public static final String CURRENT_METHOD_DESCRIPTOR = "CURRENT_METHOD_DESCRIPTOR";
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class ClassWrapper {
|
|||||||
|
|
||||||
public void init() throws IOException {
|
public void init() throws IOException {
|
||||||
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS, classStruct);
|
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS, classStruct);
|
||||||
|
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_WRAPPER, this);
|
||||||
DecompilerContext.getLogger().startClass(classStruct.qualifiedName);
|
DecompilerContext.getLogger().startClass(classStruct.qualifiedName);
|
||||||
|
|
||||||
// collect field names
|
// collect field names
|
||||||
|
|||||||
@@ -27,11 +27,13 @@ import org.jetbrains.java.decompiler.code.CodeConstants;
|
|||||||
import org.jetbrains.java.decompiler.main.ClassesProcessor.ClassNode;
|
import org.jetbrains.java.decompiler.main.ClassesProcessor.ClassNode;
|
||||||
import org.jetbrains.java.decompiler.main.DecompilerContext;
|
import org.jetbrains.java.decompiler.main.DecompilerContext;
|
||||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
|
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
|
||||||
|
import org.jetbrains.java.decompiler.main.rels.ClassWrapper;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.ArrayExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.ArrayExprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.AssignmentExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.AssignmentExprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.ConstExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.ConstExprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.ExitExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.ExitExprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
|
||||||
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.FieldExprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.FunctionExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.FunctionExprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent;
|
||||||
import org.jetbrains.java.decompiler.modules.decompiler.exps.MonitorExprent;
|
import org.jetbrains.java.decompiler.modules.decompiler.exps.MonitorExprent;
|
||||||
@@ -45,6 +47,7 @@ import org.jetbrains.java.decompiler.struct.StructClass;
|
|||||||
import org.jetbrains.java.decompiler.struct.gen.VarType;
|
import org.jetbrains.java.decompiler.struct.gen.VarType;
|
||||||
import org.jetbrains.java.decompiler.struct.match.MatchEngine;
|
import org.jetbrains.java.decompiler.struct.match.MatchEngine;
|
||||||
import org.jetbrains.java.decompiler.util.FastSparseSetFactory.FastSparseSet;
|
import org.jetbrains.java.decompiler.util.FastSparseSetFactory.FastSparseSet;
|
||||||
|
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||||
|
|
||||||
public class SimplifyExprentsHelper {
|
public class SimplifyExprentsHelper {
|
||||||
|
|
||||||
@@ -882,12 +885,12 @@ public class SimplifyExprentsHelper {
|
|||||||
"statement type:if iftype:if exprsize:-1\n" +
|
"statement type:if iftype:if exprsize:-1\n" +
|
||||||
" exprent position:head type:if\n" +
|
" exprent position:head type:if\n" +
|
||||||
" exprent type:function functype:eq\n" +
|
" exprent type:function functype:eq\n" +
|
||||||
" exprent type:field name:$field$\n" +
|
" exprent type:field name:$fieldname$\n" +
|
||||||
" exprent type:constant consttype:null\n" +
|
" exprent type:constant consttype:null\n" +
|
||||||
" statement type:basicblock\n" +
|
" statement type:basicblock\n" +
|
||||||
" exprent position:-1 type:assignment ret:$assignfield$\n" +
|
" exprent position:-1 type:assignment ret:$assignfield$\n" +
|
||||||
" exprent type:var index:$var$\n" +
|
" exprent type:var index:$var$\n" +
|
||||||
" exprent type:field name:$field$\n" +
|
" exprent type:field name:$fieldname$\n" +
|
||||||
" statement type:sequence statsize:2\n" +
|
" statement type:sequence statsize:2\n" +
|
||||||
" statement type:trycatch\n" +
|
" statement type:trycatch\n" +
|
||||||
" statement type:basicblock exprsize:1\n" +
|
" statement type:basicblock exprsize:1\n" +
|
||||||
@@ -899,7 +902,7 @@ public class SimplifyExprentsHelper {
|
|||||||
" exprent type:exit exittype:throw\n" +
|
" exprent type:exit exittype:throw\n" +
|
||||||
" statement type:basicblock exprsize:1\n" +
|
" statement type:basicblock exprsize:1\n" +
|
||||||
" exprent type:assignment\n" +
|
" exprent type:assignment\n" +
|
||||||
" exprent type:field name:$field$\n" +
|
" exprent type:field name:$fieldname$ ret:$field$\n" +
|
||||||
" exprent type:var index:$var$"
|
" exprent type:var index:$var$"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -911,6 +914,7 @@ public class SimplifyExprentsHelper {
|
|||||||
|
|
||||||
String class_name = (String)class14Builder.getVariableValue("$classname$");
|
String class_name = (String)class14Builder.getVariableValue("$classname$");
|
||||||
AssignmentExprent assfirst = (AssignmentExprent)class14Builder.getVariableValue("$assignfield$");
|
AssignmentExprent assfirst = (AssignmentExprent)class14Builder.getVariableValue("$assignfield$");
|
||||||
|
FieldExprent fieldexpr = (FieldExprent)class14Builder.getVariableValue("$field$");
|
||||||
|
|
||||||
assfirst.replaceExprent(assfirst.getRight(), new ConstExprent(VarType.VARTYPE_CLASS, class_name, null));
|
assfirst.replaceExprent(assfirst.getRight(), new ConstExprent(VarType.VARTYPE_CLASS, class_name, null));
|
||||||
|
|
||||||
@@ -920,6 +924,12 @@ public class SimplifyExprentsHelper {
|
|||||||
stat.setExprents(data);
|
stat.setExprents(data);
|
||||||
|
|
||||||
SequenceHelper.destroyAndFlattenStatement(stat);
|
SequenceHelper.destroyAndFlattenStatement(stat);
|
||||||
|
|
||||||
|
ClassWrapper wrapper = (ClassWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_WRAPPER);
|
||||||
|
if (wrapper != null) {
|
||||||
|
wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(fieldexpr.getName(), fieldexpr.getDescriptor().descriptorString));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
+1
-1
@@ -114,7 +114,7 @@ public class FastExtendedPostdominanceHelper {
|
|||||||
|
|
||||||
Statement edge_destination = edge.getDestination();
|
Statement edge_destination = edge.getDestination();
|
||||||
|
|
||||||
if(!setVisited.contains(edge_destination) /*&& !setStack.contains(edge_destination)*/) {
|
if(!setVisited.contains(edge_destination)) {
|
||||||
|
|
||||||
stack.add(edge_destination);
|
stack.add(edge_destination);
|
||||||
stackPath.add(path.getCopy());
|
stackPath.add(path.getCopy());
|
||||||
|
|||||||
Reference in New Issue
Block a user