public static final String GLOBALLOC = "GLOBALLOC";
- public static final String TOPLOC = "TOPLOC";
-
public static final String INTERLOC = "INTERLOC";
- public static final String PCLOC = "PCLOC";
+ public static final String PCLOC = "_PCLOC_";
- public static final String RLOC = "RLOC";
+ public static final String RLOC = "_RLOC_";
public static final Descriptor GLOBALDESC = new NameDescriptor(GLOBALLOC);
- public static final Descriptor TOPDESC = new NameDescriptor(TOPLOC);
+ public static final Descriptor TOPDESC = new NameDescriptor(SSJavaAnalysis.TOP);
+
+ public static final Descriptor BOTTOMDESC = new NameDescriptor(SSJavaAnalysis.BOTTOM);
public static final Descriptor RETURNLOC = new NameDescriptor(RLOC);
+ public static final Descriptor LITERALDESC = new NameDescriptor("LITERAL");
+
+ public static final HNode TOPHNODE = new HNode(TOPDESC);
+
+ public static final HNode BOTTOMHNODE = new HNode(BOTTOMDESC);
+
public static String newline = System.getProperty("line.separator");
LocationInfo curMethodInfo;
boolean debug = true;
- private static int locSeed = 0;
+ public static int locSeed = 0;
public LocationInference(SSJavaAnalysis ssjava, State state) {
this.ssjava = ssjava;
public void inference() {
+ ssjava.init();
+
// construct value flow graph
constructFlowGraph();
assignCompositeLocation();
+ // calculate RETURNLOC,PCLOC
+ calculateExtraLocations();
+
+ _debug_writeFlowGraph();
+
// System.exit(0);
constructHierarchyGraph();
debug_writeHierarchyDotFiles();
- // calculate RETURNLOC,PCLOC
- calculateExtraLocations();
-
simplifyHierarchyGraph();
debug_writeSimpleHierarchyDotFiles();
System.out.println("\nSSJAVA: Translate composite location assignments to flow graphs:");
MethodDescriptor methodEventLoopDesc = ssjava.getMethodContainingSSJavaLoop();
translateCompositeLocationAssignmentToFlowGraph(methodEventLoopDesc);
- _debug_printGraph();
}
private void updateCompositeLocationAssignments() {
System.out.println("---updatedCompLoc1=" + updatedCompLoc);
} else {
NTuple<Descriptor> descTuple = node.getDescTuple();
+ System.out.println("update desc=" + descTuple);
CompositeLocation compLoc = convertToCompositeLocation(md, descTuple);
compLoc = updateCompositeLocation(compLoc);
node.setCompositeLocation(compLoc);
String locName;
if (!enclosingDesc.equals(GLOBALDESC)) {
LocationSummary locSummary = getLocationSummary(enclosingDesc);
+ HierarchyGraph scGraph = getSkeletonCombinationHierarchyGraph(enclosingDesc);
+ if (scGraph != null) {
+ HNode curNode = scGraph.getCurrentHNode(nodeIdentifier);
+ if (curNode != null) {
+ nodeIdentifier = curNode.getName();
+ }
+ }
locName = locSummary.getLocationName(nodeIdentifier);
} else {
locName = nodeIdentifier;
private void translateCompositeLocationAssignmentToFlowGraph(MethodDescriptor mdCaller) {
-
// First, assign a composite location to a node in the flow graph
GlobalFlowGraph callerGlobalFlowGraph = getSubGlobalFlowGraph(mdCaller);
Set<FlowNode> nodeSet = flowGraph.getNodeSet();
for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
FlowNode node = (FlowNode) iterator.next();
- if (node.getDescTuple().startsWith(localDesc)) {
+ if (node.getDescTuple().startsWith(localDesc)
+ && !node.getDescTuple().get(0).equals(LITERALDESC)) {
// need to assign the inferred composite location to this node
CompositeLocation newCompLoc = generateCompositeLocation(node.getDescTuple(), inferCompLoc);
node.setCompositeLocation(newCompLoc);
}
}
- System.out.println("-----*AFTER TRANSLATING COMP LOC MAPPING, CALLEE MAPPING="
- + calleeGlobalGraph.getMapLocationToInferCompositeLocation());
+ // System.out.println("-----*AFTER TRANSLATING COMP LOC MAPPING, CALLEE MAPPING="
+ // + calleeGlobalGraph.getMapLocationToInferCompositeLocation());
// If the location of an argument has a composite location
// need to assign a proper composite location to the corresponding callee parameter
// inferred composite location
for (int paramIdx = 0; paramIdx < flowGraph.getNumParameters(); paramIdx++) {
FlowNode flowNode = flowGraph.getParamFlowNode(paramIdx);
- CompositeLocation inferredCompLoc = flowNode.getCompositeLocation();
+ CompositeLocation inferredCompLoc =
+ updateCompositeLocation(flowNode.getCompositeLocation());
// NTuple<Descriptor> descTuple = flowNode.getDescTuple();
//
// CompositeLocation assignedCompLoc = flowNode.getCompositeLocation();
// loc.setLocDescriptor(locDesc);
// inferredCompLoc = new CompositeLocation(loc);
// }
- System.out.println("-paramIdx=" + paramIdx + " infer=" + inferredCompLoc);
- System.out.println("-flowNode inferLoc=" + flowNode.getCompositeLocation());
+ System.out.println("-paramIdx=" + paramIdx + " infer=" + inferredCompLoc + " original="
+ + flowNode.getCompositeLocation());
Descriptor localVarDesc = flowNode.getDescTuple().get(0);
methodSummary.addMapVarNameToInferCompLoc(localVarDesc, inferredCompLoc);
Set<Descriptor> keySet = mapDescriptorToHierarchyGraph.keySet();
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
Descriptor desc = (Descriptor) iterator.next();
+ System.out.println("SSJAVA: remove redundant edges: " + desc);
HierarchyGraph simpleHierarchyGraph = getHierarchyGraph(desc).clone();
simpleHierarchyGraph.setName(desc + "_SIMPLE");
simpleHierarchyGraph.removeRedundantEdges();
- // simpleHierarchyGraph.simplifyHierarchyGraph();
mapDescriptorToSimpleHierarchyGraph.put(desc, simpleHierarchyGraph);
}
}
Set<Descriptor> keySet = mapDescriptorToHierarchyGraph.keySet();
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
Descriptor desc = (Descriptor) iterator.next();
+ System.out.println("SSJAVA: Constructing Skeleton Hierarchy Graph: " + desc);
HierarchyGraph simpleGraph = getSimpleHierarchyGraph(desc);
HierarchyGraph skeletonGraph = simpleGraph.generateSkeletonGraph();
skeletonGraph.setMapDescToHNode(simpleGraph.getMapDescToHNode());
// do fixed-point analysis
- ssjava.init();
LinkedList<MethodDescriptor> descriptorListToAnalyze = ssjava.getSortedDescriptors();
// Collections.sort(descriptorListToAnalyze, new
}
}
+ Set<Descriptor> keySet = mapDescriptorToHierarchyGraph.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ Descriptor key = (Descriptor) iterator.next();
+ HierarchyGraph graph = getHierarchyGraph(key);
+
+ Set<HNode> nodeToBeConnected = new HashSet<HNode>();
+ for (Iterator iterator2 = graph.getNodeSet().iterator(); iterator2.hasNext();) {
+ HNode node = (HNode) iterator2.next();
+ if (!node.isSkeleton() && !node.isCombinationNode()) {
+ if (graph.getIncomingNodeSet(node).size() == 0) {
+ nodeToBeConnected.add(node);
+ }
+ }
+ }
+
+ for (Iterator iterator2 = nodeToBeConnected.iterator(); iterator2.hasNext();) {
+ HNode node = (HNode) iterator2.next();
+ System.out.println("NEED TO BE CONNECTED TO TOP=" + node);
+ graph.addEdge(graph.getHNode(TOPDESC), node);
+ }
+
+ }
+
}
private HierarchyGraph getHierarchyGraph(Descriptor d) {
}
methodGraph.getHNode(GLOBALDESC).setSkeleton(true);
+ if (ssjava.getMethodContainingSSJavaLoop().equals(md)) {
+ // if the current method contains the event loop
+ // we need to set all nodes of the hierarchy graph as a skeleton node
+ Set<HNode> hnodeSet = methodGraph.getNodeSet();
+ for (Iterator iterator = hnodeSet.iterator(); iterator.hasNext();) {
+ HNode hnode = (HNode) iterator.next();
+ hnode.setSkeleton(true);
+ }
+ }
+
}
private MethodSummary getMethodSummary(MethodDescriptor md) {
if (desc instanceof MethodDescriptor) {
System.out.println("#EXTRA LOC DECLARATION GEN=" + desc);
- MethodSummary methodSummary = getMethodSummary((MethodDescriptor) desc);
+ MethodDescriptor md = (MethodDescriptor) desc;
+ MethodSummary methodSummary = getMethodSummary(md);
if (!ssjava.getMethodContainingSSJavaLoop().equals(desc)) {
TypeDescriptor returnType = ((MethodDescriptor) desc).getReturnType();
}
}
- rtr += "\n@THISLOC(\"" + methodSummary.getThisLocName() + "\")";
+ if (!md.isStatic()) {
+ rtr += "\n@THISLOC(\"" + methodSummary.getThisLocName() + "\")";
+ }
rtr += "\n@GLOBALLOC(\"" + methodSummary.getGlobalLocName() + "\")";
}
int idx =
getParamLocation(methodDefStr,
generateVarDeclaration((VarDescriptor) localVarDesc));
-
+ System.out.println("methodDefStr=" + methodDefStr + " localVarDesc=" + localVarDesc
+ + " idx=" + idx);
assert (idx != -1);
String annoatedStr =
}
- private void inferLattices() {
- }
-
private void calculateExtraLocations() {
- LinkedList<MethodDescriptor> descriptorListToAnalyze = ssjava.getSortedDescriptors();
- for (Iterator iterator = descriptorListToAnalyze.iterator(); iterator.hasNext();) {
+
+ LinkedList<MethodDescriptor> methodDescList = ssjava.getSortedDescriptors();
+ for (Iterator iterator = methodDescList.iterator(); iterator.hasNext();) {
MethodDescriptor md = (MethodDescriptor) iterator.next();
if (!ssjava.getMethodContainingSSJavaLoop().equals(md)) {
calculateExtraLocations(md);
}
}
+
}
private void checkLatticesOfVirtualMethods(MethodDescriptor md) {
// PC location is higher than location types of parameters which has incoming flows.
Set<NTuple<Location>> paramLocTupleHavingInFlowSet = new HashSet<NTuple<Location>>();
+ Set<Descriptor> paramDescNOTHavingInFlowSet = new HashSet<Descriptor>();
+ // Set<FlowNode> paramNodeNOThavingInFlowSet = new HashSet<FlowNode>();
int numParams = fg.getNumParameters();
for (int i = 0; i < numParams; i++) {
FlowNode paramFlowNode = fg.getParamFlowNode(i);
Descriptor prefix = paramFlowNode.getDescTuple().get(0);
+ NTuple<Descriptor> paramDescTuple = paramFlowNode.getCurrentDescTuple();
+ NTuple<Location> paramLocTuple = translateToLocTuple(md, paramDescTuple);
if (fg.getIncomingNodeSetByPrefix(prefix).size() > 0) {
// parameter has in-value flows
- NTuple<Descriptor> paramDescTuple = paramFlowNode.getCurrentDescTuple();
- NTuple<Location> paramLocTuple = translateToLocTuple(md, paramDescTuple);
paramLocTupleHavingInFlowSet.add(paramLocTuple);
+ } else {
+ // paramNodeNOThavingInFlowSet.add(fg.getFlowNode(paramDescTuple));
+ paramDescNOTHavingInFlowSet.add(prefix);
}
}
- System.out.println("paramLocTupleHavingInFlowSet=" + paramLocTupleHavingInFlowSet);
+ System.out.println("paramNodeNOThavingInFlowSet=" + paramDescNOTHavingInFlowSet);
if (paramLocTupleHavingInFlowSet.size() > 0
&& !coversAllParamters(md, fg, paramLocTupleHavingInFlowSet)) {
NTuple<Location> pcLocTuple =
generateLocTupleRelativeTo(md, paramLocTupleHavingInFlowSet, PCLOC);
- int pcLocTupleIdx = pcLocTuple.size() - 1;
- Location pcLoc = pcLocTuple.get(pcLocTupleIdx);
- Descriptor pcDesc = pcLoc.getLocDescriptor();
- Descriptor enclosingDesc = pcLocTuple.get(pcLocTupleIdx).getDescriptor();
+ NTuple<Descriptor> pcDescTuple = translateToDescTuple(pcLocTuple);
- HierarchyGraph hierarchyGraph = getHierarchyGraph(enclosingDesc);
- HNode pcNode = hierarchyGraph.getHNode(pcDesc);
- pcNode.setSkeleton(true);
+ // add ordering relations s.t. PCLOC is higher than all flow nodes except the set of
+ // parameters that do not have incoming flows
- for (Iterator iterator = paramLocTupleHavingInFlowSet.iterator(); iterator.hasNext();) {
- NTuple<Location> paramLocTuple = (NTuple<Location>) iterator.next();
- if (paramLocTuple.size() > pcLocTupleIdx) {
- Descriptor lowerDesc = paramLocTuple.get(pcLocTupleIdx).getLocDescriptor();
- hierarchyGraph.addEdge(pcDesc, lowerDesc);
+ for (Iterator iterator = fg.getNodeSet().iterator(); iterator.hasNext();) {
+ FlowNode node = (FlowNode) iterator.next();
+
+ if (!paramDescNOTHavingInFlowSet.contains(node.getCurrentDescTuple().get(0))) {
+ fg.addValueFlowEdge(pcDescTuple, node.getDescTuple());
}
}
- System.out.println("pcLoc=" + pcLoc);
+ System.out.println("pcLoc=" + pcLocTuple);
methodSummary.setPCLoc(new CompositeLocation(pcLocTuple));
}
System.out.println("#calculateRETURNLOC= " + md);
// calculate a return location:
// the return location type is lower than all parameters and the location of return values
-
MethodSummary methodSummary = getMethodSummary(md);
-
FlowGraph fg = getFlowGraph(md);
-
Map<Integer, CompositeLocation> mapParamToLoc = methodSummary.getMapParamIdxToInferLoc();
Set<Integer> paramIdxSet = mapParamToLoc.keySet();
// first, generate the set of return value location types that starts
// with 'this' reference
- Set<NTuple<Location>> inferFieldReturnLocSet = new HashSet<NTuple<Location>>();
-
Set<FlowNode> paramFlowNodeFlowingToReturnValueSet = getParamNodeFlowingToReturnValue(md);
System.out.println("paramFlowNodeFlowingToReturnValueSet="
+ paramFlowNodeFlowingToReturnValueSet);
- Set<NTuple<Location>> locFlowingToReturnValueSet = new HashSet<NTuple<Location>>();
+ Set<NTuple<Location>> tupleToBeHigherThanReturnLocSet = new HashSet<NTuple<Location>>();
for (Iterator iterator = paramFlowNodeFlowingToReturnValueSet.iterator(); iterator.hasNext();) {
FlowNode fn = (FlowNode) iterator.next();
-
NTuple<Descriptor> paramDescTuple = fn.getCurrentDescTuple();
- NTuple<Location> paramLocTuple = translateToLocTuple(md, paramDescTuple);
-
- locFlowingToReturnValueSet.add(paramLocTuple);
+ tupleToBeHigherThanReturnLocSet.add(translateToLocTuple(md, paramDescTuple));
}
Set<FlowNode> returnNodeSet = fg.getReturnNodeSet();
for (Iterator iterator = returnNodeSet.iterator(); iterator.hasNext();) {
FlowNode returnNode = (FlowNode) iterator.next();
NTuple<Descriptor> returnDescTuple = returnNode.getCurrentDescTuple();
- NTuple<Location> returnLocTuple = translateToLocTuple(md, returnDescTuple);
- locFlowingToReturnValueSet.add(returnLocTuple);
+ tupleToBeHigherThanReturnLocSet.add(translateToLocTuple(md, returnDescTuple));
}
- System.out.println("locFlowingToReturnValueSet=" + locFlowingToReturnValueSet);
+ System.out.println("-flow graph's returnNodeSet=" + returnNodeSet);
+ System.out.println("tupleSetToBeHigherThanReturnLoc=" + tupleToBeHigherThanReturnLocSet);
// Here, generates a return location in the method lattice that is lower than the
// locFlowingToReturnValueSet
NTuple<Location> returnLocTuple =
- generateLocTupleRelativeTo(md, locFlowingToReturnValueSet, RLOC);
+ generateLocTupleRelativeTo(md, tupleToBeHigherThanReturnLocSet, RLOC);
System.out.println("returnLocTuple=" + returnLocTuple);
- int returnLocTupleIdx = returnLocTuple.size() - 1;
- Location returnLoc = returnLocTuple.get(returnLocTupleIdx);
- Descriptor returnDesc = returnLoc.getLocDescriptor();
- Descriptor enclosingDesc = returnLocTuple.get(returnLocTupleIdx).getDescriptor();
-
- HierarchyGraph hierarchyGraph = getHierarchyGraph(enclosingDesc);
- HNode returnNode = hierarchyGraph.getHNode(returnDesc);
- returnNode.setSkeleton(true);
-
- for (Iterator iterator = locFlowingToReturnValueSet.iterator(); iterator.hasNext();) {
- NTuple<Location> locTuple = (NTuple<Location>) iterator.next();
- Descriptor higherDesc = locTuple.get(returnLocTupleIdx).getLocDescriptor();
- hierarchyGraph.addEdge(higherDesc, returnDesc);
+ NTuple<Descriptor> returnDescTuple = translateToDescTuple(returnLocTuple);
+ for (Iterator iterator = tupleToBeHigherThanReturnLocSet.iterator(); iterator.hasNext();) {
+ NTuple<Location> higherTuple = (NTuple<Location>) iterator.next();
+ fg.addValueFlowEdge(translateToDescTuple(higherTuple), returnDescTuple);
}
+ fg.getFlowNode(returnDescTuple).setSkeleton(true);
+ System.out.println("fg node set=" + fg.getNodeSet());
+
methodSummary.setRETURNLoc(new CompositeLocation(returnLocTuple));
// skip: for (Iterator iterator = returnNodeSet.iterator(); iterator.hasNext();) {
private void propagateFlowsToCallerWithNoCompositeLocation(MethodInvokeNode min,
MethodDescriptor mdCaller, MethodDescriptor mdCallee) {
-
// if the parameter A reaches to the parameter B
// then, add an edge the argument A -> the argument B to the caller's flow
// graph
if (curDescriptor instanceof VarDescriptor) {
enclosingDescriptor = md.getClassDesc();
+ } else if (curDescriptor instanceof FieldDescriptor) {
+ enclosingDescriptor = ((FieldDescriptor) curDescriptor).getClassDescriptor();
} else if (curDescriptor instanceof NameDescriptor) {
// it is "GLOBAL LOC" case!
enclosingDescriptor = GLOBALDESC;
- } else if (curDescriptor instanceof InterDescriptor) {
- enclosingDescriptor = null;
} else {
- enclosingDescriptor = ((FieldDescriptor) curDescriptor).getClassDescriptor();
+ enclosingDescriptor = null;
}
}
newImplicitTupleSet.addTupleSet(implicitFlowTupleSet);
newImplicitTupleSet.addTupleSet(condTupleNode);
- if (newImplicitTupleSet.size() > 1) {
+ if (needToGenerateInterLoc(newImplicitTupleSet)) {
// need to create an intermediate node for the GLB of conditional
// locations & implicit flows
NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
private void analyzeFlowReturnNode(MethodDescriptor md, SymbolTable nametable, ReturnNode rn,
NodeTupleSet implicitFlowTupleSet) {
+ System.out.println("-analyzeFlowReturnNode=" + rn.printNode(0));
ExpressionNode returnExp = rn.getReturnExpression();
if (returnExp != null) {
// add tuples corresponding to the current implicit flows
currentFlowTupleSet.addTupleSet(implicitFlowTupleSet);
- if (currentFlowTupleSet.size() > 1) {
+ System.out.println("---currentFlowTupleSet=" + currentFlowTupleSet);
+
+ if (needToGenerateInterLoc(currentFlowTupleSet)) {
+ System.out.println("---needToGenerateInterLoc");
FlowNode meetNode = fg.createIntermediateNode();
for (Iterator iterator = currentFlowTupleSet.iterator(); iterator.hasNext();) {
NTuple<Descriptor> currentFlowTuple = (NTuple<Descriptor>) iterator.next();
fg.addValueFlowEdge(currentFlowTuple, meetNode.getDescTuple());
}
fg.addReturnFlowNode(meetNode.getDescTuple());
- } else if (currentFlowTupleSet.size() == 1) {
- NTuple<Descriptor> tuple = currentFlowTupleSet.iterator().next();
- fg.addReturnFlowNode(tuple);
+ } else {
+ // currentFlowTupleSet = removeLiteralTuple(currentFlowTupleSet);
+ for (Iterator iterator = currentFlowTupleSet.iterator(); iterator.hasNext();) {
+ NTuple<Descriptor> currentFlowTuple = (NTuple<Descriptor>) iterator.next();
+ fg.addReturnFlowNode(currentFlowTuple);
+ }
}
}
}
+ private NodeTupleSet removeLiteralTuple(NodeTupleSet inSet) {
+ NodeTupleSet tupleSet = new NodeTupleSet();
+ for (Iterator<NTuple<Descriptor>> iter = inSet.iterator(); iter.hasNext();) {
+ NTuple<Descriptor> tuple = iter.next();
+ if (!tuple.get(0).equals(LITERALDESC)) {
+ tupleSet.addTuple(tuple);
+ }
+ }
+ return tupleSet;
+ }
+
+ private boolean needToGenerateInterLoc(NodeTupleSet tupleSet) {
+ int size = 0;
+ for (Iterator<NTuple<Descriptor>> iter = tupleSet.iterator(); iter.hasNext();) {
+ NTuple<Descriptor> descTuple = iter.next();
+ if (!descTuple.get(0).equals(LITERALDESC)) {
+ size++;
+ }
+ }
+ if (size > 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
private void analyzeFlowLoopNode(MethodDescriptor md, SymbolTable nametable, LoopNode ln,
NodeTupleSet implicitFlowTupleSet) {
newImplicitTupleSet.addTupleSet(implicitFlowTupleSet);
newImplicitTupleSet.addTupleSet(condTupleNode);
- if (newImplicitTupleSet.size() > 1) {
+ if (needToGenerateInterLoc(newImplicitTupleSet)) {
// need to create an intermediate node for the GLB of conditional
// locations & implicit flows
NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
analyzeFlowExpressionNode(md, bn.getVarTable(), ln.getCondition(), condTupleNode, null,
implicitFlowTupleSet, false);
- // ///////////
- NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ NodeTupleSet newImplicitTupleSet = new NodeTupleSet();
+ newImplicitTupleSet.addTupleSet(implicitFlowTupleSet);
+ newImplicitTupleSet.addTupleSet(condTupleNode);
- for (Iterator<NTuple<Descriptor>> idxIter = condTupleNode.iterator(); idxIter.hasNext();) {
- NTuple<Descriptor> tuple = idxIter.next();
- addFlowGraphEdge(md, tuple, interTuple);
- }
+ if (needToGenerateInterLoc(newImplicitTupleSet)) {
+ // 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);
- for (Iterator<NTuple<Descriptor>> idxIter = implicitFlowTupleSet.iterator(); idxIter
- .hasNext();) {
- NTuple<Descriptor> tuple = idxIter.next();
- addFlowGraphEdge(md, tuple, interTuple);
}
- NodeTupleSet newImplicitSet = new NodeTupleSet();
- newImplicitSet.addTuple(interTuple);
- analyzeFlowBlockNode(md, bn.getVarTable(), ln.getUpdate(), newImplicitSet);
- analyzeFlowBlockNode(md, bn.getVarTable(), ln.getBody(), newImplicitSet);
+ // ///////////
+ // NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+ //
+ // for (Iterator<NTuple<Descriptor>> idxIter = condTupleNode.iterator(); idxIter.hasNext();) {
+ // NTuple<Descriptor> tuple = idxIter.next();
+ // addFlowGraphEdge(md, tuple, interTuple);
+ // }
+ //
+ // for (Iterator<NTuple<Descriptor>> idxIter = implicitFlowTupleSet.iterator(); idxIter
+ // .hasNext();) {
+ // NTuple<Descriptor> tuple = idxIter.next();
+ // addFlowGraphEdge(md, tuple, interTuple);
+ // }
+ //
+ // NodeTupleSet newImplicitSet = new NodeTupleSet();
+ // newImplicitSet.addTuple(interTuple);
+ analyzeFlowBlockNode(md, bn.getVarTable(), ln.getUpdate(), newImplicitTupleSet);
+ analyzeFlowBlockNode(md, bn.getVarTable(), ln.getBody(), newImplicitTupleSet);
// ///////////
// condTupleNode.addTupleSet(implicitFlowTupleSet);
// System.out.println("implicitFlowTupleSet=" + implicitFlowTupleSet);
// System.out.println("newImplicitTupleSet=" + newImplicitTupleSet);
- if (newImplicitTupleSet.size() > 1) {
+ if (needToGenerateInterLoc(newImplicitTupleSet)) {
// need to create an intermediate node for the GLB of conditional locations & implicit flows
NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
// creates edges from RHS to LHS
NTuple<Descriptor> interTuple = null;
- if (nodeSetRHS.size() > 1) {
+ if (needToGenerateInterLoc(nodeSetRHS)) {
interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
}
break;
case Kind.LiteralNode:
- analyzeLiteralNode(md, nametable, (LiteralNode) en);
+ analyzeFlowLiteralNode(md, nametable, (LiteralNode) en, nodeSet);
break;
case Kind.MethodInvokeNode:
// if argument is liternal node, argTuple is set to NULL
NTuple<Descriptor> argTuple = new NTuple<Descriptor>();
- if (argTupleSet.size() > 1) {
+ if (needToGenerateInterLoc(argTupleSet)) {
NTuple<Descriptor> interTuple =
getFlowGraph(md).createIntermediateNode().getDescTuple();
for (Iterator<NTuple<Descriptor>> idxIter = argTupleSet.iterator(); idxIter.hasNext();) {
argTuple = new NTuple<Descriptor>();
}
-
addArgIdxMap(min, idx, argTuple);
FlowNode paramNode = calleeFlowGraph.getParamFlowNode(idx);
mapIdxToTuple.put(new Integer(idx), argTuple);
}
- private void analyzeLiteralNode(MethodDescriptor md, SymbolTable nametable, LiteralNode en) {
-
+ private void analyzeFlowLiteralNode(MethodDescriptor md, SymbolTable nametable, LiteralNode en,
+ NodeTupleSet nodeSet) {
+ NTuple<Descriptor> tuple = new NTuple<Descriptor>();
+ tuple.add(LITERALDESC);
+ nodeSet.addTuple(tuple);
}
private void analyzeFlowArrayAccessNode(MethodDescriptor md, SymbolTable nametable,
nodeSet.addTupleSet(expNodeTupleSet);
} else {
- nodeSet.addTupleSet(expNodeTupleSet);
- nodeSet.addTupleSet(idxNodeTupleSet);
+
+ NodeTupleSet nodeSetArrayAccessExp = new NodeTupleSet();
+
+ nodeSetArrayAccessExp.addTupleSet(expNodeTupleSet);
+ nodeSetArrayAccessExp.addTupleSet(idxNodeTupleSet);
+
+ if (needToGenerateInterLoc(nodeSetArrayAccessExp)) {
+ NTuple<Descriptor> interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
+
+ for (Iterator<NTuple<Descriptor>> iter = nodeSetArrayAccessExp.iterator(); iter.hasNext();) {
+ NTuple<Descriptor> higherTuple = iter.next();
+ addFlowGraphEdge(md, higherTuple, interTuple);
+ }
+ nodeSetArrayAccessExp.clear();
+ nodeSetArrayAccessExp.addTuple(interTuple);
+ }
+
+ nodeSet.addTupleSet(nodeSetArrayAccessExp);
}
}
private NTuple<Descriptor> analyzeFlowNameNode(MethodDescriptor md, SymbolTable nametable,
NameNode nn, NodeTupleSet nodeSet, NTuple<Descriptor> base, NodeTupleSet implicitFlowTupleSet) {
- // System.out.println("analyzeFlowNameNode=" + nn.printNode(0));
+ System.out.println("analyzeFlowNameNode=" + nn.printNode(0));
if (base == null) {
base = new NTuple<Descriptor>();
if (fd.isFinal()) {
// if it is 'static final', no need to have flow node for the TOP
// location
+ System.out.println("STATIC FINAL");
return null;
} else {
// if 'static', assign the default GLOBAL LOCATION to the first
// creates edges from RHS to LHS
NTuple<Descriptor> interTuple = null;
- if (nodeSetRHS.size() > 1) {
+ if (needToGenerateInterLoc(nodeSetRHS)) {
interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
}
String fileName = "lattice_";
if (md != null) {
fileName +=
- cd.getSymbol().replaceAll("[\\W_]", "") + "_" + md.toString().replaceAll("[\\W_]", "");
+ /* cd.getSymbol().replaceAll("[\\W_]", "") + "_" + */md.toString().replaceAll("[\\W_]", "");
} else {
fileName += cd.getSymbol().replaceAll("[\\W_]", "");
}
bw.write(locName + " [label=\"" + prettyStr + "\"]" + ";\n");
}
- public void _debug_printGraph() {
+ public void _debug_writeFlowGraph() {
Set<MethodDescriptor> keySet = mapMethodDescriptorToFlowGraph.keySet();
for (Iterator<MethodDescriptor> iterator = keySet.iterator(); iterator.hasNext();) {