Solved methods 940, solved fields 1084, unsolved methods 173, unsolved fields 1211. also included jars i am using

This commit is contained in:
Adam
2015-11-29 20:49:03 -05:00
parent a2581e62c1
commit 5cbd36a25c
3 changed files with 129 additions and 34 deletions

View File

@@ -428,6 +428,14 @@ public class Rename2
//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
{
JarUtil.saveJar(two, new File("d:/rs/07/adamout.jar"));

View File

@@ -279,15 +279,86 @@ public class Vertex
return il1.couldBeEqual(il2);
}
private static boolean recurse = true;
public boolean couldBeEqual(Vertex other)
{
assert this != other;
assert graph != other.graph;
assert is == null;
assert other.is == null;
// assert 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())
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)
{
@@ -336,6 +407,8 @@ public class Vertex
return false;
}
// compare other edges,
ConstantValue cf1 = (ConstantValue) f1.getAttributes().findType(AttributeType.CONSTANT_VALUE);
ConstantValue cf2 = (ConstantValue) f2.getAttributes().findType(AttributeType.CONSTANT_VALUE);
@@ -347,4 +420,18 @@ public class Vertex
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();
}
}

View File

@@ -236,8 +236,8 @@ public class Execution
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(frame.lastField), graph.getVertexFor(fi.getMyField()), EdgeType.PREV_FIELD_FROM, 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));
}
// if (fi instanceof SetFieldInstruction)
@@ -256,36 +256,36 @@ public class Execution
// }
// }
// associated fields
for (InstructionContext ic : getInsInExpr(ctx, new HashSet<>()))
{
Instruction i2 = (Instruction) ic.getInstruction();
if (i2 instanceof FieldInstruction)
{
FieldInstruction fi2 = (FieldInstruction) i2;
if (fi2.getMyField() == null)
continue;
// 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(fi2.getMyField()), graph.getVertexFor(fi.getMyField()), EdgeType.FIELD_ASSOCIATION_FROM, frame.nonStatic));
}
else if (i2 instanceof InvokeInstruction)
{
InvokeInstruction ii2 = (InvokeInstruction) i2;
if (ii2 instanceof InvokeStatic)
continue;
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(m), graph.getVertexFor(fi.getMyField()), EdgeType.METHOD_ASSOCIATION_FROM, frame.nonStatic));
}
}
}
// // associated fields
// for (InstructionContext ic : getInsInExpr(ctx, new HashSet<>()))
// {
// Instruction i2 = (Instruction) ic.getInstruction();
//
// if (i2 instanceof FieldInstruction)
// {
// FieldInstruction fi2 = (FieldInstruction) i2;
//
// if (fi2.getMyField() == null)
// continue;
//
// // 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(fi2.getMyField()), graph.getVertexFor(fi.getMyField()), EdgeType.FIELD_ASSOCIATION_FROM, frame.nonStatic));
// }
// else if (i2 instanceof InvokeInstruction)
// {
// InvokeInstruction ii2 = (InvokeInstruction) i2;
//
// if (ii2 instanceof InvokeStatic)
// continue;
//
// 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(m), graph.getVertexFor(fi.getMyField()), EdgeType.METHOD_ASSOCIATION_FROM, frame.nonStatic));
// }
// }
// }
}
}