public boolean isEmpty() { return size() == 0; }
public boolean isEmpty() { return size() == 0; }
public boolean isEmpty() { return size() == 0; }
/** * @return true if the contents of two sets are equal */ public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b) { if ((a == null && b == null) || a == b || (a.mapping == b.mapping && a.S == b.S)) { return true; } assert a != null && b != null; if (a.size() == b.size()) { if (a.mapping == b.mapping || (a.mapping != null && b.mapping != null && a.mapping.equals(b.mapping))) { return a.S == b.S || (a.S != null && b.S != null && a.S.sameValue(b.S)); } } return false; }
/** * @return true if the contents of two sets are equal */ public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b) { if ((a == null && b == null) || a == b || (a.mapping == b.mapping && a.S == b.S)) { return true; } assert a != null && b != null; if (a.size() == b.size()) { if (a.mapping == b.mapping || (a.mapping != null && b.mapping != null && a.mapping.equals(b.mapping))) { return a.S == b.S || (a.S != null && b.S != null && a.S.sameValue(b.S)); } } return false; }
/** * @return true if the contents of two sets are equal */ public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b) { if ((a == null && b == null) || a == b || (a.mapping == b.mapping && a.S == b.S)) { return true; } assert a != null && b != null; if (a.size() == b.size()) { if (a.mapping == b.mapping || (a.mapping != null && b.mapping != null && a.mapping.equals(b.mapping))) { return a.S == b.S || (a.S != null && b.S != null && a.S.sameValue(b.S)); } } return false; }
/** * @return a new OrdinalSet instances * @throws IllegalArgumentException if A is null */ public static <T> OrdinalSet<T> intersect(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null || B.S == null) { return new OrdinalSet<>(null, A.mapping); } IntSet isect = A.S.intersection(B.S); return new OrdinalSet<>(isect, A.mapping); }
/** * @return a new OrdinalSet instances * @throws IllegalArgumentException if A is null */ public static <T> OrdinalSet<T> intersect(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null || B.S == null) { return new OrdinalSet<>(null, A.mapping); } IntSet isect = A.S.intersection(B.S); return new OrdinalSet<>(isect, A.mapping); }
/** * @return a new OrdinalSet instances * @throws IllegalArgumentException if A is null */ public static <T> OrdinalSet<T> intersect(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null || B.S == null) { return new OrdinalSet<>(null, A.mapping); } IntSet isect = A.S.intersection(B.S); return new OrdinalSet<>(isect, A.mapping); }
/** * Creates the union of two ordinal sets. * * @param A ordinal set a * @param B ordinal set b * @return union of a and b * @throws IllegalArgumentException iff A or B is null */ public static <T> OrdinalSet<T> unify(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (B == null) { throw new IllegalArgumentException("B is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null) { return (B.S == null) ? OrdinalSet.<T> empty() : new OrdinalSet<>(B.S, B.mapping); } else if (B.S == null) { return new OrdinalSet<>(A.S, A.mapping); } IntSet union = A.S.union(B.S); return new OrdinalSet<>(union, A.mapping); }
/** * Creates the union of two ordinal sets. * * @param A ordinal set a * @param B ordinal set b * @return union of a and b * @throws IllegalArgumentException iff A or B is null */ public static <T> OrdinalSet<T> unify(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (B == null) { throw new IllegalArgumentException("B is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null) { return (B.S == null) ? OrdinalSet.<T> empty() : new OrdinalSet<>(B.S, B.mapping); } else if (B.S == null) { return new OrdinalSet<>(A.S, A.mapping); } IntSet union = A.S.union(B.S); return new OrdinalSet<>(union, A.mapping); }
/** * Creates the union of two ordinal sets. * * @param A ordinal set a * @param B ordinal set b * @return union of a and b * @throws IllegalArgumentException iff A or B is null */ public static <T> OrdinalSet<T> unify(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (B == null) { throw new IllegalArgumentException("B is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null) { return (B.S == null) ? OrdinalSet.<T> empty() : new OrdinalSet<>(B.S, B.mapping); } else if (B.S == null) { return new OrdinalSet<>(A.S, A.mapping); } IntSet union = A.S.union(B.S); return new OrdinalSet<>(union, A.mapping); }
Assert.assertEquals(2, readVars.size()); Assert.assertEquals("[[Node: <Code body of function Ltests/simple-lexical.js/outer> Context: Everywhere,x], [Node: <Code body of function Ltests/simple-lexical.js/outer> Context: Everywhere,z]]", readVars.toString()); Assert.assertEquals(2, writtenVars.size()); Assert.assertEquals("[[Node: <Code body of function Ltests/simple-lexical.js/outer> Context: Everywhere,x], [Node: <Code body of function Ltests/simple-lexical.js/outer> Context: Everywhere,z]]", writtenVars.toString()); Assert.assertEquals(4, readVars.size()); for(Pair<CGNode, String> rv : readVars) { Assert.assertTrue(rv.toString(),
PointerKey P = (PointerKey) N; OrdinalSet<T> S = getPointerAnalysis().getPointsToSet(P); int[] result = new int[S.size()]; int i = 0; for (T t : S) {
PointerKey P = (PointerKey) N; OrdinalSet<T> S = getPointerAnalysis().getPointsToSet(P); int[] result = new int[S.size()]; int i = 0; for (T t : S) {
@Test public void testZeroLengthArray() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.ZERO_LENGTH_ARRAY_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis(); // System.err.println(pa); HeapModel heapModel = pa.getHeapModel(); CGNode mainNode = cg.getNode( cha.resolveMethod(MethodReference.findOrCreate( TypeReference.findOrCreate(ClassLoaderReference.Application, TestConstants.ZERO_LENGTH_ARRAY_MAIN), Selector.make("main([Ljava/lang/String;)V"))), Everywhere.EVERYWHERE); OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(heapModel.getPointerKeyForLocal(mainNode, 4)); Assert.assertEquals(1, pointsToSet.size()); InstanceKey arrayKey = pointsToSet.iterator().next(); OrdinalSet<InstanceKey> arrayContents = pa.getPointsToSet(heapModel.getPointerKeyForArrayContents(arrayKey)); System.err.println(arrayContents); Assert.assertEquals(0, arrayContents.size()); } }
@Test public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util .makeMainEntrypoints(scope, cha, TestConstants.MULTI_DIM_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(),cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis(); CGNode node = findDoNothingNode(cg); PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node, 1); OrdinalSet<InstanceKey> ptsTo = pa.getPointsToSet(pk); Assert.assertEquals(1, ptsTo.size()); }
@Test public void testZeroOneContainerCopyOf() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(scope, cha, "Ldemandpa/TestArraysCopyOf"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); IAnalysisCacheView cache = new AnalysisCacheImpl(); CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis(); CGNode mainMethod = AbstractPtrTest.findMainMethod(cg); PointerKey keyToQuery = AbstractPtrTest.getParam(mainMethod, "testThisVar", pa.getHeapModel()); OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(keyToQuery); Assert.assertEquals(1, pointsToSet.size()); } /**