decompiler: cleanup

This commit is contained in:
Egor.Ushakov
2015-03-27 12:56:07 +03:00
parent d5e22fe0c9
commit 262d580ccc
28 changed files with 107 additions and 98 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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>();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;