From 3754daf135b96ead63abdadce03fde42f061e3f0 Mon Sep 17 00:00:00 2001 From: egeay Date: Wed, 7 May 2008 18:25:51 +0000 Subject: [PATCH] - Added new constructor with a SDG already built. - Refactored scanForMod and scanForRef to use a transmitted ModRef instance, so that for instance CAst ModRef implementation can be used. git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2789 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- .../ibm/wala/ipa/slicer/thin/CISlicer.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/thin/CISlicer.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/thin/CISlicer.java index 6bb8dd8ee..8d96b904d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/thin/CISlicer.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/thin/CISlicer.java @@ -69,12 +69,19 @@ public class CISlicer { SDG sdg = new SDG(cg, pa, modRef, dOptions, cOptions, null); - Map> mod = scanForMod(sdg, pa); - Map> ref = scanForRef(sdg, pa); + Map> mod = scanForMod(sdg, pa, modRef); + Map> ref = scanForRef(sdg, pa, modRef); depGraph = GraphInverter.invert(new CISDG(sdg, mod, ref)); } + + public CISlicer(final SDG sdg, final PointerAnalysis pa, final ModRef modRef) { + Map> mod = scanForMod(sdg, pa, modRef); + Map> ref = scanForRef(sdg, pa, modRef); + + depGraph = GraphInverter.invert(new CISDG(sdg, mod, ref)); + } public Collection computeBackwardThinSlice(Statement seed) { Collection slice = DFS.getReachableNodes(depGraph, Collections.singleton(seed)); @@ -89,18 +96,17 @@ public class CISlicer { /** * Compute the set of pointer keys each statement mods */ - public static Map> scanForMod(SDG sdg, PointerAnalysis pa) { - return scanForMod(sdg, pa, false); + public static Map> scanForMod(SDG sdg, PointerAnalysis pa, ModRef modRef) { + return scanForMod(sdg, pa, false, modRef); } /** * Compute the set of pointer keys each statement mods. Be careful to avoid eager PDG construction here! That means .. * don't iterate over SDG statements! */ - public static Map> scanForMod(SDG sdg, PointerAnalysis pa, boolean ignoreAllocHeapDefs) { + public static Map> scanForMod(SDG sdg, PointerAnalysis pa, boolean ignoreAllocHeapDefs, ModRef modRef) { ExtendedHeapModel h = new DelegatingExtendedHeapModel(pa.getHeapModel()); Map> result = HashMapFactory.make(); - ModRef modRef = ModRef.make(); for (CGNode n : sdg.getCallGraph()) { IR ir = n.getIR(); if (ir != null) { @@ -123,10 +129,9 @@ public class CISlicer { * Compute the set of PointerKeys each statement refs.Be careful to avoid eager PDG construction here! That means .. * don't iterate over SDG statements! */ - public static Map> scanForRef(SDG sdg, PointerAnalysis pa) { + public static Map> scanForRef(SDG sdg, PointerAnalysis pa, ModRef modRef) { ExtendedHeapModel h = new DelegatingExtendedHeapModel(pa.getHeapModel()); Map> result = HashMapFactory.make(); - ModRef modRef = ModRef.make(); for (CGNode n : sdg.getCallGraph()) { IR ir = n.getIR(); if (ir != null) {