@Override public BitVectorIntSet parse(String string) throws NumberFormatException { int[] data = SparseIntSet.parseIntArray(string); BitVectorIntSet result = new BitVectorIntSet(); for (int element : data) { result.add(element); } return result; }
@Override public IntSet union(IntSet that) { BitVectorIntSet temp = new BitVectorIntSet(); temp.addAll(this); temp.addAll(that); return temp; }
private boolean isSubsetInternal(BitVectorIntSet set) { for (int i = 0; i < size; i++) { if (!set.contains(elements[i])) { return false; } } return true; }
@Override public BitVectorIntSet intersection(IntSet that) { BitVectorIntSet newbie = new BitVectorIntSet(); newbie.copySet(this); newbie.intersectWith(that); return newbie; }
@Override public boolean addAllInIntersection(IntSet other, IntSet filter) throws IllegalArgumentException { if (other == null) { throw new IllegalArgumentException("other == null"); } BitVectorIntSet o = new BitVectorIntSet(other); o.intersectWith(filter); return addAll(o); }
@Override public byte evaluate(BitVectorVariable lhs, BitVectorVariable rhs) throws IllegalArgumentException, IllegalArgumentException { if (lhs == null) { throw new IllegalArgumentException("lhs == null"); } if (rhs == null) { throw new IllegalArgumentException("rhs == null"); } BitVectorVariable U = new BitVectorVariable(); BitVectorIntSet bv = new BitVectorIntSet(); bv.addAll(rhs.getValue()); bv.removeAll(v); U.addAll(bv.getBitVector()); if (!lhs.sameValue(U)) { lhs.copyState(U); return CHANGED; } else { return NOT_CHANGED; } }
BitVectorIntSet bits = new BitVectorIntSet(); IntSet s = S.getIn(bb).getValue(); if (s != null) { bits.addAll(s); if (inst != null) { for (int j = 0; j < inst.getNumberOfDefs(); j++) { bits.remove(inst.getDef(j)); bits.add(inst.getUse(j)); return bits.getBitVector();
/** * Should be invoked when the underlying call graph has changed. This will cause certain successor and predecessor edges to be * recomputed. USE WITH EXTREME CARE. */ public void callGraphUpdated() { cgNodesVisited = new BitVectorIntSet(); cgNodesWithCallerEdges = new BitVectorIntSet(); handledCalls = new BitVectorIntSet(); handledReturns = new BitVectorIntSet(); addedSuccs = new BitVectorIntSet(); addedPreds = new BitVectorIntSet(); }
@Override public IntSet getPredNodeNumbers(CGNode node) { IntSet superR = super.getPredNodeNumbers(node); if (superR == null) { return null; } else { MutableSparseIntSet result = MutableSparseIntSet.make(superR); BitVectorIntSet allPossiblePreds = new BitVectorIntSet(superR); for (IntIterator it = superR.intIterator(); it.hasNext();) { int x = it.next(); IntSet ySet = delegateR.getRelated(x); if (ySet != null) { allPossiblePreds.addAll(ySet); } } for (IntIterator it = allPossiblePreds.intIterator(); it.hasNext();) { int y = it.next(); DelegatingCGNode yNode = (DelegatingCGNode) getNode(y); if (hasEdge(yNode, node)) { result.add(y); } } return result; } } }
/** */ private boolean addAllInIntersectionGeneral(IntSet other, IntSet filter) { BitVectorIntSet o = new BitVectorIntSet(other); o.intersectWith(filter); return addAll(o); }
private boolean addAllInternal(BitVectorIntSet set) { // should have hijacked this case before getting here! assert sharedPart != set; if (privatePart == null) { if (sharedPart == null) { copyValue(set); return !set.isEmpty(); } } BitVectorIntSet temp = makeDenseCopy(); boolean result = temp.addAll(set); copyValue(temp); return result; }
@Override public boolean isSubset(IntSet that) { if (that instanceof BitVectorIntSet) { return bitVector.isSubset(((BitVectorIntSet) that).bitVector); } else if (that instanceof SparseIntSet) { return isSubsetInternal((SparseIntSet) that); } else { // really slow. optimize as needed. for (IntIterator it = intIterator(); it.hasNext();) { int x = it.next(); if (!that.contains(x)) { return false; } } return true; } }
@Override public IntIterator intIterator() { if (privatePart == null) { return (sharedPart == null) ? EmptyIntIterator.instance() : sharedPart.intIterator(); } else { return (sharedPart == null) ? privatePart.intIterator() : new CompoundIntIterator(privatePart.intIterator(), sharedPart .intIterator()); } }
/** * internal optimized form */ private void fastForeachExcluding(BitVectorIntSet X, IntSetAction action) { int[] bits = bitVector.bits; int[] xbits = X.bitVector.bits; int w = 0; while (w < xbits.length && w < bits.length) { int b = bits[w] & ~xbits[w]; actOnWord(action, w << 5, b); w++; } while (w < bits.length) { actOnWord(action, w << 5, bits[w]); w++; } }
@Override public byte evaluate(BitVectorVariable lhs, BitVectorVariable rhs) throws IllegalArgumentException { if (rhs == null) { throw new IllegalArgumentException("rhs == null"); } if (lhs == null) { throw new IllegalArgumentException("lhs == null"); } BitVectorVariable U = new BitVectorVariable(); BitVectorIntSet bv = new BitVectorIntSet(); if (rhs.getValue() != null) { bv.addAll(rhs.getValue()); } bv.removeAll(kill); bv.addAll(gen); U.addAll(bv.getBitVector()); if (!lhs.sameValue(U)) { lhs.copyState(U); return CHANGED; } else { return NOT_CHANGED; } }
BitVectorIntSet bits = new BitVectorIntSet(); IntSet s = S.getIn(bb).getValue(); if (s != null) { bits.addAll(s); if (inst != null) { for (int j = 0; j < inst.getNumberOfDefs(); j++) { bits.remove(inst.getDef(j)); bits.add(inst.getUse(j)); return bits.getBitVector();
@Override public boolean addAllInIntersection(IntSet other, IntSet filter) throws IllegalArgumentException { if (other == null) { throw new IllegalArgumentException("other == null"); } BitVectorIntSet o = new BitVectorIntSet(other); o.intersectWith(filter); return addAll(o); }
public BitVectorKillGen(BitVector kill, BitVector gen) { if (kill == null) { throw new IllegalArgumentException("null kill"); } if (gen == null) { throw new IllegalArgumentException("null gen"); } this.kill = new BitVectorIntSet(kill); this.gen = new BitVectorIntSet(gen); }
@Override public IntSet getPredNodeNumbers(CGNode node) { IntSet superR = super.getPredNodeNumbers(node); if (superR == null) { return null; } else { MutableSparseIntSet result = MutableSparseIntSet.make(superR); BitVectorIntSet allPossiblePreds = new BitVectorIntSet(superR); for (IntIterator it = superR.intIterator(); it.hasNext();) { int x = it.next(); IntSet ySet = delegateR.getRelated(x); if (ySet != null) { allPossiblePreds.addAll(ySet); } } for (IntIterator it = allPossiblePreds.intIterator(); it.hasNext();) { int y = it.next(); DelegatingCGNode yNode = (DelegatingCGNode) getNode(y); if (hasEdge(yNode, node)) { result.add(y); } } return result; } } }