Solved methods 940, solved fields 1084, unsolved methods 173, unsolved fields 1211. also included jars i am using
This commit is contained in:
@@ -428,6 +428,14 @@ public class Rename2
|
|||||||
|
|
||||||
//rename(mappings, two);
|
//rename(mappings, two);
|
||||||
|
|
||||||
|
// for (Vertex v : g1.getVerticies())
|
||||||
|
// {
|
||||||
|
// if (v.getOther() != null)
|
||||||
|
// System.out.println(v.getObject() + " -> " + v.getOther().getOther());
|
||||||
|
// else
|
||||||
|
// System.out.println(v.getObject() + " -> unk");
|
||||||
|
// }
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JarUtil.saveJar(two, new File("d:/rs/07/adamout.jar"));
|
JarUtil.saveJar(two, new File("d:/rs/07/adamout.jar"));
|
||||||
|
|||||||
@@ -279,15 +279,86 @@ public class Vertex
|
|||||||
return il1.couldBeEqual(il2);
|
return il1.couldBeEqual(il2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean recurse = true;
|
||||||
public boolean couldBeEqual(Vertex other)
|
public boolean couldBeEqual(Vertex other)
|
||||||
{
|
{
|
||||||
assert this != other;
|
assert this != other;
|
||||||
assert graph != other.graph;
|
assert graph != other.graph;
|
||||||
assert is == null;
|
// assert is == null;
|
||||||
assert other.is == null;
|
//assert other.is == null;
|
||||||
|
|
||||||
|
if (this.getOther() != null || other.getOther() != null)
|
||||||
|
{
|
||||||
|
return this.getOther() == other && other.getOther() == this;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.getType() != other.getType())
|
if (this.getType() != other.getType())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (this.getEdges().size() != other.getEdges().size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (EdgeType e : EdgeType.values())
|
||||||
|
{
|
||||||
|
// for each edge of this type, it must be equal with just one of the others
|
||||||
|
|
||||||
|
if (this.edgesOf(e) != other.edgesOf(e))// ||
|
||||||
|
//this.solvedEdgesOfType(e) != other.solvedEdgesOfType(e))
|
||||||
|
{
|
||||||
|
int thise = edgesOf(e), othere = other.edgesOf(e);
|
||||||
|
int thisse = this.solvedEdgesOfType(e), otherse = other.solvedEdgesOfType(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// must be 1->1
|
||||||
|
// map v -> possibles
|
||||||
|
// start with the ones with the least possibilities
|
||||||
|
|
||||||
|
// if (recurse)
|
||||||
|
// {
|
||||||
|
// Set<Edge> others = new HashSet<>(other.getEdges());
|
||||||
|
// for (Edge e : edges.values())
|
||||||
|
// {
|
||||||
|
// Vertex v = e.getTo();
|
||||||
|
//
|
||||||
|
// boolean found = false;
|
||||||
|
// List<Vertex> lv = new ArrayList();
|
||||||
|
// for (Edge e2 : others)
|
||||||
|
// {
|
||||||
|
// Vertex v2 = e2.getTo();
|
||||||
|
// lv.add(v2);
|
||||||
|
//
|
||||||
|
// recurse = false;
|
||||||
|
// if (v.couldBeEqual(v2))
|
||||||
|
// // if (e.couldBeEqual(e2))
|
||||||
|
// {
|
||||||
|
// recurse = true;
|
||||||
|
// // others.remove(e2);
|
||||||
|
// found = true;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// recurse = true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!found)
|
||||||
|
// {
|
||||||
|
// Vertex v2 = null;
|
||||||
|
// for (Vertex vt : lv)
|
||||||
|
// if (vt.getObject() instanceof Method)
|
||||||
|
// {
|
||||||
|
// Method m = (Method) vt.getObject();
|
||||||
|
// if (m.getName().equals("vmethod2975"))
|
||||||
|
// {
|
||||||
|
// v2 = vt;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //v.couldBeEqual(v2);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (this.getType() == VertexType.METHOD)
|
if (this.getType() == VertexType.METHOD)
|
||||||
{
|
{
|
||||||
@@ -336,6 +407,8 @@ public class Vertex
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// compare other edges,
|
||||||
|
|
||||||
ConstantValue cf1 = (ConstantValue) f1.getAttributes().findType(AttributeType.CONSTANT_VALUE);
|
ConstantValue cf1 = (ConstantValue) f1.getAttributes().findType(AttributeType.CONSTANT_VALUE);
|
||||||
ConstantValue cf2 = (ConstantValue) f2.getAttributes().findType(AttributeType.CONSTANT_VALUE);
|
ConstantValue cf2 = (ConstantValue) f2.getAttributes().findType(AttributeType.CONSTANT_VALUE);
|
||||||
|
|
||||||
@@ -347,4 +420,18 @@ public class Vertex
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int edgesOf(EdgeType type)
|
||||||
|
{
|
||||||
|
int t = 0;
|
||||||
|
for (Edge e : this.edges.values())
|
||||||
|
if (e.getType() == type)
|
||||||
|
++t;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int solvedEdgesOfType(EdgeType type)
|
||||||
|
{
|
||||||
|
return (int) edges.values().stream().filter(e -> e.getType() == type).filter(e -> e.getTo().getOther() != null).count();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,8 +236,8 @@ public class Execution
|
|||||||
|
|
||||||
if (fi instanceof SetFieldInstruction && frame.lastField != null)
|
if (fi instanceof SetFieldInstruction && frame.lastField != null)
|
||||||
{
|
{
|
||||||
graph.addEdge(new MethodEdge(i, graph.getVertexFor(fi.getMyField()), graph.getVertexFor(frame.lastField), EdgeType.PREV_FIELD, frame.nonStatic));
|
//graph.addEdge(new MethodEdge(i, graph.getVertexFor(fi.getMyField()), graph.getVertexFor(frame.lastField), EdgeType.PREV_FIELD, frame.nonStatic));
|
||||||
graph.addEdge(new MethodEdge(i, graph.getVertexFor(frame.lastField), graph.getVertexFor(fi.getMyField()), EdgeType.PREV_FIELD_FROM, frame.nonStatic));
|
//graph.addEdge(new MethodEdge(i, graph.getVertexFor(frame.lastField), graph.getVertexFor(fi.getMyField()), EdgeType.PREV_FIELD_FROM, frame.nonStatic));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (fi instanceof SetFieldInstruction)
|
// if (fi instanceof SetFieldInstruction)
|
||||||
@@ -256,36 +256,36 @@ public class Execution
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// associated fields
|
// // associated fields
|
||||||
for (InstructionContext ic : getInsInExpr(ctx, new HashSet<>()))
|
// for (InstructionContext ic : getInsInExpr(ctx, new HashSet<>()))
|
||||||
{
|
// {
|
||||||
Instruction i2 = (Instruction) ic.getInstruction();
|
// Instruction i2 = (Instruction) ic.getInstruction();
|
||||||
|
//
|
||||||
if (i2 instanceof FieldInstruction)
|
// if (i2 instanceof FieldInstruction)
|
||||||
{
|
// {
|
||||||
FieldInstruction fi2 = (FieldInstruction) i2;
|
// FieldInstruction fi2 = (FieldInstruction) i2;
|
||||||
|
//
|
||||||
if (fi2.getMyField() == null)
|
// if (fi2.getMyField() == null)
|
||||||
continue;
|
// continue;
|
||||||
|
//
|
||||||
// these are within the context of a method
|
// // these are within the context of a method
|
||||||
graph.addEdge(new MethodEdge(i2, graph.getVertexFor(fi.getMyField()), graph.getVertexFor(fi2.getMyField()), EdgeType.FIELD_ASSOCIATION, frame.nonStatic));
|
// graph.addEdge(new MethodEdge(i2, graph.getVertexFor(fi.getMyField()), graph.getVertexFor(fi2.getMyField()), EdgeType.FIELD_ASSOCIATION, frame.nonStatic));
|
||||||
graph.addEdge(new MethodEdge(i2, graph.getVertexFor(fi2.getMyField()), graph.getVertexFor(fi.getMyField()), EdgeType.FIELD_ASSOCIATION_FROM, frame.nonStatic));
|
// graph.addEdge(new MethodEdge(i2, graph.getVertexFor(fi2.getMyField()), graph.getVertexFor(fi.getMyField()), EdgeType.FIELD_ASSOCIATION_FROM, frame.nonStatic));
|
||||||
}
|
// }
|
||||||
else if (i2 instanceof InvokeInstruction)
|
// else if (i2 instanceof InvokeInstruction)
|
||||||
{
|
// {
|
||||||
InvokeInstruction ii2 = (InvokeInstruction) i2;
|
// InvokeInstruction ii2 = (InvokeInstruction) i2;
|
||||||
|
//
|
||||||
if (ii2 instanceof InvokeStatic)
|
// if (ii2 instanceof InvokeStatic)
|
||||||
continue;
|
// continue;
|
||||||
|
//
|
||||||
for (Method m : ii2.getMethods())
|
// for (Method m : ii2.getMethods())
|
||||||
{
|
// {
|
||||||
graph.addEdge(new MethodEdge(i2, graph.getVertexFor(fi.getMyField()), graph.getVertexFor(m), EdgeType.METHOD_ASSOCIATION, frame.nonStatic));
|
// graph.addEdge(new MethodEdge(i2, graph.getVertexFor(fi.getMyField()), graph.getVertexFor(m), EdgeType.METHOD_ASSOCIATION, frame.nonStatic));
|
||||||
graph.addEdge(new MethodEdge(i2, graph.getVertexFor(m), graph.getVertexFor(fi.getMyField()), EdgeType.METHOD_ASSOCIATION_FROM, frame.nonStatic));
|
// graph.addEdge(new MethodEdge(i2, graph.getVertexFor(m), graph.getVertexFor(fi.getMyField()), EdgeType.METHOD_ASSOCIATION_FROM, frame.nonStatic));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user