more generics
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2094 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
3e33169ecc
commit
52f13b2fc0
|
@ -28,38 +28,32 @@ public class CAstCloner extends CAstBasicRewriter {
|
|||
super(Ast, false);
|
||||
}
|
||||
|
||||
protected CAstNode copyNodes(CAstNode root,
|
||||
NonCopyingContext c,
|
||||
Map nodeMap)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
protected CAstNode copyNodes(CAstNode root, NonCopyingContext c, Map nodeMap) {
|
||||
if (root instanceof CAstOperator) {
|
||||
nodeMap.put(Pair.make(root, c.key()), root);
|
||||
return root;
|
||||
} else if (root.getValue() != null) {
|
||||
CAstNode copy = Ast.makeConstant( root.getValue() );
|
||||
Assertions._assert(! nodeMap.containsKey(root));
|
||||
CAstNode copy = Ast.makeConstant(root.getValue());
|
||||
Assertions._assert(!nodeMap.containsKey(root));
|
||||
nodeMap.put(Pair.make(root, c.key()), copy);
|
||||
return copy;
|
||||
} else {
|
||||
CAstNode newChildren[] = new CAstNode[ root.getChildCount() ];
|
||||
CAstNode newChildren[] = new CAstNode[root.getChildCount()];
|
||||
|
||||
for(int i = 0; i < root.getChildCount(); i++) {
|
||||
newChildren[i] = copyNodes(root.getChild(i), c, nodeMap);
|
||||
for (int i = 0; i < root.getChildCount(); i++) {
|
||||
newChildren[i] = copyNodes(root.getChild(i), c, nodeMap);
|
||||
}
|
||||
|
||||
CAstNode copy = Ast.makeNode(root.getKind(), newChildren);
|
||||
Assertions._assert(! nodeMap.containsKey(root));
|
||||
Assertions._assert(!nodeMap.containsKey(root));
|
||||
nodeMap.put(Pair.make(root, c.key()), copy);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
public Rewrite copy(CAstNode root,
|
||||
final CAstControlFlowMap cfg,
|
||||
final CAstSourcePositionMap pos,
|
||||
final CAstNodeTypeMap types,
|
||||
final Map<CAstNode,Collection<CAstEntity>> children)
|
||||
{
|
||||
public Rewrite copy(CAstNode root, final CAstControlFlowMap cfg, final CAstSourcePositionMap pos, final CAstNodeTypeMap types,
|
||||
final Map<CAstNode, Collection<CAstEntity>> children) {
|
||||
return rewrite(root, cfg, pos, types, children);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,8 +193,8 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
|
|||
}
|
||||
}
|
||||
|
||||
private Map copyChildren(Map nodeMap, Map children) {
|
||||
final Map newChildren = new LinkedHashMap();
|
||||
private Map<CAstNode, Collection<CAstEntity>> copyChildren(Map<CAstNode, CAstNode> nodeMap, Map<CAstNode, Collection<CAstEntity>> children) {
|
||||
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<CAstNode, Collection<CAstEntity>>();
|
||||
|
||||
for (Iterator NS = nodeMap.entrySet().iterator(); NS.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) NS.next();
|
||||
|
@ -204,7 +204,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
|
|||
CAstNode newNode = (CAstNode) entry.getValue();
|
||||
|
||||
if (children.containsKey(oldNode)) {
|
||||
Set newEntities = new LinkedHashSet();
|
||||
Set<CAstEntity> newEntities = new LinkedHashSet<CAstEntity>();
|
||||
newChildren.put(newNode, newEntities);
|
||||
for (Iterator oldEntities = ((Collection) children.get(oldNode)).iterator(); oldEntities.hasNext();) {
|
||||
newEntities.add(rewrite((CAstEntity) oldEntities.next()));
|
||||
|
@ -212,11 +212,11 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
|
|||
}
|
||||
}
|
||||
|
||||
for (Iterator keys = children.entrySet().iterator(); keys.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) keys.next();
|
||||
Object key = entry.getKey();
|
||||
for (Iterator<Map.Entry<CAstNode, Collection<CAstEntity>>> keys = children.entrySet().iterator(); keys.hasNext();) {
|
||||
Map.Entry<CAstNode, Collection<CAstEntity>> entry = keys.next();
|
||||
CAstNode key = entry.getKey();
|
||||
if (!(key instanceof CAstNode)) {
|
||||
Set newEntities = new LinkedHashSet();
|
||||
Set<CAstEntity> newEntities = new LinkedHashSet<CAstEntity>();
|
||||
newChildren.put(key, newEntities);
|
||||
for (Iterator oldEntities = ((Collection) entry.getValue()).iterator(); oldEntities.hasNext();) {
|
||||
newEntities.add(rewrite((CAstEntity) oldEntities.next()));
|
||||
|
|
Loading…
Reference in New Issue