Package com.ibm.wala.cast.tree.impl
Class CAstControlFlowRecorder
- java.lang.Object
-
- com.ibm.wala.cast.tree.impl.CAstControlFlowRecorder
-
- All Implemented Interfaces:
CAstControlFlowMap
public class CAstControlFlowRecorder extends Object implements CAstControlFlowMap
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).
-
-
Field Summary
-
Fields inherited from interface com.ibm.wala.cast.tree.CAstControlFlowMap
EXCEPTION_TO_EXIT, SWITCH_DEFAULT
-
-
Constructor Summary
Constructors Constructor Description CAstControlFlowRecorder(CAstSourcePositionMap src)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Object from, Object to, Object label)Add a control-flow edge from the `from' node to the `to' node with the (possibly null) label `label'.voidaddAll(CAstControlFlowMap other)Collection<CAstNode>getMappedNodes()Returns an iterator of all CAstNodes for which this map contains control flow mapping information.CollectiongetSourceNodes(CAstNode to)Return a collection of control-flow ast nodes that have this one as a possible target.CAstNodegetTarget(CAstNode from, Object label)Return the target ast node of the control-flow instruction denoted by from with respect to the given label.Collection<Object>getTargetLabels(CAstNode from)Return a collection of all labels for which the control-flow ast nodefromhas a target.booleanisMapped(Object node)voidmap(Object node, CAstNode ast)Establish a mapping between some object `node' and the ast node `ast'.StringtoString()
-
-
-
Constructor Detail
-
CAstControlFlowRecorder
public CAstControlFlowRecorder(CAstSourcePositionMap src)
-
-
Method Detail
-
getTarget
public CAstNode getTarget(CAstNode from, Object label)
Description copied from interface:CAstControlFlowMapReturn the target ast node of the control-flow instruction denoted by from with respect to the given label.- Specified by:
getTargetin interfaceCAstControlFlowMap
-
getTargetLabels
public Collection<Object> getTargetLabels(CAstNode from)
Description copied from interface:CAstControlFlowMapReturn a collection of all labels for which the control-flow ast nodefromhas a target.- Specified by:
getTargetLabelsin interfaceCAstControlFlowMap
-
getSourceNodes
public Collection getSourceNodes(CAstNode to)
Description copied from interface:CAstControlFlowMapReturn a collection of control-flow ast nodes that have this one as a possible target.- Specified by:
getSourceNodesin interfaceCAstControlFlowMap
-
getMappedNodes
public Collection<CAstNode> getMappedNodes()
Description copied from interface:CAstControlFlowMapReturns an iterator of all CAstNodes for which this map contains control flow mapping information.- Specified by:
getMappedNodesin interfaceCAstControlFlowMap
-
add
public void add(Object from, Object to, Object label)
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.
-
map
public void map(Object node, CAstNode ast)
Establish a mapping between some object `node' and the ast node `ast'. Objects used as endpoints in a control flow edge must be mapped to ast nodes using this call.
-
addAll
public void addAll(CAstControlFlowMap other)
-
isMapped
public boolean isMapped(Object node)
-
-