Class CAstRewriterExt
java.lang.Object
com.ibm.wala.cast.tree.rewrite.CAstRewriter<NodePos, CAstBasicRewriter.NoKey>
com.ibm.wala.cast.js.ipa.callgraph.correlations.extraction.CAstRewriterExt
- Direct Known Subclasses:
ClosureExtractor
Extension of
CAstRewriter which allows adding or deleting control flow edges, and keeps
track of the current entity.
TODO: This class is an unholy mess. It should be restructured considerably.
- Author:
- mschaefer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA control flow edge to be added to the CFG.Nested classes/interfaces inherited from class CAstRewriter
CAstRewriter.CopyKey<Self>, CAstRewriter.Rewrite, CAstRewriter.RewriteContext<K>Modifier and TypeClassDescriptionstatic interfaceCAstRewriter.CopyKey<Self extends CAstRewriter.CopyKey<Self>>interface to be implemented by keys used for cloning sub-trees during the rewritestatic interfacerepresents a rewritten CAststatic interfaceCAstRewriter.RewriteContext<K extends CAstRewriter.CopyKey<K>>interface to be implemented by contexts used while traversing the AST -
Field Summary
Fields inherited from class CAstRewriter
Ast, DEBUG, recursive, rootContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntity(CAstNode anchor, CAstEntity entity) addFlow(CAstNode node, Object label, CAstNode target, CAstControlFlowMap flow) addNode(CAstNode node, CAstControlFlowMap flow) protected Map<CAstNode, Collection<CAstEntity>> copyChildren(CAstNode root, Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap, Map<CAstNode, Collection<CAstEntity>> children) protected CAstControlFlowMapcopyFlow(Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, @NonNull 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.voiddeleteFlow(CAstNode node, CAstEntity entity) protected voidenterEntity(CAstEntity entity) protected CAstNodeflowOutTo(Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap, CAstNode oldSource, Object label, CAstNode oldTarget, CAstControlFlowMap orig, CAstSourcePositionMap src) inCAstRewriter.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 booleanisFlowDeleted(CAstNode node, CAstEntity entity) protected voidrewrite(CAstEntity root) perform the rewrite on aCAstEntity, returning the newCAstEntityas the resultMethods inherited from class CAstRewriter
copyChildrenArray, copyChildrenArrayAndTargets, copyNodes, copySource, copySubtreesIntoNewNode, copySubtreesIntoNewNode, copyTypes, rewriteModifier and TypeMethodDescriptioncopyChildrenArray(CAstNode n, CAstControlFlowMap cfg, NodePos context, Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap) copyChildrenArrayAndTargets(CAstNode n, CAstControlFlowMap cfg, NodePos context, Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap) protected abstract CAstNodecopyNodes(CAstNode root, CAstControlFlowMap cfg, NodePos context, Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap) rewrite the CAst rooted at root under some context, returning the node at the root of the rewritten tree.protected CAstSourcePositionMapcopySource(Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap, CAstSourcePositionMap orig) protected CAstNodecopySubtreesIntoNewNode(CAstNode n, CAstControlFlowMap cfg, NodePos c, Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap) protected CAstNodecopySubtreesIntoNewNode(CAstNode n, CAstControlFlowMap cfg, NodePos c, Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap, Pair<CAstNode, CAstBasicRewriter.NoKey> pairKey) protected CAstNodeTypeMapcopyTypes(Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap, CAstNodeTypeMap orig) rewrite(CAstNode root, CAstControlFlowMap cfg, CAstSourcePositionMap pos, CAstNodeTypeMap types, Map<CAstNode, Collection<CAstEntity>> children, CAstNode[] defaults) rewrite the CAst sub-tree rooted at root
-
Constructor Details
-
CAstRewriterExt
-
-
Method Details
-
addNode
-
addFlow
-
deleteFlow
-
isFlowDeleted
-
getCurrentEntity
-
getEnclosingEntities
-
addEntity
-
copyChildren
protected Map<CAstNode, Collection<CAstEntity>> copyChildren(CAstNode root, Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap, Map<CAstNode, Collection<CAstEntity>> children) - Overrides:
copyChildrenin classCAstRewriter<NodePos, CAstBasicRewriter.NoKey>
-
flowOutTo
protected CAstNode flowOutTo(Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, CAstNode> nodeMap, CAstNode oldSource, Object label, CAstNode oldTarget, CAstControlFlowMap orig, CAstSourcePositionMap src) Description copied from class:CAstRewriterinCAstRewriter.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.- Overrides:
flowOutToin classCAstRewriter<NodePos, CAstBasicRewriter.NoKey>
-
copyFlow
protected CAstControlFlowMap copyFlow(Map<Pair<CAstNode, CAstBasicRewriter.NoKey>, @NonNull CAstNode> nodeMap, CAstControlFlowMap orig, CAstSourcePositionMap newSrc) Description copied from class:CAstRewritercreate 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.- Overrides:
copyFlowin classCAstRewriter<NodePos, CAstBasicRewriter.NoKey>
-
rewrite
Description copied from class:CAstRewriterperform the rewrite on aCAstEntity, returning the newCAstEntityas the result- Overrides:
rewritein classCAstRewriter<NodePos, CAstBasicRewriter.NoKey>
-
enterEntity
-
leaveEntity
protected void leaveEntity()
-