public class BuildLattice {
private LocationInference infer;
+ private Map<HNode, TripleItem> mapSharedNodeToTripleItem;
public BuildLattice(LocationInference infer) {
this.infer = infer;
+ this.mapSharedNodeToTripleItem = new HashMap<HNode, TripleItem>();
}
public SSJavaLattice<String> buildLattice(Descriptor desc) {
// perform DFS that starts from each skeleton/combination node and ends by another
// skeleton/combination node
+ mapSharedNodeToTripleItem.clear();
+
HierarchyGraph simpleGraph = infer.getSimpleHierarchyGraph(desc);
HierarchyGraph scGraph = infer.getSkeletonCombinationHierarchyGraph(desc);
LocationSummary locSummary = infer.getLocationSummary(desc);
}
}
+ // add shared locations
+ Set<HNode> sharedNodeSet = mapSharedNodeToTripleItem.keySet();
+ for (Iterator iterator = sharedNodeSet.iterator(); iterator.hasNext();) {
+ HNode sharedNode = (HNode) iterator.next();
+ TripleItem item = mapSharedNodeToTripleItem.get(sharedNode);
+ String nonSharedLocName = mapIntermediateLoc.get(item);
+ System.out.println("sharedNode=" + sharedNode + " locName=" + nonSharedLocName);
+
+ String newLocName;
+ if (locSummary.getHNodeNameSetByLatticeLoationName(nonSharedLocName) != null
+ && !lattice.isSharedLoc(nonSharedLocName)) {
+ // need to generate a new shared location in the lattice, which is one level lower than the
+ // 'locName' location
+ newLocName = "ILOC" + (LocationInference.locSeed++);
+
+ // Set<String> aboveElementSet = getAboveElementSet(lattice, locName);
+ Set<String> belowElementSet = new HashSet<String>();
+ belowElementSet.addAll(lattice.get(nonSharedLocName));
+
+ System.out.println("nonSharedLocName=" + nonSharedLocName + " belowElementSet="
+ + belowElementSet + " newLocName=" + newLocName);
+
+ lattice.insertNewLocationBetween(nonSharedLocName, belowElementSet, newLocName);
+ } else {
+ newLocName = nonSharedLocName;
+ }
+
+ lattice.addSharedLoc(newLocName);
+ HierarchyGraph graph = infer.getSimpleHierarchyGraph(desc);
+ Set<Descriptor> descSet = graph.getDescSetOfNode(sharedNode);
+ for (Iterator iterator2 = descSet.iterator(); iterator2.hasNext();) {
+ Descriptor d = (Descriptor) iterator2.next();
+ locSummary.addMapHNodeNameToLocationName(d.getSymbol(), newLocName);
+ }
+ locSummary.addMapHNodeNameToLocationName(sharedNode.getName(), newLocName);
+
+ }
+
return lattice;
}
+ private Set<String> getAboveElementSet(SSJavaLattice<String> lattice, String loc) {
+
+ Set<String> aboveSet = new HashSet<String>();
+
+ Map<String, Set<String>> latticeMap = lattice.getTable();
+ Set<String> keySet = latticeMap.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ String key = (String) iterator.next();
+ if (latticeMap.get(key).contains(loc)) {
+ aboveSet.add(key);
+ }
+ }
+
+ return aboveSet;
+ }
+
private void expandCombinationNode(Descriptor desc, SSJavaLattice<String> lattice,
Set<HNode> visited, Map<TripleItem, String> mapIntermediateLoc, LocationSummary locSummary,
HNode cnode) {
}
String locName = mapIntermediateLoc.get(item);
-
HierarchyGraph graph = infer.getSimpleHierarchyGraph(desc);
- Set<Descriptor> descSet = graph.getDescSetOfNode(curNode);
- for (Iterator iterator = descSet.iterator(); iterator.hasNext();) {
- Descriptor d = (Descriptor) iterator.next();
- locSummary.addMapHNodeNameToLocationName(d.getSymbol(), locName);
- }
- locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName);
-
if (curNode.isSharedNode()) {
- lattice.addSharedLoc(locName);
+ // if the current node is shared location, add a shared location to the lattice later
+ mapSharedNodeToTripleItem.put(curNode, item);
+ } else {
+ Set<Descriptor> descSet = graph.getDescSetOfNode(curNode);
+ for (Iterator iterator = descSet.iterator(); iterator.hasNext();) {
+ Descriptor d = (Descriptor) iterator.next();
+ locSummary.addMapHNodeNameToLocationName(d.getSymbol(), locName);
+ }
+ locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName);
}
System.out.println("-TripleItem=" + item);
- System.out.println("-curNode=" + curNode.getName() + " locName=" + locName);
+ System.out.println("-curNode=" + curNode.getName() + " S=" + curNode.isSharedNode()
+ + " locName=" + locName);
Set<HNode> outSet = graph.getOutgoingNodeSet(curNode);
for (Iterator iterator2 = outSet.iterator(); iterator2.hasNext();) {
}
lattice.insertNewLocationBetween(above, belowSet, newLocName);
mapIntermediateLoc.put(item, newLocName);
-
}
}
+ // TODO
+ // Do we need to skip the combination node and assign a shared location to the next node?
+ // if (idx == 1 && curNode.isSharedNode()) {
+ // System.out.println("THE FIRST COMBINATION NODE EXPANSION IS SHARED!");
+ // recurDFS(desc, lattice, combinationNodeInSCGraph, endNodeSet, visited, mapIntermediateLoc,
+ // idx + 1, locSummary, curNode);
+ // return;
+ // }
+
HierarchyGraph graph = infer.getSimpleHierarchyGraph(desc);
String locName = mapIntermediateLoc.get(item);
- Set<Descriptor> descSet = graph.getDescSetOfNode(curNode);
- for (Iterator iterator = descSet.iterator(); iterator.hasNext();) {
- Descriptor d = (Descriptor) iterator.next();
- locSummary.addMapHNodeNameToLocationName(d.getSymbol(), locName);
- }
- locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName);
-
if (curNode.isSharedNode()) {
- lattice.addSharedLoc(locName);
+ // if the current node is shared location, add a shared location to the lattice later
+ mapSharedNodeToTripleItem.put(curNode, item);
+ } else {
+ Set<Descriptor> descSet = graph.getDescSetOfNode(curNode);
+ for (Iterator iterator = descSet.iterator(); iterator.hasNext();) {
+ Descriptor d = (Descriptor) iterator.next();
+ locSummary.addMapHNodeNameToLocationName(d.getSymbol(), locName);
+ }
+ locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName);
}
+
System.out.println("-TripleItem=" + item);
System.out.println("-curNode=" + curNode.getName() + " S=" + curNode.isSharedNode()
+ " locName=" + locName);
public HNode higherNode;
public Set<HNode> lowerNodeSet;
public int idx;
+ public boolean isShared;
public TripleItem(HNode h, Set<HNode> l, int i) {
higherNode = h;
lowerNodeSet = l;
idx = i;
+ isShared = false;
+ }
+
+ public void setShared(boolean in) {
+ this.isShared = in;
+ }
+
+ public boolean isShared() {
+ return isShared;
}
public int hashCode() {
h = higherNode.hashCode();
}
+ if (isShared) {
+ h++;
+ }
+
return h + lowerNodeSet.hashCode() + idx;
}
if (obj instanceof TripleItem) {
TripleItem in = (TripleItem) obj;
if ((higherNode == null || (higherNode != null && higherNode.equals(in.higherNode)))
- && lowerNodeSet.equals(in.lowerNodeSet) && idx == in.idx) {
+ && lowerNodeSet.equals(in.lowerNodeSet) && idx == in.idx && isShared == in.isShared()) {
return true;
}
}
}
public String toString() {
- return higherNode + "-" + idx + "->" + lowerNodeSet;
+ String rtr = higherNode + "-" + idx + "->" + lowerNodeSet;
+ if (isShared) {
+ rtr += " S";
+ }
+ return rtr;
}
}
private CompositeLocation checkLocationFromIfStatementNode(MethodDescriptor md,
SymbolTable nametable, IfStatementNode isn, CompositeLocation constraint) {
- System.out.println("checkLocationFromIfStatementNode=" + isn);
+ System.out.println("\n\ncheckLocationFromIfStatementNode=" + isn.printNode(0));
CompositeLocation condLoc =
checkLocationFromExpressionNode(md, nametable, isn.getCondition(), new CompositeLocation(),
constraint, false);
SymbolTable nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean isLHS) {
System.out.println("aan=" + aan.printNode(0) + " line#=" + aan.getNumLine());
ClassDescriptor cd = md.getClassDesc();
-
+ System.out.println("aan.getExpression()=" +aan.getExpression().getClass());
CompositeLocation arrayLoc =
checkLocationFromExpressionNode(md, nametable, aan.getExpression(),
new CompositeLocation(), constraint, isLHS);
-
+System.out.println("HERE?");
// addTypeLocation(aan.getExpression().getType(), arrayLoc);
CompositeLocation indexLoc =
checkLocationFromExpressionNode(md, nametable, aan.getIndex(), new CompositeLocation(),
constraint, isLHS);
// addTypeLocation(aan.getIndex().getType(), indexLoc);
+ System.out.println("HERE2?");
if (isLHS) {
if (!CompositeLattice.isGreaterThan(indexLoc, arrayLoc, generateErrorMessage(cd, aan))) {
Set<CompositeLocation> inputGLB = new HashSet<CompositeLocation>();
inputGLB.add(arrayLoc);
inputGLB.add(indexLoc);
- return CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan));
+ System.out.println("arrayLoc=" + arrayLoc + " indexLoc=" + indexLoc);
+ CompositeLocation comp =
+ CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan));
+ System.out.println("---aan=" + aan.printNode(0) + " compLoc=" + comp);
+ return comp;
}
}
private CompositeLocation checkLocationFromNameNode(MethodDescriptor md, SymbolTable nametable,
NameNode nn, CompositeLocation loc, CompositeLocation constraint) {
- System.out.println("checkLocationFromNameNode nn=" + nn.printNode(0));
+ // System.out.println("checkLocationFromNameNode nn=" + nn.printNode(0));
NameDescriptor nd = nn.getName();
if (nd.getBase() != null) {
loc =
} else if (d instanceof FieldDescriptor) {
// the type of field descriptor has a location!
FieldDescriptor fd = (FieldDescriptor) d;
- System.out.println("fd=" + fd);
+ // System.out.println("fd=" + fd);
if (fd.isStatic()) {
if (fd.isFinal()) {
// if it is 'static final', the location has TOP since no one can
private CompositeLocation checkLocationFromAssignmentNode(MethodDescriptor md,
SymbolTable nametable, AssignmentNode an, CompositeLocation loc, CompositeLocation constraint) {
+ System.out.println("\n\ncheckLocationFromAssignmentNode=" + an.printNode(0));
+
ClassDescriptor cd = md.getClassDesc();
Set<CompositeLocation> inputGLBSet = new HashSet<CompositeLocation>();
// generateErrorMessage(cd, an));
}
- // System.out.println("src=" + srcLocation + " dest=" + destLocation + " const=" +
- // constraint);
+ System.out.println("src=" + srcLocation + " dest=" + destLocation + " const=" + constraint);
if (!CompositeLattice.isGreaterThan(srcLocation, destLocation, generateErrorMessage(cd, an))) {
}
if (innerGLBInput.size() > 0) {
- System.out.println("######innerGLBInput=" + innerGLBInput);
+ // System.out.println("######innerGLBInput=" + innerGLBInput);
CompositeLocation innerGLB = CompositeLattice.calculateGLB(innerGLBInput, errMsg);
for (int idx = 0; idx < innerGLB.getSize(); idx++) {
glbCompLoc.addLocation(innerGLB.get(idx));
}
}
- System.out.println("GLB=" + glbCompLoc + "\n");
+ System.out.println("GLB=" + glbCompLoc);
return glbCompLoc;
}
Set<GlobalFlowNode> incomingNodeSetPrefix =
graph.getIncomingNodeSetByPrefix(node.getLocTuple().get(0));
- // System.out.println("---incomingNodeSetPrefix=" + incomingNodeSetPrefix);
+ System.out.println("---incomingNodeSetPrefix=" + incomingNodeSetPrefix);
Set<GlobalFlowNode> reachableNodeSetPrefix =
graph.getReachableNodeSetByPrefix(node.getLocTuple().get(0));
- // System.out.println("---reachableNodeSetPrefix=" + reachableNodeSetPrefix);
+ System.out.println("---reachableNodeSetPrefix=" + reachableNodeSetPrefix);
List<NTuple<Location>> prefixList = new ArrayList<NTuple<Location>>();
// // the type of argument is primitive.
// return nodeLocTuple.clone();
// }
+ System.out.println("paramIdx=" + paramIdx + " argDescTuple=" + argDescTuple);
NTuple<Location> argLocTuple = translateToLocTuple(mdCaller, argDescTuple);
NTuple<Location> callerLocTuple = new NTuple<Location>();
// visit each node of method flow graph
FlowGraph fg = getFlowGraph(md);
- Set<FlowNode> nodeSet = fg.getNodeSet();
+ // Set<FlowNode> nodeSet = fg.getNodeSet();
+
+ Set<FlowEdge> edgeSet = fg.getEdgeSet();
Set<Descriptor> paramDescSet = fg.getMapParamDescToIdx().keySet();
for (Iterator iterator = paramDescSet.iterator(); iterator.hasNext();) {
// for the method lattice, we need to look at the first element of
// NTuple<Descriptor>
boolean hasGlobalAccess = false;
- for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
- FlowNode originalSrcNode = (FlowNode) iterator.next();
+ // for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
+ // FlowNode originalSrcNode = (FlowNode) iterator.next();
+ for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
+ FlowEdge edge = (FlowEdge) iterator.next();
+ FlowNode originalSrcNode = fg.getFlowNode(edge.getInitTuple());
Set<FlowNode> sourceNodeSet = new HashSet<FlowNode>();
if (originalSrcNode instanceof FlowReturnNode) {
FlowReturnNode rnode = (FlowReturnNode) originalSrcNode;
sourceNodeSet.add(originalSrcNode);
}
- System.out.println("---sourceNodeSet=" + sourceNodeSet);
+ System.out.println("---sourceNodeSet=" + sourceNodeSet + " from originalSrcNode="
+ + originalSrcNode);
+
for (Iterator iterator3 = sourceNodeSet.iterator(); iterator3.hasNext();) {
FlowNode srcNode = (FlowNode) iterator3.next();
hasGlobalAccess = true;
}
- Set<FlowEdge> outEdgeSet = fg.getOutEdgeSet(originalSrcNode);
- for (Iterator iterator2 = outEdgeSet.iterator(); iterator2.hasNext();) {
- FlowEdge outEdge = (FlowEdge) iterator2.next();
- FlowNode originalDstNode = outEdge.getDst();
-
- Set<FlowNode> dstNodeSet = new HashSet<FlowNode>();
- if (originalDstNode instanceof FlowReturnNode) {
- FlowReturnNode rnode = (FlowReturnNode) originalDstNode;
- System.out.println("\n-returnNode=" + rnode);
- Set<NTuple<Descriptor>> tupleSet = rnode.getTupleSet();
- for (Iterator iterator4 = tupleSet.iterator(); iterator4.hasNext();) {
- NTuple<Descriptor> nTuple = (NTuple<Descriptor>) iterator4.next();
- dstNodeSet.add(fg.getFlowNode(nTuple));
- }
- } else {
- dstNodeSet.add(originalDstNode);
+ // Set<FlowEdge> outEdgeSet = fg.getOutEdgeSet(originalSrcNode);
+ // for (Iterator iterator2 = outEdgeSet.iterator(); iterator2.hasNext();) {
+ // FlowEdge outEdge = (FlowEdge) iterator2.next();
+ // FlowNode originalDstNode = outEdge.getDst();
+ FlowNode originalDstNode = fg.getFlowNode(edge.getEndTuple());
+
+ Set<FlowNode> dstNodeSet = new HashSet<FlowNode>();
+ if (originalDstNode instanceof FlowReturnNode) {
+ FlowReturnNode rnode = (FlowReturnNode) originalDstNode;
+ System.out.println("\n-returnNode=" + rnode);
+ Set<NTuple<Descriptor>> tupleSet = rnode.getTupleSet();
+ for (Iterator iterator4 = tupleSet.iterator(); iterator4.hasNext();) {
+ NTuple<Descriptor> nTuple = (NTuple<Descriptor>) iterator4.next();
+ dstNodeSet.add(fg.getFlowNode(nTuple));
}
- System.out.println("---dstNodeSet=" + dstNodeSet);
- for (Iterator iterator4 = dstNodeSet.iterator(); iterator4.hasNext();) {
- FlowNode dstNode = (FlowNode) iterator4.next();
-
- NTuple<Descriptor> dstNodeTuple = dstNode.getDescTuple();
- Descriptor dstLocalDesc = dstNodeTuple.get(0);
-
- if (dstLocalDesc instanceof InterDescriptor
- && ((InterDescriptor) dstLocalDesc).getMethodArgIdxPair() != null) {
- if (dstNode.getCompositeLocation() == null) {
- System.out.println("%%%%%%%%%%%%%SKIP=" + dstNode);
- continue;
- }
+ } else {
+ dstNodeSet.add(originalDstNode);
+ }
+ System.out.println("---dstNodeSet=" + dstNodeSet);
+ for (Iterator iterator4 = dstNodeSet.iterator(); iterator4.hasNext();) {
+ FlowNode dstNode = (FlowNode) iterator4.next();
+
+ NTuple<Descriptor> dstNodeTuple = dstNode.getDescTuple();
+ Descriptor dstLocalDesc = dstNodeTuple.get(0);
+
+ if (dstLocalDesc instanceof InterDescriptor
+ && ((InterDescriptor) dstLocalDesc).getMethodArgIdxPair() != null) {
+ if (dstNode.getCompositeLocation() == null) {
+ System.out.println("%%%%%%%%%%%%%SKIP=" + dstNode);
+ continue;
}
+ }
- // if (outEdge.getInitTuple().equals(srcNodeTuple)
- // && outEdge.getEndTuple().equals(dstNodeTuple)) {
+ // if (outEdge.getInitTuple().equals(srcNodeTuple)
+ // && outEdge.getEndTuple().equals(dstNodeTuple)) {
- NTuple<Descriptor> srcCurTuple = srcNode.getCurrentDescTuple();
- NTuple<Descriptor> dstCurTuple = dstNode.getCurrentDescTuple();
+ NTuple<Descriptor> srcCurTuple = srcNode.getCurrentDescTuple();
+ NTuple<Descriptor> dstCurTuple = dstNode.getCurrentDescTuple();
- System.out.println("-srcCurTuple=" + srcCurTuple + " dstCurTuple=" + dstCurTuple);
+ System.out.println("-srcCurTuple=" + srcCurTuple + " dstCurTuple=" + dstCurTuple);
- if ((srcCurTuple.size() > 1 && dstCurTuple.size() > 1)
- && srcCurTuple.get(0).equals(dstCurTuple.get(0))) {
+ if ((srcCurTuple.size() > 1 && dstCurTuple.size() > 1)
+ && srcCurTuple.get(0).equals(dstCurTuple.get(0))) {
- // value flows between fields
- Descriptor desc = srcCurTuple.get(0);
- ClassDescriptor classDesc;
+ // value flows between fields
+ Descriptor desc = srcCurTuple.get(0);
+ ClassDescriptor classDesc;
- if (desc.equals(GLOBALDESC)) {
- classDesc = md.getClassDesc();
- } else {
- VarDescriptor varDesc = (VarDescriptor) srcCurTuple.get(0);
- classDesc = varDesc.getType().getClassDesc();
- }
- extractFlowsBetweenFields(classDesc, srcNode, dstNode, 1);
+ if (desc.equals(GLOBALDESC)) {
+ classDesc = md.getClassDesc();
+ } else {
+ VarDescriptor varDesc = (VarDescriptor) srcCurTuple.get(0);
+ classDesc = varDesc.getType().getClassDesc();
+ }
+ extractFlowsBetweenFields(classDesc, srcNode, dstNode, 1);
- } else if (!srcCurTuple.get(0).equals(dstCurTuple.get(0))) {
- // value flow between local var - local var or local var - field
+ } else if ((srcCurTuple.size() == 1 && dstCurTuple.size() == 1)
+ || ((srcCurTuple.size() > 1 || dstCurTuple.size() > 1) && !srcCurTuple.get(0).equals(
+ dstCurTuple.get(0)))) {
- Descriptor srcDesc = srcCurTuple.get(0);
- Descriptor dstDesc = dstCurTuple.get(0);
+ // value flow between a primitive local var - a primitive local var or local var -
+ // field
- methodGraph.addEdge(srcDesc, dstDesc);
+ Descriptor srcDesc = srcCurTuple.get(0);
+ Descriptor dstDesc = dstCurTuple.get(0);
- if (fg.isParamDesc(srcDesc)) {
- methodGraph.setParamHNode(srcDesc);
- }
- if (fg.isParamDesc(dstDesc)) {
- methodGraph.setParamHNode(dstDesc);
- }
+ methodGraph.addEdge(srcDesc, dstDesc);
+ if (fg.isParamDesc(srcDesc)) {
+ methodGraph.setParamHNode(srcDesc);
+ }
+ if (fg.isParamDesc(dstDesc)) {
+ methodGraph.setParamHNode(dstDesc);
}
- // }
}
+ // }
+ // }
+
}
}
Descriptor srcFieldDesc = srcCurTuple.get(idx);
Descriptor dstFieldDesc = dstCurTuple.get(idx);
- // add a new edge
- getHierarchyGraph(cd).addEdge(srcFieldDesc, dstFieldDesc);
+ if (!srcFieldDesc.equals(dstFieldDesc)) {
+ // add a new edge
+ getHierarchyGraph(cd).addEdge(srcFieldDesc, dstFieldDesc);
+ }
}
}
}
if (size > 1) {
+ System.out.println("needToGenerateInterLoc=" + tupleSet + " size=" + size);
return true;
} else {
return false;
NTuple<Descriptor> interTuple = null;
if (needToGenerateInterLoc(nodeSetRHS)) {
System.out.println("3");
-
interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
}
for (Iterator<NTuple<Descriptor>> iter = nodeSetRHS.iterator(); iter.hasNext();) {
NTuple<Descriptor> fromTuple = iter.next();
+ System.out.println("fromTuple=" + fromTuple + " interTuple=" + interTuple + " tupleLSH="
+ + tupleLHS);
addFlowGraphEdge(md, fromTuple, interTuple, tupleLHS);
}
private void analyzeFlowTertiaryNode(MethodDescriptor md, SymbolTable nametable, TertiaryNode tn,
NodeTupleSet nodeSet, NodeTupleSet implicitFlowTupleSet) {
+ System.out.println("analyzeFlowTertiaryNode=" + tn.printNode(0));
+
NodeTupleSet tertiaryTupleNode = new NodeTupleSet();
analyzeFlowExpressionNode(md, nametable, tn.getCond(), tertiaryTupleNode, null,
implicitFlowTupleSet, false);
+ NodeTupleSet newImplicitTupleSet = new NodeTupleSet();
+ newImplicitTupleSet.addTupleSet(implicitFlowTupleSet);
+ newImplicitTupleSet.addTupleSet(tertiaryTupleNode);
+
+ System.out.println("$$$GGGcondTupleNode=" + tertiaryTupleNode.getGlobalLocTupleSet());
+ System.out.println("-tertiaryTupleNode=" + tertiaryTupleNode);
+ System.out.println("-implicitFlowTupleSet=" + implicitFlowTupleSet);
+ System.out.println("-newImplicitTupleSet=" + newImplicitTupleSet);
+
+ if (needToGenerateInterLoc(newImplicitTupleSet)) {
+ System.out.println("15");
+ // need to create an intermediate node for the GLB of conditional locations & implicit flows
+ NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ for (Iterator<NTuple<Descriptor>> idxIter = newImplicitTupleSet.iterator(); idxIter.hasNext();) {
+ NTuple<Descriptor> tuple = idxIter.next();
+ addFlowGraphEdge(md, tuple, interTuple);
+ }
+ newImplicitTupleSet.clear();
+ newImplicitTupleSet.addTuple(interTuple);
+ }
+
+ newImplicitTupleSet.addGlobalFlowTupleSet(tertiaryTupleNode.getGlobalLocTupleSet());
+
// add edges from tertiaryTupleNode to all nodes of conditional nodes
- tertiaryTupleNode.addTupleSet(implicitFlowTupleSet);
+ // tertiaryTupleNode.addTupleSet(implicitFlowTupleSet);
analyzeFlowExpressionNode(md, nametable, tn.getTrueExpr(), tertiaryTupleNode, null,
- implicitFlowTupleSet, false);
+ newImplicitTupleSet, false);
analyzeFlowExpressionNode(md, nametable, tn.getFalseExpr(), tertiaryTupleNode, null,
- implicitFlowTupleSet, false);
+ newImplicitTupleSet, false);
+ nodeSet.addGlobalFlowTupleSet(tertiaryTupleNode.getGlobalLocTupleSet());
nodeSet.addTupleSet(tertiaryTupleNode);
+ System.out.println("#tertiary node set=" + nodeSet);
}
private void addMapCallerMethodDescToMethodInvokeNodeSet(MethodDescriptor caller,
System.out.println("---calleeReturnSet=" + calleeReturnSet);
- // when generating the global flow graph,
- // we need to add ordering relations from the set of callee return loc tuple to LHS of the
- // caller assignment
- for (Iterator iterator = calleeReturnSet.iterator(); iterator.hasNext();) {
- FlowNode calleeReturnNode = (FlowNode) iterator.next();
- NTuple<Location> calleeReturnLocTuple =
- translateToLocTuple(mdCallee, calleeReturnNode.getDescTuple());
- nodeSet.addGlobalFlowTuple(calleeReturnLocTuple);
- }
-
NodeTupleSet tupleSet = new NodeTupleSet();
if (min.getExpression() != null) {
// propagateFlowsFromCallee(min, md, min.getMethod());
+ // when generating the global flow graph,
+ // we need to add ordering relations from the set of callee return loc tuple to LHS of the
+ // caller assignment
+ for (Iterator iterator = calleeReturnSet.iterator(); iterator.hasNext();) {
+ FlowNode calleeReturnNode = (FlowNode) iterator.next();
+ NTuple<Location> calleeReturnLocTuple =
+ translateToLocTuple(mdCallee, calleeReturnNode.getDescTuple());
+ System.out.println("calleeReturnLocTuple=" + calleeReturnLocTuple);
+ nodeSet.addGlobalFlowTuple(translateToCallerLocTuple(min, mdCallee, mdCaller,
+ calleeReturnLocTuple));
+ }
+
System.out.println("min nodeSet=" + nodeSet);
+
}
}
nodeSetArrayAccessExp.addTuple(flowFieldTuple);
nodeSetArrayAccessExp.addTupleSet(idxNodeTupleSet);
+ nodeSetArrayAccessExp.addTupleSet(nodeSet);
if (needToGenerateInterLoc(nodeSetArrayAccessExp)) {
System.out.println("4");
System.out.println("nodeSetArrayAccessExp=" + nodeSetArrayAccessExp);
- System.out.println("idxNodeTupleSet.getGlobalLocTupleSet()="
- + idxNodeTupleSet.getGlobalLocTupleSet());
+ // System.out.println("idxNodeTupleSet.getGlobalLocTupleSet()="
+ // + idxNodeTupleSet.getGlobalLocTupleSet());
NTuple<Descriptor> interTuple =
getFlowGraph(md).createIntermediateNode().getDescTuple();
NTuple<Descriptor> higherTuple = iter.next();
addFlowGraphEdge(md, higherTuple, interTuple);
}
+ nodeSet.clear();
flowFieldTuple = interTuple;
}
public void writeInferredLatticeDotFile(ClassDescriptor cd, HierarchyGraph simpleHierarchyGraph,
SSJavaLattice<String> locOrder, String nameSuffix) {
+ System.out.println("@cd=" + cd);
+ System.out.println("@sharedLoc=" + locOrder.getSharedLocSet());
writeInferredLatticeDotFile(cd, null, simpleHierarchyGraph, locOrder, nameSuffix);
}
String highLocId = pair.getFirst();
String lowLocId = pair.getSecond();
-
+ System.out.println("addedLocSet=" + addedLocSet);
if (!addedLocSet.contains(highLocId)) {
addedLocSet.add(highLocId);
drawNode(bw, locOrder, simpleHierarchyGraph, highLocId);
private void drawNode(BufferedWriter bw, SSJavaLattice<String> lattice, HierarchyGraph graph,
String locName) throws IOException {
- HNode node = graph.getHNode(locName);
-
- if (node == null) {
- return;
- }
-
String prettyStr;
if (lattice.isSharedLoc(locName)) {
prettyStr = locName + "*";
} else {
prettyStr = locName;
}
-
- if (node.isMergeNode()) {
- Set<HNode> mergeSet = graph.getMapHNodetoMergeSet().get(node);
- prettyStr += ":" + convertMergeSetToString(graph, mergeSet);
- }
+ // HNode node = graph.getHNode(locName);
+ // if (node != null && node.isMergeNode()) {
+ // Set<HNode> mergeSet = graph.getMapHNodetoMergeSet().get(node);
+ // prettyStr += ":" + convertMergeSetToString(graph, mergeSet);
+ // }
bw.write(locName + " [label=\"" + prettyStr + "\"]" + ";\n");
}