squash remaining Eclipse warnings

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@700 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2007-02-09 15:33:45 +00:00
parent 8b2db1517f
commit 05e1f973a6
10 changed files with 666 additions and 724 deletions

View File

@ -10,7 +10,6 @@
*****************************************************************************/
package com.ibm.wala.cast.ipa.callgraph;
import com.ibm.wala.cast.ir.cfg.*;
import com.ibm.wala.cast.ir.ssa.*;
import com.ibm.wala.cfg.*;
@ -62,7 +61,7 @@ public class AstCallGraph extends ExplicitCallGraph {
}
class AstCGNode extends ExplicitNode {
private Set<Function> callbacks;
private Set<Function<Object,Object>> callbacks;
private AstCGNode(IMethod method, Context context) {
super(method, context);
@ -73,7 +72,7 @@ public class AstCallGraph extends ExplicitCallGraph {
boolean done = false;
while (!done) {
try {
for (Iterator<Function> x = callbacks.iterator(); x.hasNext();) {
for (Iterator<Function<Object,Object>> x = callbacks.iterator(); x.hasNext();) {
x.next().apply(null);
}
} catch (ConcurrentModificationException e) {
@ -85,17 +84,16 @@ public class AstCallGraph extends ExplicitCallGraph {
}
}
public void addCallback(Function callback) {
public void addCallback(Function<Object,Object> callback) {
if (callbacks == null)
callbacks = new HashSet<Function>(1);
callbacks = new HashSet<Function<Object,Object>>(1);
callbacks.add(callback);
}
private void fireCallbacksTransitive() {
for(Iterator<CGNode> nodes = DFS.iterateFinishTime(AstCallGraph.this, new NonNullSingletonIterator<CGNode>(this));
nodes.hasNext(); )
{
((AstCGNode)nodes.next()).fireCallbacks();
for (Iterator<CGNode> nodes = DFS.iterateFinishTime(AstCallGraph.this, new NonNullSingletonIterator<CGNode>(this)); nodes
.hasNext();) {
((AstCGNode) nodes.next()).fireCallbacks();
}
}

View File

@ -10,17 +10,25 @@
*****************************************************************************/
package com.ibm.wala.cast.ipa.callgraph;
import com.ibm.wala.cast.ir.translator.*;
import com.ibm.wala.cast.loader.AstMethod.*;
import com.ibm.wala.classLoader.*;
import com.ibm.wala.ipa.callgraph.*;
import com.ibm.wala.ipa.callgraph.propagation.*;
import com.ibm.wala.types.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import com.ibm.wala.cast.ir.translator.AstTranslator;
import com.ibm.wala.cast.loader.AstMethod.LexicalParent;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.classLoader.ProgramCounter;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKeyFactory;
import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.Trace;
import java.util.*;
abstract public class ScopeMappingInstanceKeys implements InstanceKeyFactory {
protected abstract LexicalParent[] getParents(InstanceKey base);
@ -38,7 +46,7 @@ abstract public class ScopeMappingInstanceKeys implements InstanceKeyFactory {
private final ScopeMap map;
private class ScopeMap extends HashMap {
private class ScopeMap extends HashMap<String,CGNode> {
private static final long serialVersionUID = 3645910671551712906L;

View File

@ -93,7 +93,7 @@ public abstract class AbstractSSAConversion {
protected final DominanceFrontiers<IBasicBlock> DF;
private final Graph dominatorTree;
private final Graph<IBasicBlock> dominatorTree;
protected final int[] phiCounts;
@ -111,7 +111,7 @@ public abstract class AbstractSSAConversion {
protected int valueMap[];
private Set[] assignmentMap;
private Set<SSACFG.BasicBlock>[] assignmentMap;
protected AbstractSSAConversion(IR ir, SSAOptions options) {
this.CFG = ir.getControlFlowGraph();
@ -143,6 +143,7 @@ public abstract class AbstractSSAConversion {
makeAssignmentMap();
}
@SuppressWarnings("unchecked")
private void makeAssignmentMap() {
this.assignmentMap = new Set[getMaxValueNumber() + 1];
for (Iterator BBs = CFG.iterateNodes(); BBs.hasNext();) {

View File

@ -499,7 +499,7 @@ public class SSAConversion extends AbstractSSAConversion {
protected void initializeVariables() {
for (int V = 1; V <= getMaxValueNumber(); V++) {
if (!skip(V)) {
R[V] = new Stack();
R[V] = new Stack<CopyPropagationRecord>();
}
}

View File

@ -1745,7 +1745,7 @@ public abstract class AstTranslator extends CAstVisitor {
}
}
AstLexicalInformation(Scope scope, IInstruction[] instrs, Set exposedNamesSet, Set accesses) {
AstLexicalInformation(Scope scope, IInstruction[] instrs, Set<Pair<Pair<String, String>, Integer>> exposedNamesSet, Set accesses) {
Pair[] EN = null;
if (exposedNamesSet != null) {
EN = (Pair[]) exposedNamesSet.toArray(new Pair[exposedNamesSet.size()]);
@ -1982,7 +1982,7 @@ public abstract class AstTranslator extends CAstVisitor {
}
}
private void patchLexicalAccesses(IInstruction[] instrs, Set accesses) {
private void patchLexicalAccesses(IInstruction[] instrs, Set<Access> accesses) {
Access[] AC = accesses == null ? (Access[]) null : (Access[]) accesses.toArray(new Access[accesses.size()]);
for (int i = 0; i < instrs.length; i++) {
if (instrs[i] instanceof AstLexicalAccess && ((AstLexicalAccess) instrs[i]).getAccessCount() == 0) {

View File

@ -16,59 +16,59 @@ import com.ibm.wala.util.debug.Assertions;
import java.util.*;
/**
* An implementation of a CAstControlFlowMap that is designed to be
* used by producers of CAPA asts. In addition to implementing the
* control flow map, it additionally allows clients to record control
* flow mappings in terms of some arbitrary type object that are then
* mapped to CAstNodes by the client. These objects can be anything,
* but one common use is that some type of parse tree is walked to
* build a capa ast, with control flow being recorded in terms of
* parse tree nodes and then ast nodes being mapped to parse tree
* nodes.
*
* Note that, at present, support for mapping control flow on ast
* nodes directly is clunky. It is necessary to establish that an ast
* nodes maps to itself, i.e. call xx.map(node, node).
*
* An implementation of a CAstControlFlowMap that is designed to be used by
* producers of CAPA asts. In addition to implementing the control flow map, it
* additionally allows clients to record control flow mappings in terms of some
* arbitrary type object that are then mapped to CAstNodes by the client. These
* objects can be anything, but one common use is that some type of parse tree
* is walked to build a capa ast, with control flow being recorded in terms of
* parse tree nodes and then ast nodes being mapped to parse tree nodes.
*
* Note that, at present, support for mapping control flow on ast nodes directly
* is clunky. It is necessary to establish that an ast nodes maps to itself,
* i.e. call xx.map(node, node).
*
* @author Julian Dolby (dolby@us.ibm.com)
*/
public class CAstControlFlowRecorder implements CAstControlFlowMap {
private final Map CAstToNode = new LinkedHashMap();
private final Map nodeToCAst = new LinkedHashMap();
private final Map table = new LinkedHashMap();
private final Map labelMap = new LinkedHashMap();
private final Map sourceMap = new LinkedHashMap();
private final Map<CAstNode,Object> CAstToNode = new LinkedHashMap<CAstNode,Object>();
private final Map<Object,CAstNode> nodeToCAst = new LinkedHashMap<Object,CAstNode>();
private final Map<Key,Object> table = new LinkedHashMap<Key,Object>();
private final Map<Object,Set<Object>> labelMap = new LinkedHashMap<Object,Set<Object>>();
private final Map<Object,Set<Object>> sourceMap = new LinkedHashMap<Object,Set<Object>>();
private class Key {
private final Object label;
private final Object from;
Key(Object label, Object from) {
this.from = from;
this.label = label;
}
Key(Object label, CAstNode from) {
this(label, CAstToNode.get(from));
Assertions._assert(CAstToNode.containsKey(from));
}
public int hashCode() {
public int hashCode() {
if (label != null)
return from.hashCode()*label.hashCode();
return from.hashCode() * label.hashCode();
else
return from.hashCode();
return from.hashCode();
}
public boolean equals(Object o) {
return (o instanceof Key) &&
from == ((Key)o).from &&
((label==null)?
((Key)o).label == null:
label.equals( ((Key)o).label ));
return (o instanceof Key) && from == ((Key) o).from
&& ((label == null) ? ((Key) o).label == null : label.equals(((Key) o).label));
}
}
public CAstControlFlowRecorder() {
map(EXCEPTION_TO_EXIT, EXCEPTION_TO_EXIT);
}
@ -76,62 +76,63 @@ public class CAstControlFlowRecorder implements CAstControlFlowMap {
public CAstNode getTarget(CAstNode from, Object label) {
Key key = new Key(label, from);
if (table.containsKey(key))
return (CAstNode)nodeToCAst.get( table.get(key) );
return (CAstNode) nodeToCAst.get(table.get(key));
else
return null;
}
public Collection getTargetLabels(CAstNode from) {
if (labelMap.containsKey( CAstToNode.get(from) )) {
return (Set) labelMap.get( CAstToNode.get(from) );
if (labelMap.containsKey(CAstToNode.get(from))) {
return (Set) labelMap.get(CAstToNode.get(from));
} else {
return Collections.EMPTY_SET;
}
}
public Collection getSourceNodes(CAstNode to) {
if (sourceMap.containsKey( CAstToNode.get(to) )) {
return (Set) sourceMap.get( CAstToNode.get(to) );
if (sourceMap.containsKey(CAstToNode.get(to))) {
return (Set) sourceMap.get(CAstToNode.get(to));
} else {
return Collections.EMPTY_SET;
}
}
public Collection getMappedNodes() {
Set nodes = new LinkedHashSet();
for(Iterator keys = table.keySet().iterator(); keys.hasNext(); ) {
nodes.add( (CAstNode) nodeToCAst.get( ((Key)keys.next()).from ) );
public Collection<CAstNode> getMappedNodes() {
Set<CAstNode> nodes = new LinkedHashSet<CAstNode>();
for (Iterator keys = table.keySet().iterator(); keys.hasNext();) {
nodes.add((CAstNode) nodeToCAst.get(((Key) keys.next()).from));
}
return nodes;
}
/**
* Add a control-flow edge from the `from' node to the `to' node
* with the (possibly null) label `label'. These nodes must be
* mapped by the client to CAstNodes using the `map' call; this mapping
* can happen before or after this add call.
/**
* Add a control-flow edge from the `from' node to the `to' node with the
* (possibly null) label `label'. These nodes must be mapped by the client to
* CAstNodes using the `map' call; this mapping can happen before or after
* this add call.
*/
public void add(Object from, Object to, Object label) {
table.put(new Key(label, from), to);
Set ls = (Set)labelMap.get(from);
if (ls==null) labelMap.put(from, ls=new LinkedHashSet(2));
ls.add( label );
Set<Object> ls = labelMap.get(from);
if (ls == null)
labelMap.put(from, ls = new LinkedHashSet<Object>(2));
ls.add(label);
Set ss = (Set)sourceMap.get(to);
if (ss==null) sourceMap.put(to, ss=new LinkedHashSet(2));
ss.add( from );
Set<Object> ss = sourceMap.get(to);
if (ss == null)
sourceMap.put(to, ss = new LinkedHashSet<Object>(2));
ss.add(from);
}
/**
* Establish a mapping between some object `node' and the ast node
* `ast'. Objects used a endpoints in a control flow edge must be
* mapped to ast nodes using this call.
* Establish a mapping between some object `node' and the ast node `ast'.
* Objects used a endpoints in a control flow edge must be mapped to ast nodes
* using this call.
*/
public void map(Object node, CAstNode ast) {
nodeToCAst.put(node, ast);
CAstToNode.put(ast, node);
}
}

View File

@ -18,7 +18,7 @@ import com.ibm.wala.cast.tree.*;
import java.util.*;
public class CAstNodeTypeMapRecorder
extends HashMap
extends HashMap <CAstNode,CAstType>
implements CAstNodeTypeMap
{
private static final long serialVersionUID= 7812144102027916961L;

View File

@ -33,28 +33,28 @@ public class CAstFunctions {
return null;
}
public static Iterator iterateNodes(final CAstNode tree) {
return new DFSDiscoverTimeIterator() {
public static Iterator<CAstNode> iterateNodes(final CAstNode tree) {
return new DFSDiscoverTimeIterator<CAstNode>() {
private final Map<Object, Iterator> pendingChildren = new HashMap<Object, Iterator>();
private final Map<Object, Iterator<? extends CAstNode>> pendingChildren = new HashMap<Object, Iterator<? extends CAstNode>>();
protected Iterator getPendingChildren(Object n) {
protected Iterator<? extends CAstNode> getPendingChildren(CAstNode n) {
return pendingChildren.get(n);
}
protected void setPendingChildren(Object v, Iterator iterator) {
protected void setPendingChildren(CAstNode v, Iterator<? extends CAstNode> iterator) {
pendingChildren.put(v, iterator);
}
protected Iterator getConnected(final Object n) {
return new Iterator() {
protected Iterator<CAstNode> getConnected(final CAstNode n) {
return new Iterator<CAstNode>() {
private int i = 0;
public boolean hasNext() {
return i < ((CAstNode) n).getChildCount();
}
public Object next() {
public CAstNode next() {
return ((CAstNode) n).getChild(i++);
}
@ -71,7 +71,7 @@ public class CAstFunctions {
}
public static Iterator findAll(CAstNode tree, Filter f) {
return new FilterIterator(iterateNodes(tree), f);
return new FilterIterator<CAstNode>(iterateNodes(tree), f);
}
}

View File

@ -59,6 +59,7 @@ public class CAstPattern {
return (CAstNode) get(name);
}
@SuppressWarnings("unchecked")
public List<Object> getMultiple(String name) {
if (!containsKey(name)) {
return Collections.emptyList();
@ -87,6 +88,7 @@ public class CAstPattern {
}
}
@SuppressWarnings("unchecked")
private void add(String name, CAstNode result) {
if (containsKey(name)) {
Object o = get(name);