/** * Remove all local bindings (except ret). This info is indeed superfluous on summary purity graphs representing the effect * of a method. This saves a little memory, but also, simplify summary graph drawings a lot! * * DO NOT USE DURING INTRA-PROCEDURAL ANALYSIS! */ void removeLocals() { locals = new HashMultiMap(); backLocals = new HashMultiMap(); }
@Override public boolean put(K key, V value) { return findSet(key).add(value); }
@Override public boolean equals(Object o) { if (!(o instanceof MultiMap)) { return false; } @SuppressWarnings("unchecked") MultiMap<K, V> mm = (MultiMap<K, V>) o; if (!keySet().equals(mm.keySet())) { return false; } Iterator<Map.Entry<K, Set<V>>> it = m.entrySet().iterator(); while (it.hasNext()) { Map.Entry<K, Set<V>> e = it.next(); Set<V> s = e.getValue(); if (!s.equals(mm.get(e.getKey()))) { return false; } } return true; }
public HashMultiMap( MultiMap m ) { putAll( m ); } public void putAll( MultiMap m ) {
for (Iterator iter = callAssigns.keySet().iterator(); iter.hasNext();) { InvokeExpr ie = (InvokeExpr) iter.next(); Integer callSite = new Integer(callSiteNum++); receiverToVirtCallSites.put(receiver, callSite); Set curEdges = callAssigns.get(ie); for (Iterator iterator = curEdges.iterator(); iterator.hasNext();) { Pair callAssign = (Pair) iterator.next();
private Set<V> findSet(K key) { Set<V> s = m.get(key); if (s == null) { s = newSet(); m.put(key, s); } return s; }
public boolean isEmpty() { return numKeys() == 0; } public int numKeys() {
public HashMultiMap( MultiMap m ) { putAll( m ); } public void putAll( MultiMap m ) {
private Set findSet( Object key ) { Set s = m.get( key ); if( s == null ) { s = newSet(); m.put( key, s ); } return s; } public boolean put( Object key, Object value ) {
public boolean isEmpty() { return numKeys() == 0; } public int numKeys() {
public void copyFrom(Fact in) { varToStmt = new HashMap<Local, Stmt>(in.varToStmt); stmtToVar = new HashMultiMap<Stmt, Local>(in.stmtToVar); alloc = in.alloc; }
@Override public boolean putAll(K key, Set<V> values) { if (values.isEmpty()) { return false; } return findSet(key).addAll(values); }
public void putAll( MultiMap m ) { Iterator it = m.keySet().iterator(); while( it.hasNext() ) { Object o = it.next(); putAll( o, m.get( o ) ); } } public boolean isEmpty() {
private Set findSet( Object key ) { Set s = m.get( key ); if( s == null ) { s = newSet(); m.put( key, s ); } return s; } public boolean put( Object key, Object value ) {
public boolean equals( Object o ) { if( ! (o instanceof MultiMap) ) return false; MultiMap mm = (MultiMap) o; if( !keySet().equals( mm.keySet() ) ) return false; Iterator it = m.entrySet().iterator(); while( it.hasNext() ) { Map.Entry e = (Map.Entry) it.next(); Set s = (Set) e.getValue(); if( !s.equals( mm.get( e.getKey() ) ) ) return false; } return true; } public int hashCode() {
/** * Copy constructor. */ PurityGraph(PurityGraph x) { nodes = new HashSet(x.nodes); paramNodes = new HashSet(x.paramNodes); edges = new HashMultiMap(x.edges); locals = new HashMultiMap(x.locals); ret = new HashSet(x.ret); globEscape = new HashSet(x.globEscape); backEdges = new HashMultiMap(x.backEdges); backLocals = new HashMultiMap(x.backLocals); mutated = new HashMultiMap(x.mutated); if (doCheck) { sanityCheck(); } }
public boolean put( Object key, Object value ) { return findSet( key ).add( value ); } public boolean putAll( Object key, Set values ) {
public void putAll( MultiMap m ) { Iterator it = m.keySet().iterator(); while( it.hasNext() ) { Object o = it.next(); putAll( o, m.get( o ) ); } } public boolean isEmpty() {