decompiler: cleanup

master
Egor.Ushakov 10 years ago
parent d5e22fe0c9
commit 262d580ccc
  1. 4
      src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java
  2. 8
      src/org/jetbrains/java/decompiler/main/ClassesProcessor.java
  3. 4
      src/org/jetbrains/java/decompiler/main/extern/IIdentifierRenamer.java
  4. 12
      src/org/jetbrains/java/decompiler/main/rels/MethodWrapper.java
  5. 6
      src/org/jetbrains/java/decompiler/modules/decompiler/IfHelper.java
  6. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/SequenceHelper.java
  7. 2
      src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java
  8. 6
      src/org/jetbrains/java/decompiler/modules/decompiler/deobfuscator/IrreducibleCFGDeobfuscator.java
  9. 3
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/ExitExprent.java
  10. 3
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/FunctionExprent.java
  11. 12
      src/org/jetbrains/java/decompiler/modules/decompiler/sforms/DirectGraph.java
  12. 12
      src/org/jetbrains/java/decompiler/modules/decompiler/sforms/DirectNode.java
  13. 30
      src/org/jetbrains/java/decompiler/modules/decompiler/sforms/FlattenStatementsHelper.java
  14. 7
      src/org/jetbrains/java/decompiler/modules/decompiler/stats/IfStatement.java
  15. 6
      src/org/jetbrains/java/decompiler/modules/decompiler/stats/Statement.java
  16. 6
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/CheckTypesResult.java
  17. 6
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionEdge.java
  18. 10
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionNode.java
  19. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarVersionsGraph.java
  20. 2
      src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java
  21. 8
      src/org/jetbrains/java/decompiler/struct/gen/generics/GenericClassDescriptor.java
  22. 10
      src/org/jetbrains/java/decompiler/struct/gen/generics/GenericMethodDescriptor.java
  23. 8
      src/org/jetbrains/java/decompiler/struct/lazy/LazyLoader.java
  24. 21
      src/org/jetbrains/java/decompiler/struct/match/IMatchable.java
  25. 4
      src/org/jetbrains/java/decompiler/struct/match/MatchNode.java
  26. 2
      src/org/jetbrains/java/decompiler/util/FastSetFactory.java
  27. 2
      src/org/jetbrains/java/decompiler/util/FastSparseSetFactory.java
  28. 3
      src/org/jetbrains/java/decompiler/util/InterpreterUtil.java

@ -38,9 +38,9 @@ import java.util.Map.Entry;
public class ClassReference14Processor {
public ExitExprent bodyexprent;
public final ExitExprent bodyexprent;
public ExitExprent handlerexprent;
public final ExitExprent handlerexprent;
public ClassReference14Processor() {

@ -353,14 +353,14 @@ public class ClassesProcessor {
public int type;
public int access;
public String simpleName;
public StructClass classStruct;
public final StructClass classStruct;
private ClassWrapper wrapper;
public String enclosingMethod;
public InvocationExprent superInvocation;
public Map<String, VarVersionPair> mapFieldsToVars = new HashMap<String, VarVersionPair>();
public final Map<String, VarVersionPair> mapFieldsToVars = new HashMap<String, VarVersionPair>();
public VarType anonymousClassType;
public List<ClassNode> nested = new ArrayList<ClassNode>();
public Set<String> enclosingClasses = new HashSet<String>();
public final List<ClassNode> nested = new ArrayList<ClassNode>();
public final Set<String> enclosingClasses = new HashSet<String>();
public ClassNode parent;
public LambdaInformation lambdaInformation;
public boolean namelessConstructorStub = false;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -17,7 +17,7 @@ package org.jetbrains.java.decompiler.main.extern;
public interface IIdentifierRenamer {
enum Type {ELEMENT_CLASS, ELEMENT_FIELD, ELEMENT_METHOD};
enum Type {ELEMENT_CLASS, ELEMENT_FIELD, ELEMENT_METHOD}
boolean toBeRenamed(Type elementType, String className, String element, String descriptor);

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -29,13 +29,13 @@ import java.util.List;
public class MethodWrapper {
public RootStatement root;
public final RootStatement root;
public VarProcessor varproc;
public final VarProcessor varproc;
public StructMethod methodStruct;
public final StructMethod methodStruct;
public CounterContainer counter;
public final CounterContainer counter;
public DirectGraph graph;
@ -43,7 +43,7 @@ public class MethodWrapper {
public boolean decompiledWithErrors;
public HashSet<String> setOuterVarNames = new HashSet<String>();
public final HashSet<String> setOuterVarNames = new HashSet<String>();
public MethodWrapper(RootStatement root, VarProcessor varproc, StructMethod methodStruct, CounterContainer counter) {
this.root = root;

@ -733,10 +733,10 @@ public class IfHelper {
}
private static class IfNode {
public Statement value;
public final Statement value;
public List<IfNode> succs = new ArrayList<IfNode>();
public List<Integer> edgetypes = new ArrayList<Integer>();
public final List<IfNode> succs = new ArrayList<IfNode>();
public final List<Integer> edgetypes = new ArrayList<Integer>();
public IfNode(Statement value) {
this.value = value;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -244,7 +244,7 @@ public class SequenceHelper {
while (true) {
Statement next = null;
Statement next;
Statement current = null;
boolean found = false;

@ -51,7 +51,7 @@ import org.jetbrains.java.decompiler.util.InterpreterUtil;
public class SimplifyExprentsHelper {
static MatchEngine class14Builder = new MatchEngine();
static final MatchEngine class14Builder = new MatchEngine();
private final boolean firstInvocation;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -31,8 +31,8 @@ public class IrreducibleCFGDeobfuscator {
class Node {
public Integer id;
public Set<Node> preds = new HashSet<Node>();
public Set<Node> succs = new HashSet<Node>();
public final Set<Node> preds = new HashSet<Node>();
public final Set<Node> succs = new HashSet<Node>();
public Node(Integer id) {
this.id = id;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -33,7 +33,6 @@ import org.jetbrains.java.decompiler.util.InterpreterUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map.Entry;
public class ExitExprent extends Exprent {

@ -21,15 +21,12 @@ import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
import org.jetbrains.java.decompiler.modules.decompiler.vars.CheckTypesResult;
import org.jetbrains.java.decompiler.struct.gen.VarType;
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.ListStack;
import java.util.*;
import java.util.Map.Entry;
public class FunctionExprent extends Exprent {

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -27,21 +27,21 @@ import java.util.List;
public class DirectGraph {
public VBStyleCollection<DirectNode, String> nodes = new VBStyleCollection<DirectNode, String>();
public final VBStyleCollection<DirectNode, String> nodes = new VBStyleCollection<DirectNode, String>();
public DirectNode first;
// exit, [source, destination]
public HashMap<String, List<FinallyPathWrapper>> mapShortRangeFinallyPaths = new HashMap<String, List<FinallyPathWrapper>>();
public final HashMap<String, List<FinallyPathWrapper>> mapShortRangeFinallyPaths = new HashMap<String, List<FinallyPathWrapper>>();
// exit, [source, destination]
public HashMap<String, List<FinallyPathWrapper>> mapLongRangeFinallyPaths = new HashMap<String, List<FinallyPathWrapper>>();
public final HashMap<String, List<FinallyPathWrapper>> mapLongRangeFinallyPaths = new HashMap<String, List<FinallyPathWrapper>>();
// negative if branches (recorded for handling of && and ||)
public HashMap<String, String> mapNegIfBranch = new HashMap<String, String>();
public final HashMap<String, String> mapNegIfBranch = new HashMap<String, String>();
// nodes, that are exception exits of a finally block with monitor variable
public HashMap<String, String> mapFinallyMonitorExceptionPathExits = new HashMap<String, String>();
public final HashMap<String, String> mapFinallyMonitorExceptionPathExits = new HashMap<String, String>();
public void sortReversePostOrder() {
LinkedList<DirectNode> res = new LinkedList<DirectNode>();

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -32,19 +32,19 @@ public class DirectNode {
public static final int NODE_INCREMENT = 5;
public static final int NODE_TRY = 6;
public int type;
public final int type;
public String id;
public final String id;
public BasicBlockStatement block;
public Statement statement;
public final Statement statement;
public List<Exprent> exprents = new ArrayList<Exprent>();
public List<DirectNode> succs = new ArrayList<DirectNode>();
public final List<DirectNode> succs = new ArrayList<DirectNode>();
public List<DirectNode> preds = new ArrayList<DirectNode>();
public final List<DirectNode> preds = new ArrayList<DirectNode>();
public DirectNode(int type, Statement statement, String id) {
this.type = type;

@ -489,9 +489,9 @@ public class FlattenStatementsHelper {
}
public static class FinallyPathWrapper {
public String source;
public String destination;
public String entry;
public final String source;
public final String destination;
public final String entry;
private FinallyPathWrapper(String source, String destination, String entry) {
this.source = source;
@ -522,16 +522,16 @@ public class FlattenStatementsHelper {
private static class StackEntry {
public CatchAllStatement catchstatement;
public boolean state;
public int edgetype;
public boolean isFinallyExceptionPath;
public final CatchAllStatement catchstatement;
public final boolean state;
public final int edgetype;
public final boolean isFinallyExceptionPath;
public Statement destination;
public Statement finallyShortRangeEntry;
public Statement finallyLongRangeEntry;
public DirectNode finallyShortRangeSource;
public DirectNode finallyLongRangeSource;
public final Statement destination;
public final Statement finallyShortRangeEntry;
public final Statement finallyLongRangeEntry;
public final DirectNode finallyShortRangeSource;
public final DirectNode finallyLongRangeSource;
public StackEntry(CatchAllStatement catchstatement,
boolean state,
@ -561,9 +561,9 @@ public class FlattenStatementsHelper {
}
private static class Edge {
public String sourceid;
public Integer statid;
public int edgetype;
public final String sourceid;
public final Integer statid;
public final int edgetype;
public Edge(String sourceid, Integer statid, int edgetype) {
this.sourceid = sourceid;

@ -30,13 +30,12 @@ import org.jetbrains.java.decompiler.util.InterpreterUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
public class IfStatement extends Statement {
public static int IFTYPE_IF = 0;
public static int IFTYPE_IFELSE = 1;
public static final int IFTYPE_IF = 0;
public static final int IFTYPE_IFELSE = 1;
public int iftype;
@ -54,7 +53,7 @@ public class IfStatement extends Statement {
private boolean iffflag;
private List<Exprent> headexprent = new ArrayList<Exprent>(); // contains IfExprent
private final List<Exprent> headexprent = new ArrayList<Exprent>(); // contains IfExprent
// *****************************************************************************
// constructors

@ -80,7 +80,7 @@ public class Statement implements IMatchable {
private final Map<Integer, List<Statement>> mapPredStates = new HashMap<Integer, List<Statement>>();
// statement as graph
protected VBStyleCollection<Statement, Integer> stats = new VBStyleCollection<Statement, Integer>();
protected final VBStyleCollection<Statement, Integer> stats = new VBStyleCollection<Statement, Integer>();
protected Statement parent;
@ -88,9 +88,9 @@ public class Statement implements IMatchable {
protected List<Exprent> exprents;
protected HashSet<StatEdge> labelEdges = new HashSet<StatEdge>();
protected final HashSet<StatEdge> labelEdges = new HashSet<StatEdge>();
protected List<Exprent> varDefinitions = new ArrayList<Exprent>();
protected final List<Exprent> varDefinitions = new ArrayList<Exprent>();
// copied statement, s. deobfuscating of irreducible CFGs
private boolean copied = false;

@ -44,9 +44,9 @@ public class CheckTypesResult {
}
public static class ExprentTypePair {
public Exprent exprent;
public VarType type;
public VarType desttype;
public final Exprent exprent;
public final VarType type;
public final VarType desttype;
public ExprentTypePair(Exprent exprent, VarType type, VarType desttype) {
this.exprent = exprent;

@ -20,11 +20,11 @@ public class VarVersionEdge { // FIXME: can be removed?
public static final int EDGE_GENERAL = 0;
public static final int EDGE_PHANTOM = 1;
public int type;
public final int type;
public VarVersionNode source;
public final VarVersionNode source;
public VarVersionNode dest;
public final VarVersionNode dest;
private final int hashCode;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -27,13 +27,13 @@ public class VarVersionNode implements IGraphNode {
public static final int FLAG_PHANTOM_FINEXIT = 2;
public int var;
public final int var;
public int version;
public final int version;
public Set<VarVersionEdge> succs = new HashSet<VarVersionEdge>();
public final Set<VarVersionEdge> succs = new HashSet<VarVersionEdge>();
public Set<VarVersionEdge> preds = new HashSet<VarVersionEdge>();
public final Set<VarVersionEdge> preds = new HashSet<VarVersionEdge>();
public int flags;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -27,7 +27,7 @@ public class VarVersionsGraph {
public int counter = 0;
public VBStyleCollection<VarVersionNode, VarVersionPair> nodes = new VBStyleCollection<VarVersionNode, VarVersionPair>();
public final VBStyleCollection<VarVersionNode, VarVersionPair> nodes = new VBStyleCollection<VarVersionNode, VarVersionPair>();
private GenericDominatorEngine engine;

@ -34,7 +34,7 @@ public class ConstantPool implements NewClassNameBuilder {
public static final int FIELD = 1;
public static final int METHOD = 2;
private List<PooledConstant> pool = new ArrayList<PooledConstant>();
private final List<PooledConstant> pool = new ArrayList<PooledConstant>();
private final PoolInterceptor interceptor;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -22,9 +22,9 @@ public class GenericClassDescriptor {
public GenericType superclass;
public List<GenericType> superinterfaces = new ArrayList<GenericType>();
public final List<GenericType> superinterfaces = new ArrayList<GenericType>();
public List<String> fparameters = new ArrayList<String>();
public final List<String> fparameters = new ArrayList<String>();
public List<List<GenericType>> fbounds = new ArrayList<List<GenericType>>();
public final List<List<GenericType>> fbounds = new ArrayList<List<GenericType>>();
}

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -20,13 +20,13 @@ import java.util.List;
public class GenericMethodDescriptor {
public List<String> fparameters = new ArrayList<String>();
public final List<String> fparameters = new ArrayList<String>();
public List<List<GenericType>> fbounds = new ArrayList<List<GenericType>>();
public final List<List<GenericType>> fbounds = new ArrayList<List<GenericType>>();
public List<GenericType> params = new ArrayList<GenericType>();
public final List<GenericType> params = new ArrayList<GenericType>();
public GenericType ret;
public List<GenericType> exceptions = new ArrayList<GenericType>();
public final List<GenericType> exceptions = new ArrayList<GenericType>();
}

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -160,9 +160,9 @@ public class LazyLoader {
public static final int CLASS = 1;
public static final int ENTRY = 2;
public int type;
public String externalPath;
public String internalPath;
public final int type;
public final String externalPath;
public final String internalPath;
public Link(int type, String externalPath, String internalPath) {
this.type = type;

@ -1,9 +1,24 @@
/*
* Copyright 2000-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.java.decompiler.struct.match;
public interface IMatchable {
public enum MatchProperties {
enum MatchProperties {
STATEMENT_TYPE,
STATEMENT_RET,
STATEMENT_STATSIZE,
@ -25,8 +40,8 @@ public interface IMatchable {
EXPRENT_FIELD_NAME,
}
public IMatchable findObject(MatchNode matchNode, int index);
IMatchable findObject(MatchNode matchNode, int index);
public boolean match(MatchNode matchNode, MatchEngine engine);
boolean match(MatchNode matchNode, MatchEngine engine);
}

@ -25,8 +25,8 @@ import org.jetbrains.java.decompiler.struct.match.IMatchable.MatchProperties;
public class MatchNode {
public static class RuleValue {
public int parameter;
public Object value;
public final int parameter;
public final Object value;
public RuleValue(int parameter, Object value) {
this.parameter = parameter;

@ -192,7 +192,7 @@ public class FastSetFactory<E> {
index = factory.addElement(element);
}
return index[0] >= data.length ? false : ((data[index[0]] & index[1]) != 0);
return index[0] < data.length && ((data[index[0]] & index[1]) != 0);
}
public boolean contains(FastSet<E> set) {

@ -219,7 +219,7 @@ public class FastSparseSetFactory<E> {
index = factory.addElement(element);
}
return index[0] >= data.length ? false : ((data[index[0]] & index[1]) != 0);
return index[0] < data.length && ((data[index[0]] & index[1]) != 0);
}
public boolean contains(FastSparseSet<E> set) {

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -16,7 +16,6 @@
package org.jetbrains.java.decompiler.util;
import org.jetbrains.java.decompiler.main.DecompilerContext;
import org.jetbrains.java.decompiler.main.TextBuffer;
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
import java.io.*;

Loading…
Cancel
Save