C - type of the RewriteContext used when traversing the original CAst during the rewrite
operationK - a key used to ease cloning of partial ASTs. When rewriting an AST, sub-classes
maintain a mapping from (original node, key) pairs (where key is of type K) to new nodes; see
copyNodes(com.ibm.wala.cast.tree.CAstNode, com.ibm.wala.cast.tree.CAstControlFlowMap, C, java.util.Map<com.ibm.wala.util.collections.Pair<com.ibm.wala.cast.tree.CAstNode, K>, com.ibm.wala.cast.tree.CAstNode>)public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>,K extends CAstRewriter.CopyKey<K>>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
CAstRewriter.CopyKey<Self extends CAstRewriter.CopyKey<Self>>
interface to be implemented by keys used for cloning sub-trees during the rewrite
|
static interface |
CAstRewriter.Rewrite
represents a rewritten CAst
|
static interface |
CAstRewriter.RewriteContext<K extends CAstRewriter.CopyKey<K>>
interface to be implemented by contexts used while traversing the AST
|
| Modifier and Type | Field and Description |
|---|---|
protected CAst |
Ast |
protected static boolean |
DEBUG |
protected boolean |
recursive
for CAstEntity nodes r s.t.
|
protected C |
rootContext |
| Constructor and Description |
|---|
CAstRewriter(CAst Ast,
boolean recursive,
C rootContext) |
| Modifier and Type | Method and Description |
|---|---|
protected java.util.Map<CAstNode,java.util.Collection<CAstEntity>> |
copyChildren(CAstNode root,
java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap,
java.util.Map<CAstNode,java.util.Collection<CAstEntity>> children) |
protected java.util.List<CAstNode> |
copyChildrenArray(CAstNode n,
CAstControlFlowMap cfg,
C context,
java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap) |
protected java.util.List<CAstNode> |
copyChildrenArrayAndTargets(CAstNode n,
CAstControlFlowMap cfg,
C context,
java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap) |
protected CAstControlFlowMap |
copyFlow(java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap,
CAstControlFlowMap orig,
CAstSourcePositionMap newSrc)
create a control-flow map for the rewritten tree, given the mapping from (original node, copy
key) pairs ot new nodes and the original control-flow map.
|
protected abstract CAstNode |
copyNodes(CAstNode root,
CAstControlFlowMap cfg,
C context,
java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap)
rewrite the CAst rooted at root under some context, returning the node at the root of the
rewritten tree.
|
protected CAstSourcePositionMap |
copySource(java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap,
CAstSourcePositionMap orig) |
protected CAstNode |
copySubtreesIntoNewNode(CAstNode n,
CAstControlFlowMap cfg,
C c,
java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap) |
protected CAstNode |
copySubtreesIntoNewNode(CAstNode n,
CAstControlFlowMap cfg,
C c,
java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap,
com.ibm.wala.util.collections.Pair<CAstNode,K> pairKey) |
protected CAstNodeTypeMap |
copyTypes(java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap,
CAstNodeTypeMap orig) |
protected CAstNode |
flowOutTo(java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap,
CAstNode oldSource,
java.lang.Object label,
CAstNode oldTarget,
CAstControlFlowMap orig,
CAstSourcePositionMap src)
in
copyFlow(Map, CAstControlFlowMap, CAstSourcePositionMap), if the source of some
original CFG edge is replicated, but we find no replica for the target, what node should be the
target of the CFG edge in the rewritten AST? By default, just uses the original target. |
CAstEntity |
rewrite(CAstEntity root)
perform the rewrite on a
CAstEntity, returning the new CAstEntity as the result |
CAstRewriter.Rewrite |
rewrite(CAstNode root,
CAstControlFlowMap cfg,
CAstSourcePositionMap pos,
CAstNodeTypeMap types,
java.util.Map<CAstNode,java.util.Collection<CAstEntity>> children,
CAstNode[] defaults)
rewrite the CAst sub-tree rooted at root
|
protected static final boolean DEBUG
protected final CAst Ast
protected final boolean recursive
protected final C extends CAstRewriter.RewriteContext<K> rootContext
protected abstract CAstNode copyNodes(CAstNode root, CAstControlFlowMap cfg, C context, java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap)
protected CAstNode copySubtreesIntoNewNode(CAstNode n, CAstControlFlowMap cfg, C c, java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap)
protected CAstNode copySubtreesIntoNewNode(CAstNode n, CAstControlFlowMap cfg, C c, java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap, com.ibm.wala.util.collections.Pair<CAstNode,K> pairKey)
protected java.util.List<CAstNode> copyChildrenArray(CAstNode n, CAstControlFlowMap cfg, C context, java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap)
protected java.util.List<CAstNode> copyChildrenArrayAndTargets(CAstNode n, CAstControlFlowMap cfg, C context, java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap)
protected CAstNode flowOutTo(java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap, CAstNode oldSource, java.lang.Object label, CAstNode oldTarget, CAstControlFlowMap orig, CAstSourcePositionMap src)
copyFlow(Map, CAstControlFlowMap, CAstSourcePositionMap), if the source of some
original CFG edge is replicated, but we find no replica for the target, what node should be the
target of the CFG edge in the rewritten AST? By default, just uses the original target.protected CAstControlFlowMap copyFlow(java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap, CAstControlFlowMap orig, CAstSourcePositionMap newSrc)
protected CAstSourcePositionMap copySource(java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap, CAstSourcePositionMap orig)
protected CAstNodeTypeMap copyTypes(java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap, CAstNodeTypeMap orig)
protected java.util.Map<CAstNode,java.util.Collection<CAstEntity>> copyChildren(CAstNode root, java.util.Map<com.ibm.wala.util.collections.Pair<CAstNode,K>,CAstNode> nodeMap, java.util.Map<CAstNode,java.util.Collection<CAstEntity>> children)
public CAstRewriter.Rewrite rewrite(CAstNode root, CAstControlFlowMap cfg, CAstSourcePositionMap pos, CAstNodeTypeMap types, java.util.Map<CAstNode,java.util.Collection<CAstEntity>> children, CAstNode[] defaults)
public CAstEntity rewrite(CAstEntity root)
CAstEntity, returning the new CAstEntity as the result