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

clear up code, javadoc

parent ed2a3ac2
...@@ -58,11 +58,13 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume ...@@ -58,11 +58,13 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
this.pointerAnalysis = pointerAnalysis; 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 @Override
public StateSaver buildStateSaver(SDG sdg, String pathToJar, String entryMethod) { public StateSaver buildStateSaver(SDG sdg, String pathToJar, String entryMethod) {
...@@ -77,12 +79,11 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume ...@@ -77,12 +79,11 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
} }
saver.setCallGraph(callGraph); saver.setCallGraph(callGraph);
saver.setPointerAnalysis(pointerAnalysis); saver.setPointerAnalysis(pointerAnalysis);
//TODO: sdg to cg mapping needed !
// generatePersistenceStructures(sdg, saver); //necessary ? // generatePersistenceStructures(sdg, saver); //necessary ?
try { try {
generatePersistenceStructures(sdg, saver); generatePersistenceStructures(sdg, saver);
} catch (NullPointerException e) { } catch (NullPointerException e) {
System.out.print(e.getStackTrace());
} }
return saver; return saver;
} }
...@@ -95,14 +96,11 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume ...@@ -95,14 +96,11 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
for (PointerKey pk : pointerAnalysis.getPointerKeys()) { for (PointerKey pk : pointerAnalysis.getPointerKeys()) {
if (pk instanceof LocalPointerKey) { if (pk instanceof LocalPointerKey) {
LocalPointerKey localPointerKey = (LocalPointerKey) pk; LocalPointerKey localPointerKey = (LocalPointerKey) pk;
if (!localPointerKey.isParameter()) { if (!localPointerKey.isParameter()) {
continue; continue;
} }
CGNode corresCgNode = localPointerKey.getNode(); CGNode corresCgNode = localPointerKey.getNode();
localPointerKeys.add(localPointerKey); localPointerKeys.add(localPointerKey);
if (!saver.getCgNodesToPersistentCGNodes().containsKey(corresCgNode)) { if (!saver.getCgNodesToPersistentCGNodes().containsKey(corresCgNode)) {
PersistentCGNode persistentCGNode = new PersistentCGNode(id); PersistentCGNode persistentCGNode = new PersistentCGNode(id);
saver.getCgNodesToPersistentCGNodes().put(corresCgNode, persistentCGNode); saver.getCgNodesToPersistentCGNodes().put(corresCgNode, persistentCGNode);
...@@ -140,8 +138,6 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume ...@@ -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) private StateSaver generateFromJson(JSONObject jsonObj, SDG sdg)
throws IOException { throws IOException {
StateSaver stateSaver = new StateSaver(); StateSaver stateSaver = new StateSaver();
...@@ -193,20 +189,6 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume ...@@ -193,20 +189,6 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
stateSaver.getDisjunctPointsToSets().put(keyPointerKey, disPointers); 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(); TIntIntMap entry2CGNode = new TIntIntHashMap();
JSONArray nodeToCGNodeArr = jsonObj.getJSONArray(StateSaver.ENTRY_NODES_TO_CG); JSONArray nodeToCGNodeArr = jsonObj.getJSONArray(StateSaver.ENTRY_NODES_TO_CG);
for (int i = 0; i < nodeToCGNodeArr.length(); ++i) { for (int i = 0; i < nodeToCGNodeArr.length(); ++i) {
...@@ -228,21 +210,17 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume ...@@ -228,21 +210,17 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
} }
sdg.setNode2Instr(entry2SSAIndex); sdg.setNode2Instr(entry2SSAIndex);
stateSaver.setNode2SSA(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; 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) { public StateSaver buildSateSaverFromJson(JSONObject jsonObj, SDG sdg, String pathToJar, String entryMethod) {
if (callGraph == null) { if (callGraph == null) {
try { try {
...@@ -263,7 +241,6 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume ...@@ -263,7 +241,6 @@ public class StateSaverCGConsumerBuilder implements StateSaverBuilder, CGConsume
} }
try { try {
StateSaver stateSaver = generateFromJson(jsonObj, sdg); StateSaver stateSaver = generateFromJson(jsonObj, sdg);
//TODO: sdg to cg mapping needed !
// generatePersistenceStructures(sdg, stateSaver); //necessary ? // generatePersistenceStructures(sdg, stateSaver); //necessary ?
return stateSaver; return stateSaver;
} catch (IOException e) { } catch (IOException e) {
......
Supports Markdown
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