org.jtool.jxplatform.graph.cfg
Class CFGStatement

java.lang.Object
  extended byorg.jtool.jxplatform.graph.GraphNode
      extended byorg.jtool.jxplatform.graph.cfg.CFGNode
          extended byorg.jtool.jxplatform.graph.cfg.CFGStatement
All Implemented Interfaces:
GraphElement, GraphNodeSort
Direct Known Subclasses:
CFGAssignment, CFGBranch, CFGCall, CFGDeclaration, CFGParameter

public class CFGStatement
extends CFGNode

A statement node of CFGs.

Author:
Katsuhsa Maruyama

Field Summary
protected  JxVariableList defs
          A collection of variables defined at this node.
protected  JxVariableList uses
          A collection of variables used at this node.
 
Fields inherited from class org.jtool.jxplatform.graph.cfg.CFGNode
defid, element
 
Fields inherited from class org.jtool.jxplatform.graph.GraphNode
id, nodeNum, sort
 
Fields inherited from interface org.jtool.jxplatform.graph.GraphNodeSort
actualIn, actualOut, assignments, assignmentSt, branches, breakSt, callings, caseLabel, classEntry, classExit, constructorCall, constructorEntry, constructorExit, continueSt, defaultLabel, doSt, entries, exits, fieldDecl, formalIn, formalOut, forSt, ifSt, ignores, instanceCreation, interfaceEntry, interfaceExit, labelSt, localDecl, mergeSt, methodCall, methodEntry, methodExit, newSt, parameters, polymorphicCall, returnSt, switchSt, synchronizedSt, throwSt, trySt, whileSt
 
Constructor Summary
protected CFGStatement()
          Creates a new, empty object.
protected CFGStatement(int sort, org.w3c.dom.Element elem)
          Creates a new node.
 
Method Summary
protected  void addDefinedVariable(JxVariable jv)
          Adds a defined variable.
protected  void addDefinedVariables(JxDefUseExpression jexp)
          Adds defined variables of an expression or a statement.
protected  void addDefinedVariables(JxVariableList jvl)
          Adds defined variables in a collection.
protected  void addUsedVariable(JxVariable jv)
          Adds a used variable.
protected  void addUsedVariables(JxDefUseExpression jexp)
          Adds used variables of an expression or a statement.
protected  void addUsedVariables(JxVariableList jvl)
          Adds used variables in a collection.
protected  void clearDefinedVariable()
          Clears a collection of defined variables.
protected  void clearUsedVariable()
          Clears a collection of used variables.
 boolean definesVariable(JxVariable jv)
          Tests if this statement defines a variable.
 JxVariable getDefinedVariable(java.lang.String name)
          Returns a defined variable with a name at this statement.
 JxVariableList getDefinedVariables()
          Returns variables defined at this statement.
 JxVariable getUsedVariable(java.lang.String name)
          Returns a defined variable with a name at this statement.
 JxVariableList getUsedVariables()
          Returns variables used at this statement.
 boolean isStatement()
          Tests if this node indicates a statement.
 void print(java.lang.StringBuffer buf)
          protected Collects information about this statement for printing.
 void printDefUse(java.lang.String mesg, java.lang.StringBuffer buf)
          Collects information about this statement for printing.
protected  void removeDefinedVariable(JxVariable jv)
          Removes a defined variable.
protected  void removeUsedVariable(JxVariable jv)
          Removes a used variable.
protected  void setDefinedVariable(JxVariable jv)
          Sets a defined variable.
protected  void setDefinedVariables(JxDefUseExpression jexp)
          Sets defined variables of a stetement.
protected  void setUsedVariable(JxVariable jv)
          Sets a used variable.
protected  void setUsedVariables(JxDefUseExpression jexp)
          Sets used variables of a statement.
 boolean usesVariable(JxVariable jv)
          Tests if this statement uses a variable.
 
Methods inherited from class org.jtool.jxplatform.graph.cfg.CFGNode
equals, getDefId, getElem, getPredecessors, getPredecessorsNumber, getSuccessors, getSuccessorsNumber, hasDefVariable, hasUseVariable, isAssignmentSt, isBranch, isBranchSt, isBreakSt, isCallSt, isContinueSt, isDoSt, isEntrySt, isExitSt, isFieldSt, isFormalInSt, isFormalOutSt, isFormalSt, isForSt, isGeneralAssignmentSt, isGeneralStatement, isIfSt, isIgnoredSt, isJoin, isLabelSt, isLocalSt, isLoopSt, isMergeSt, isMethodEntry, isParameterSt, isReturnSt, isSwitchLabel, isSwitchSt, isWhileSt, print, print, write
 
Methods inherited from class org.jtool.jxplatform.graph.GraphNode
addIncomingEdge, addIncomingEdges, addOutgoingEdge, addOutgoingEdges, clear, clearId, clearIncomingEdges, clearOutgoingEdges, getDstNodes, getId, getIncomingEdges, getOutgoingEdges, getSort, getSrcNodes, removeIncomingEdge, removeOutgoingEdge, setDstNodes, setIncomingEdges, setOutgoingEdges, setSort, setSrcNodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defs

protected JxVariableList defs
A collection of variables defined at this node.


uses

protected JxVariableList uses
A collection of variables used at this node.

Constructor Detail

CFGStatement

protected CFGStatement()
Creates a new, empty object.


CFGStatement

protected CFGStatement(int sort,
                       org.w3c.dom.Element elem)
Creates a new node.

Parameters:
sort - The sort of this node.
elem - A DOM element corresponding to this node.
Method Detail

isStatement

public boolean isStatement()
Tests if this node indicates a statement.

Overrides:
isStatement in class CFGNode
Returns:
always true.

setDefinedVariables

protected void setDefinedVariables(JxDefUseExpression jexp)
                            throws JxWrapperException
Sets defined variables of a stetement.

Parameters:
jexp - A def-use expression wrapper which might define variables.
Throws:
JxWrapperException - if the collection of variables fails.

setUsedVariables

protected void setUsedVariables(JxDefUseExpression jexp)
                         throws JxWrapperException
Sets used variables of a statement.

Parameters:
jexp - A def-use expression wrapper which might use variables.
Throws:
JxWrapperException - if the collection of variables fails.

setDefinedVariable

protected void setDefinedVariable(JxVariable jv)
Sets a defined variable.

Parameters:
jv - A variable wrapper to be stored.

setUsedVariable

protected void setUsedVariable(JxVariable jv)
Sets a used variable.

Parameters:
jv - A variable wrapper to be stored.

addDefinedVariable

protected void addDefinedVariable(JxVariable jv)
Adds a defined variable.

Parameters:
jv - A variable wrapper to be added.

addUsedVariable

protected void addUsedVariable(JxVariable jv)
Adds a used variable.

Parameters:
jv - A variable wrapper to be added.

addDefinedVariables

protected void addDefinedVariables(JxVariableList jvl)
Adds defined variables in a collection.

Parameters:
jvl - A collection of defined variables to be added.

addUsedVariables

protected void addUsedVariables(JxVariableList jvl)
Adds used variables in a collection.

Parameters:
jvl - A collection of used variables to be added.

removeDefinedVariable

protected void removeDefinedVariable(JxVariable jv)
Removes a defined variable.

Parameters:
jv - A variable wrapper to be removed.

removeUsedVariable

protected void removeUsedVariable(JxVariable jv)
Removes a used variable.

Parameters:
jv - A variable wrapper to be removed.

clearDefinedVariable

protected void clearDefinedVariable()
Clears a collection of defined variables.


clearUsedVariable

protected void clearUsedVariable()
Clears a collection of used variables.


addDefinedVariables

protected void addDefinedVariables(JxDefUseExpression jexp)
                            throws JxWrapperException
Adds defined variables of an expression or a statement.

Parameters:
jexp - A def-use expression wrapper which might define variables.
Throws:
JxWrapperException - if the collection of variables fails.

addUsedVariables

protected void addUsedVariables(JxDefUseExpression jexp)
                         throws JxWrapperException
Adds used variables of an expression or a statement.

Parameters:
jexp - A def-use expression wrapper which might use variables.
Throws:
JxWrapperException - if the collection of variables fails.

getDefinedVariables

public JxVariableList getDefinedVariables()
Returns variables defined at this statement.

Returns:
The colelction of variables defined at this statement.

getUsedVariables

public JxVariableList getUsedVariables()
Returns variables used at this statement.

Returns:
The colelction of variables used at this statement.

definesVariable

public boolean definesVariable(JxVariable jv)
Tests if this statement defines a variable.

Parameters:
jv - A variable wrapper to be tested.
Returns:
true if this statement defines the variable, otherwise false.

usesVariable

public boolean usesVariable(JxVariable jv)
Tests if this statement uses a variable.

Parameters:
jv - A variable wrapper to be tested.
Returns:
true if this statement uses the variable, otherwise false.

getDefinedVariable

public JxVariable getDefinedVariable(java.lang.String name)
Returns a defined variable with a name at this statement.

Parameters:
name - The name of a variable to be retrieved.
Returns:
The variable wrapper, or null if there is no variable found.

getUsedVariable

public JxVariable getUsedVariable(java.lang.String name)
Returns a defined variable with a name at this statement.

Parameters:
name - The name of a variable to be retrieved.
Returns:
The variable wrapper, or null if there is no variable found.

print

public void print(java.lang.StringBuffer buf)
protected Collects information about this statement for printing.

Overrides:
print in class GraphNode
Parameters:
buf - The information about the stetement.

printDefUse

public void printDefUse(java.lang.String mesg,
                        java.lang.StringBuffer buf)
Collects information about this statement for printing.

Parameters:
mesg - The description about this statement.
buf - The information about the statement.