javadoc, generics

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4145 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2011-04-22 22:59:44 +00:00
parent 06b529e146
commit d838a6c42f
4 changed files with 31 additions and 7 deletions

View File

@ -50,6 +50,7 @@ import com.ibm.wala.cast.tree.impl.CAstOperator;
import com.ibm.wala.cast.tree.impl.CAstRewriter;
import com.ibm.wala.cast.tree.impl.CAstSymbolImpl;
import com.ibm.wala.cast.tree.impl.CAstSymbolImplBase;
import com.ibm.wala.cast.tree.impl.CAstBasicRewriter.NoKey;
import com.ibm.wala.cast.tree.visit.CAstVisitor;
import com.ibm.wala.cast.types.AstTypeReference;
import com.ibm.wala.cast.util.CAstPrinter;
@ -3632,8 +3633,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle
}
}
@SuppressWarnings("unchecked")
protected CAstNode copyNodes(CAstNode root, NonCopyingContext c, Map nodeMap) {
protected CAstNode copyNodes(CAstNode root, NonCopyingContext c, Map<Pair<CAstNode,NoKey>, CAstNode> nodeMap) {
if (isMacroExpansion && root.getKind() == CAstNode.MACRO_VAR) {
int arg = ((Number) root.getChild(0).getValue()).intValue();
CAstNode expr = copyIncludeExpr(n.getChild(arg));

View File

@ -48,6 +48,6 @@ public abstract class CAstBasicRewriter
super(Ast, recursive, new NonCopyingContext());
}
protected abstract CAstNode copyNodes(CAstNode root, NonCopyingContext context, Map<Pair, CAstNode> nodeMap);
protected abstract CAstNode copyNodes(CAstNode root, NonCopyingContext context, Map<Pair<CAstNode,NoKey>, CAstNode> nodeMap);
}

View File

@ -31,12 +31,14 @@ public class CAstCloner extends CAstBasicRewriter {
this(Ast, false);
}
protected CAstNode copyNodes(CAstNode root, NonCopyingContext c, Map nodeMap) {
protected CAstNode copyNodes(CAstNode root, NonCopyingContext c, Map<Pair<CAstNode,NoKey>, CAstNode> nodeMap) {
return copyNodesHackForEclipse(root, c, nodeMap);
}
@SuppressWarnings("unchecked")
protected CAstNode copyNodesHackForEclipse(CAstNode root, NonCopyingContext c, Map nodeMap) {
/**
* what is the hack here? --MS
*/
protected CAstNode copyNodesHackForEclipse(CAstNode root, NonCopyingContext c, Map<Pair<CAstNode,NoKey>, CAstNode> nodeMap) {
if (root instanceof CAstOperator) {
nodeMap.put(Pair.make(root, c.key()), root);
return root;

View File

@ -31,6 +31,16 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.IteratorPlusOne;
import com.ibm.wala.util.collections.Pair;
/**
* Abstract superclass for types performing a rewrite operation on a CAst. The
* CAst is not mutated; instead, a new CAst is created which delegates to the
* original CAst where no transformation was performed.
*
* @param <C>
* type of the RewriteContext used when traversing the original CAst
* during the rewrite operation
* @param <K>
*/
public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K extends CAstRewriter.CopyKey<K>> {
protected static final boolean DEBUG = false;
@ -51,6 +61,10 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
};
/**
* represents a rewritten CAst
*
*/
public interface Rewrite {
CAstNode newRoot();
@ -67,6 +81,10 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
protected final CAst Ast;
/**
* for CAstEntity nodes r s.t. r.getAst() == null, should the scoped entities
* of r be rewritten?
*/
protected final boolean recursive;
protected final C rootContext;
@ -77,6 +95,10 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
this.rootContext = rootContext;
}
/**
* rewrite the CAst rooted at root, updating nodeMap with a mapping from
* (original node,key) pairs to new nodes
*/
protected abstract CAstNode copyNodes(CAstNode root, C context, Map<Pair<CAstNode, K>, CAstNode> nodeMap);
protected CAstNode flowOutTo(Map<Pair<CAstNode, K>, CAstNode> nodeMap, CAstNode oldSource, Object label, CAstNode oldTarget,
@ -89,7 +111,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
Set<CAstNode> mappedOutsideNodes = HashSetFactory.make(1);
Set<CAstNode> allNewTargetNodes = HashSetFactory.make(1);
CAstControlFlowRecorder newMap = new CAstControlFlowRecorder(newSrc);
Collection oldSources = orig.getMappedNodes();
Collection<CAstNode> oldSources = orig.getMappedNodes();
for (Iterator<Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) {
Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();