Commit a146dc5b authored by Joachim Müssig's avatar Joachim Müssig

clear up code, javadoc

parent ed2a3ac2
......@@ -58,11 +58,13 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
this.pointerAnalysis = pointerAnalysis;
}
//TODO: JavaDoc
/**
*
* generate a StateSaver without generating a new SDGProgram.
* @param sdg the {@link SDG} you want to use to generate a {@link StateSaver}
* @param pathToJar
* @param entryMethod
* @return the {@link StateSaver} object
*/
@Override
public StateSaver buildStateSaver(SDG sdg, String pathToJar, String entryMethod) {
......@@ -77,12 +79,11 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
}
saver.setCallGraph(callGraph);
saver.setPointerAnalysis(pointerAnalysis);
//TODO: sdg to cg mapping needed !
// generatePersistenceStructures(sdg, saver); //necessary ?
try {
generatePersistenceStructures(sdg, saver);
} catch (NullPointerException e) {
System.out.print(e.getStackTrace());
}
return saver;
}
......@@ -95,14 +96,11 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
for (PointerKey pk : pointerAnalysis.getPointerKeys()) {
if (pk instanceof LocalPointerKey) {
LocalPointerKey localPointerKey = (LocalPointerKey) pk;
if (!localPointerKey.isParameter()) {
continue;
}
CGNode corresCgNode = localPointerKey.getNode();
localPointerKeys.add(localPointerKey);
if (!saver.getCgNodesToPersistentCGNodes().containsKey(corresCgNode)) {
PersistentCGNode persistentCGNode = new PersistentCGNode(id);
saver.getCgNodesToPersistentCGNodes().put(corresCgNode, persistentCGNode);
......@@ -140,8 +138,6 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
}
//TODO: callGraph and pointsToAnalysis is null after this method !!!! can cause errors late in the program !
private StateSaver generateFromJson(JSONObject jsonObj, SDG sdg)
throws IOException {
StateSaver stateSaver = new StateSaver();
......@@ -193,20 +189,6 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
stateSaver.getDisjunctPointsToSets().put(keyPointerKey, disPointers);
}
//TODO : MAP SDG NODE TO CG WITH INTMAPPER AND SDG NODE TO SSA INSTRUCTION WITH INT MAPPER
//map sdg nodes from the state saver file to the corresponding cg nodes
// JSONArray nodeToCGNodeArr = jsonObj.getJSONArray(StateSaver.FORMAL_INS_TO_PERS_CG);
// for (int i = 0; i < nodeToCGNodeArr.length(); ++i) {
// JSONObject currentPair = nodeToCGNodeArr.getJSONObject(i);
// int sdgID = currentPair.getInt(StateSaver.SDG_NODE);
// SDGNode node = sdg.getNode(sdgID);
// int entryID = sdg.getEntry(node).getId();
// JSONObject persistentCGNode = currentPair.getJSONObject(StateSaver.CG_NODE);
// int cgID = persistentCGNode.getInt("cg_node_id"); //cg_node_id or id ?
// entry2CGNode.put(entryID, cgID);
// }
// sdg.setEntryToCGNode(entry2CGNode);
//
TIntIntMap entry2CGNode = new TIntIntHashMap();
JSONArray nodeToCGNodeArr = jsonObj.getJSONArray(StateSaver.ENTRY_NODES_TO_CG);
for (int i = 0; i < nodeToCGNodeArr.length(); ++i) {
......@@ -228,21 +210,17 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
}
sdg.setNode2Instr(entry2SSAIndex);
stateSaver.setNode2SSA(entry2SSAIndex);
// Iterator<CGNode> iter = callGraph.iterator();
// while (iter.hasNext()) {
// System.out.println("Generated CALLGRAPH NODE : " + iter.next().getGraphNodeId());
// }
//
// for (Integer i : stateSaver.getCgNodeIdToPersistentCGNodes().keySet()) {
// Integer cgID = stateSaver.getCgNodeIdToPersistentCGNodes().get(i).getCgNodeId();
// System.out.println("key :" + i + " cgNodeID :" + cgID);
// entry2CGNode.put(i, cgID);
// }
// sdg.setEntryToCGNode(entry2CGNode);
return stateSaver;
}
//TODO: SDG graph needs mapping to cg nodes after manual generation
/**
* generate a StateSaver from a {@link JSONObject}, which contain the necessary information.
* @param jsonObj which contain the necessary information of the state saver
* @param sdg
* @param pathToJar
* @param entryMethod
* @return
*/
public StateSaver buildSateSaverFromJson(JSONObject jsonObj, SDG sdg, String pathToJar, String entryMethod) {
if (callGraph == null) {
try {
......@@ -263,7 +241,6 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
}
try {
StateSaver stateSaver = generateFromJson(jsonObj, sdg);
//TODO: sdg to cg mapping needed !
// generatePersistenceStructures(sdg, stateSaver); //necessary ?
return stateSaver;
} catch (IOException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment