Some fixes.
This commit is contained in:
@@ -56,7 +56,7 @@ public class Method
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return this.getMethods().getClassFile().getName() + "." + this.name + this.arguments;
|
return (this.isStatic() ? "static " : "") + this.getMethods().getClassFile().getName() + "." + this.name + this.arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(DataOutputStream out) throws IOException
|
public void write(DataOutputStream out) throws IOException
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
|
|||||||
|
|
||||||
// add possible method call to execution
|
// add possible method call to execution
|
||||||
Execution execution = frame.getExecution();
|
Execution execution = frame.getExecution();
|
||||||
Frame f = execution.invoke(ins, method);
|
execution.invoke(ins, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.addInstructionContext(ins);
|
frame.addInstructionContext(ins);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import net.runelite.deob.pool.NameAndType;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.Method;
|
||||||
|
|
||||||
public class PutField extends Instruction implements SetFieldInstruction
|
public class PutField extends Instruction implements SetFieldInstruction
|
||||||
{
|
{
|
||||||
@@ -26,6 +27,13 @@ public class PutField extends Instruction implements SetFieldInstruction
|
|||||||
{
|
{
|
||||||
super(instructions, type, pc);
|
super(instructions, type, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
Method m = this.getInstructions().getCode().getAttributes().getMethod();
|
||||||
|
return "putfield " + myField + " in " + m;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(DataInputStream is) throws IOException
|
public void load(DataInputStream is) throws IOException
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import net.runelite.deob.pool.NameAndType;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import net.runelite.deob.Method;
|
||||||
|
|
||||||
public class PutStatic extends Instruction implements SetFieldInstruction
|
public class PutStatic extends Instruction implements SetFieldInstruction
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,13 @@ public class PutStatic extends Instruction implements SetFieldInstruction
|
|||||||
super(instructions, type, pc);
|
super(instructions, type, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
Method m = this.getInstructions().getCode().getAttributes().getMethod();
|
||||||
|
return "putstatic " + myField + " in " + m;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(DataInputStream is) throws IOException
|
public void load(DataInputStream is) throws IOException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class Vertex
|
|||||||
private final Object object;
|
private final Object object;
|
||||||
private VertexType type;
|
private VertexType type;
|
||||||
|
|
||||||
private final Map<Edge, Edge> edges = new HashMap<>();
|
private final Set<Edge> edges = new HashSet<>();
|
||||||
|
|
||||||
private Collection<Vertex> mightBe;
|
private Collection<Vertex> mightBe;
|
||||||
private Vertex is;
|
private Vertex is;
|
||||||
@@ -107,8 +107,8 @@ public class Vertex
|
|||||||
|
|
||||||
public void addEdge(Edge edge)
|
public void addEdge(Edge edge)
|
||||||
{
|
{
|
||||||
Edge c = edges.get(edge);
|
if (edges.contains(edge))
|
||||||
if (c != null)
|
//if (c != null)
|
||||||
{
|
{
|
||||||
// if (edge.getIns() instanceof SetFieldInstruction && !edgeFrom.contains(edge.getIns()))
|
// if (edge.getIns() instanceof SetFieldInstruction && !edgeFrom.contains(edge.getIns()))
|
||||||
// {
|
// {
|
||||||
@@ -118,12 +118,13 @@ public class Vertex
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
edges.put(edge, edge);
|
edges.add(edge);
|
||||||
|
//edges.put(edge, edge);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Edge> getEdges()
|
public Set<Edge> getEdges()
|
||||||
{
|
{
|
||||||
return edges.keySet();
|
return edges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void merge(Collection<Vertex> maybe)
|
public void merge(Collection<Vertex> maybe)
|
||||||
@@ -295,21 +296,21 @@ public class Vertex
|
|||||||
if (this.getType() != other.getType())
|
if (this.getType() != other.getType())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (this.getEdges().size() != other.getEdges().size())
|
// if (this.getEdges().size() != other.getEdges().size())
|
||||||
return false;
|
// return false;
|
||||||
|
//
|
||||||
for (EdgeType e : EdgeType.values())
|
// for (EdgeType e : EdgeType.values())
|
||||||
{
|
// {
|
||||||
// for each edge of this type, it must be equal with just one of the others
|
// // for each edge of this type, it must be equal with just one of the others
|
||||||
|
//
|
||||||
if (this.edgesOf(e) != other.edgesOf(e))// ||
|
// if (this.edgesOf(e) != other.edgesOf(e))// ||
|
||||||
//this.solvedEdgesOfType(e) != other.solvedEdgesOfType(e))
|
// //this.solvedEdgesOfType(e) != other.solvedEdgesOfType(e))
|
||||||
{
|
// {
|
||||||
int thise = edgesOf(e), othere = other.edgesOf(e);
|
// int thise = edgesOf(e), othere = other.edgesOf(e);
|
||||||
int thisse = this.solvedEdgesOfType(e), otherse = other.solvedEdgesOfType(e);
|
// int thisse = this.solvedEdgesOfType(e), otherse = other.solvedEdgesOfType(e);
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// must be 1->1
|
// must be 1->1
|
||||||
// map v -> possibles
|
// map v -> possibles
|
||||||
@@ -424,7 +425,7 @@ public class Vertex
|
|||||||
private int edgesOf(EdgeType type)
|
private int edgesOf(EdgeType type)
|
||||||
{
|
{
|
||||||
int t = 0;
|
int t = 0;
|
||||||
for (Edge e : this.edges.values())
|
for (Edge e : this.edges)
|
||||||
if (e.getType() == type)
|
if (e.getType() == type)
|
||||||
++t;
|
++t;
|
||||||
return t;
|
return t;
|
||||||
@@ -432,6 +433,6 @@ public class Vertex
|
|||||||
|
|
||||||
private int solvedEdgesOfType(EdgeType type)
|
private int solvedEdgesOfType(EdgeType type)
|
||||||
{
|
{
|
||||||
return (int) edges.values().stream().filter(e -> e.getType() == type).filter(e -> e.getTo().getOther() != null).count();
|
return (int) edges.stream().filter(e -> e.getType() == type).filter(e -> e.getTo().getOther() != null).count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public class Execution
|
|||||||
public Set<Instruction> executed = new HashSet<>(); // executed instructions
|
public Set<Instruction> executed = new HashSet<>(); // executed instructions
|
||||||
private MultiValueMap<InstructionContext, Method> invokes = new MultiValueMap<>();
|
private MultiValueMap<InstructionContext, Method> invokes = new MultiValueMap<>();
|
||||||
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>();
|
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>();
|
||||||
private Map<Method, MethodContext> methodContexts = new HashMap<>();
|
|
||||||
private boolean buildGraph; // if true the frame graph is built and execution hasJumped also compares previous instructions
|
private boolean buildGraph; // if true the frame graph is built and execution hasJumped also compares previous instructions
|
||||||
private Graph graph = new Graph();
|
private Graph graph = new Graph();
|
||||||
|
|
||||||
@@ -91,6 +90,8 @@ public class Execution
|
|||||||
|
|
||||||
private boolean hasInvoked(InstructionContext from, Method to)
|
private boolean hasInvoked(InstructionContext from, Method to)
|
||||||
{
|
{
|
||||||
|
// this is wrong because the called of the method of from
|
||||||
|
// might be different, for building graph
|
||||||
Collection<Method> methods = invokes.getCollection(from);
|
Collection<Method> methods = invokes.getCollection(from);
|
||||||
if (methods != null && methods.contains(to))
|
if (methods != null && methods.contains(to))
|
||||||
return true;
|
return true;
|
||||||
@@ -150,17 +151,6 @@ public class Execution
|
|||||||
{
|
{
|
||||||
return contexts.getCollection(i);
|
return contexts.getCollection(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodContext getMethodContext(Method m)
|
|
||||||
{
|
|
||||||
MethodContext c = methodContexts.get(m);
|
|
||||||
if (c != null)
|
|
||||||
return c;
|
|
||||||
|
|
||||||
c = new MethodContext(this);
|
|
||||||
methodContexts.put(m, c);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBuildGraph()
|
public boolean isBuildGraph()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ public class Frame
|
|||||||
private List<InstructionContext> instructions = new ArrayList<>(); // instructions executed in this frame
|
private List<InstructionContext> instructions = new ArrayList<>(); // instructions executed in this frame
|
||||||
private MethodContext ctx;
|
private MethodContext ctx;
|
||||||
protected Method nonStatic; // next non static method up the stack
|
protected Method nonStatic; // next non static method up the stack
|
||||||
public Field lastField;
|
private Frame caller;
|
||||||
public Frame staticReturn;
|
|
||||||
|
|
||||||
public Frame(Execution execution, Method method)
|
public Frame(Execution execution, Method method)
|
||||||
{
|
{
|
||||||
@@ -39,7 +38,10 @@ public class Frame
|
|||||||
|
|
||||||
stack = new Stack(code.getMaxStack());
|
stack = new Stack(code.getMaxStack());
|
||||||
variables = new Variables(code.getMaxLocals());
|
variables = new Variables(code.getMaxLocals());
|
||||||
ctx = execution.getMethodContext(method);
|
// don't cache method contexts per execution
|
||||||
|
// need to allow the same method to execute multiple times
|
||||||
|
// when called from multiple places to allow graph building
|
||||||
|
ctx = new MethodContext(execution);
|
||||||
nonStatic = method;
|
nonStatic = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +72,7 @@ public class Frame
|
|||||||
{
|
{
|
||||||
this.nonStatic = ctx.getFrame().nonStatic;
|
this.nonStatic = ctx.getFrame().nonStatic;
|
||||||
}
|
}
|
||||||
|
caller = ctx.getFrame();
|
||||||
|
|
||||||
// initialize LVT. the last argument is popped first, and is at arguments[0]
|
// initialize LVT. the last argument is popped first, and is at arguments[0]
|
||||||
List<StackContext> pops = ctx.getPops();
|
List<StackContext> pops = ctx.getPops();
|
||||||
@@ -105,8 +108,7 @@ public class Frame
|
|||||||
this.variables = new Variables(other.variables);
|
this.variables = new Variables(other.variables);
|
||||||
this.ctx = other.ctx;
|
this.ctx = other.ctx;
|
||||||
this.nonStatic = other.nonStatic;
|
this.nonStatic = other.nonStatic;
|
||||||
this.lastField = other.lastField;
|
this.caller = other.caller;
|
||||||
this.staticReturn = other.staticReturn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Frame dup()
|
public Frame dup()
|
||||||
@@ -223,12 +225,6 @@ public class Frame
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
execution.buildGraph(this, oldCur, ictx);
|
execution.buildGraph(this, oldCur, ictx);
|
||||||
if (oldCur instanceof SetFieldInstruction)
|
|
||||||
{
|
|
||||||
SetFieldInstruction sfi = (SetFieldInstruction) oldCur;
|
|
||||||
if (sfi.getMyField() != null)
|
|
||||||
this.lastField = sfi.getMyField();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldCur == cur)
|
if (oldCur == cur)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user