Package org.jtool.cfg

Class CFGNode

Direct Known Subclasses:
CCFGEntry, CFGEntry, CFGExit, CFGMerge, CFGStatement

public class CFGNode extends GraphNode
A node of a CFG.
  • Field Details

    • astNode

      protected org.eclipse.jdt.core.dom.ASTNode astNode
      The AST node corresponding to this node.
    • kind

      protected CFGNode.Kind kind
      The kind of this node.
    • pdgNode

      protected PDGNode pdgNode
      The PDG node corresponding to this node.
  • Constructor Details

    • CFGNode

      public CFGNode()
      Creates a new object that represents a dummy node. This method is not intended to be invoked by clients.
    • CFGNode

      public CFGNode(org.eclipse.jdt.core.dom.ASTNode node, CFGNode.Kind kind)
      Creates a new object that represents a CFG node. This method is not intended to be invoked by clients.
      Parameters:
      node - the ASt node corresponding to this node
      kind - the kind of this node
  • Method Details

    • resetId

      public static void resetId()
      Resets the identification number for CFG nodes. This method is not intended to be invoked by clients.
    • setASTNode

      public void setASTNode(org.eclipse.jdt.core.dom.ASTNode node)
      Sets the AST node corresponding to this node. This method is not intended to be invoked by clients.
      Parameters:
      node - the AST node to be set
    • getASTNode

      public org.eclipse.jdt.core.dom.ASTNode getASTNode()
      Returns the AST node corresponding to this node.
      Returns:
      the corresponding AST node
    • setKind

      public void setKind(CFGNode.Kind kind)
      Sets the kind of this node. This method is not intended to be invoked by clients.
      Parameters:
      kind - the kind to be set
    • getKind

      public CFGNode.Kind getKind()
      Returns the kind of this node.
      Returns:
      the kind of this node
    • setPDGNode

      public void setPDGNode(PDGNode node)
      Sets the PDG node corresponding to this node. This method is not intended to be invoked by clients.
      Parameters:
      node - the PDG node to be set
    • getPDGNode

      public PDGNode getPDGNode()
      Returns the PDG node corresponding to this node.
      Returns:
      the corresponding PDG node
    • getPredecessors

      public Set<CFGNode> getPredecessors()
      Obtains predecessors of this node.
      Returns:
      the collection of the predecessors
    • getSuccessors

      public Set<CFGNode> getSuccessors()
      Obtains successors of this node.
      Returns:
      the collection of the successors
    • getNumOfPredecessors

      public int getNumOfPredecessors()
      Returns the number of predecessors of this node.
      Returns:
      the the number of the predecessors
    • getNumOfSuccessors

      public int getNumOfSuccessors()
      Returns the number of successors of this node.
      Returns:
      the the number of the successors
    • getIncomingFlows

      public List<ControlFlow> getIncomingFlows()
      Obtains control flow edges incoming to this node.
      Returns:
      the collection of the incoming edges
    • getOutgoingFlows

      public List<ControlFlow> getOutgoingFlows()
      Obtains control flow edges outgoing from this node.
      Returns:
      the collection of the outgoing edges
    • getIncomingTrueFlows

      public List<ControlFlow> getIncomingTrueFlows()
      Obtains true control flow edges incoming to this node.
      Returns:
      the collection of the incoming true edges
    • getIncomingFalseFlows

      public List<ControlFlow> getIncomingFalseFlows()
      Obtains true control flow edges incoming to this node.
      Returns:
      the collection of the incoming false edges
    • getOutgoingTrueFlow

      public ControlFlow getOutgoingTrueFlow()
      Obtains true control flow edges outgoing from this node.
      Returns:
      the outgoing true edge
    • getOutgoingFalseFlow

      public ControlFlow getOutgoingFalseFlow()
      Obtains true control flow edges outgoing from this node.
      Returns:
      the outgoing false edge
    • isBranch

      public boolean isBranch()
      Tests if this node causes branching, which has multiple outgoing control flow edges.
      Returns:
      true if this node causes branching, otherwise false
    • isSelection

      public boolean isSelection()
      Tests if this node causes selection.
      Returns:
      true if this node causes selection, otherwise false
    • isLoop

      public boolean isLoop()
      Tests if this node causes looping.
      Returns:
      true if this node causes looping, otherwise false
    • isJoin

      public boolean isJoin()
      Tests if this node causes joining, which has multiple incoming control flow edges.
      Returns:
      true if this node causes joining, otherwise false
    • isEntry

      public boolean isEntry()
      Tests if this is an entry node.
      Returns:
      true if this is an entry node, otherwise false
    • isClassEntry

      public boolean isClassEntry()
      Tests if this is a class entry node.
      Returns:
      true if this is a class entry node, otherwise false
    • isInterfaceEntry

      public boolean isInterfaceEntry()
      Tests if this is an interface entry node.
      Returns:
      true if this is an interface entry node, otherwise false
    • isEnumEntry

      public boolean isEnumEntry()
      Tests if this is an enum entry node.
      Returns:
      true if this is an enum entry node, otherwise false
    • isMethodEntry

      public boolean isMethodEntry()
      Tests if this is a method entry node.
      Returns:
      true if this is a method entry node, otherwise false
    • isConstructorEntry

      public boolean isConstructorEntry()
      Tests if this is a constructor entry node.
      Returns:
      true if this is a constructor entry node, otherwise false
    • isInitializerEntry

      public boolean isInitializerEntry()
      Tests if this is a static initializer entry node.
      Returns:
      true if this is a static initializer entry node, otherwise false
    • isFieldEntry

      public boolean isFieldEntry()
      Tests if this is a field entry node.
      Returns:
      true if this is a field entry node, otherwise false
    • isEnumConstantEntry

      public boolean isEnumConstantEntry()
      Tests if this is an enum constant entry node.
      Returns:
      true if this is an enum constant entry node, otherwise false
    • isExit

      public boolean isExit()
      Tests if this is an exit node.
      Returns:
      true if this is an exit node, otherwise false
    • isAssignment

      public boolean isAssignment()
      Tests if this is a statement node formed by an assignment.
      Returns:
      true if this is an assignment node, otherwise false
    • isMethodCall

      public boolean isMethodCall()
      Tests if this is a statement node formed by a method call.
      Returns:
      true if this is a method call node, otherwise false
    • isFieldDeclaration

      public boolean isFieldDeclaration()
      Tests if this is a statement node formed by a field declaration.
      Returns:
      true if this is a field declaration node, otherwise false
    • isLocalDeclaration

      public boolean isLocalDeclaration()
      Tests if this is a statement node formed by a local variable declaration.
      Returns:
      true if this is a local variable declaration node, otherwise false
    • isAssert

      public boolean isAssert()
      Tests if this is an assert-statement node.
      Returns:
      true if this is an assert-statement node, otherwise false
    • isBreak

      public boolean isBreak()
      Tests if this is a break-statement node.
      Returns:
      true if this is a break-statement node, otherwise false
    • isContinue

      public boolean isContinue()
      Tests if this is a continue-statement node.
      Returns:
      true if this is a continue-statement node, otherwise false
    • isDo

      public boolean isDo()
      Tests if this is a do-statement node.
      Returns:
      true if this is a do-statement node, otherwise false
    • isFor

      public boolean isFor()
      Tests if this is a for-statement node.
      Returns:
      true if this is a for-statement node, otherwise false
    • isEnhancedFor

      public boolean isEnhancedFor()
      Tests if this is an enhanced for-statement node.
      Returns:
      true if this is an enhanced for-statement node, otherwise false
    • isIf

      public boolean isIf()
      Tests if this is an if-statement node.
      Returns:
      true if this is an if-statement, otherwise false
    • isReturn

      public boolean isReturn()
      Tests if this is a return statement node.
      Returns:
      true if this is a return statement, otherwise false
    • isSwitchCase

      public boolean isSwitchCase()
      Tests if this is a switch-case node for the case label.
      Returns:
      true if this is a switch-case-statement, otherwise false
    • isSwitchDefault

      public boolean isSwitchDefault()
      Tests if this is a switch-default-case node for the default label.
      Returns:
      true if this is a switch-default-statement node, otherwise false
    • isWhile

      public boolean isWhile()
      Tests if this is a while-statement node.
      Returns:
      true if this is a while-statement node, otherwise false
    • isLabel

      public boolean isLabel()
      Tests if this is a statement node for the label.
      Returns:
      true if this is a label statement node, otherwise false
    • isSwitch

      public boolean isSwitch()
      Tests if this is a switch-statement node.
      Returns:
      true if this is a switch-statement, otherwise false
    • isSynchronized

      public boolean isSynchronized()
      Tests if this is a synchronized-statement node.
      Returns:
      true if this is a synchronized-statement node, otherwise false
    • isThrow

      public boolean isThrow()
      Tests if this is a throw-statement node.
      Returns:
      true if this is a throw-statement node, otherwise false
    • isTry

      public boolean isTry()
      Tests if this is a try-statement node.
      Returns:
      true if this is a try-statement node, otherwise false
    • isCatchClause

      public boolean isCatchClause()
      Tests if this is a catch-clause node.
      Returns:
      true if this is a catch-clause node, otherwise false
    • isFinallyClause

      public boolean isFinallyClause()
      Tests if this is a finally-clause node.
      Returns:
      true if this is a finally-clause node, otherwise false
    • isThrowClause

      public boolean isThrowClause()
      Tests if this is a throws-clause node.
      Returns:
      true if this is a throws-clause node, otherwise false
    • isParameter

      public boolean isParameter()
      Tests if this is a statement node formed by a parameter.
      Returns:
      true if this is a parameter node, otherwise false
    • isFormal

      public boolean isFormal()
      Tests if this is a statement node formed by a formal parameter.
      Returns:
      true if this is a formal parameter node, otherwise false
    • isFormalIn

      public boolean isFormalIn()
      Tests if this is a statement node formed by a formal-in parameter.
      Returns:
      true if this is a formal-in parameter node, otherwise false
    • isFormalOut

      public boolean isFormalOut()
      Tests if this is a statement node formed by a formal-out parameter.
      Returns:
      true if this is a formal parameter-out parameter node, otherwise false
    • isActual

      public boolean isActual()
      Tests if this is a statement node formed by an actual argument.
      Returns:
      true if this is an actual argument node, otherwise false
    • isActualIn

      public boolean isActualIn()
      Tests if this is a statement node formed by an actual-in argument.
      Returns:
      true if this is an actual-in argument node, otherwise false
    • isActualOut

      public boolean isActualOut()
      Tests if this is a statement node formed by an actual-out argument.
      Returns:
      true if this is an actual-out argument node, otherwise false
    • isReceiver

      public boolean isReceiver()
      Tests if this is a statement node formed by a receiver.
      Returns:
      true if this is a receiver node, otherwise false
    • isStatementNotParameter

      public boolean isStatementNotParameter()
      Tests if this node represents a statement but not a parameter.
      Returns:
      true if this node represents a statement node but not a parameter, otherwise false
    • isStatement

      public boolean isStatement()
      Tests if this is a a statement node.
      Returns:
      true if this is a statement node, otherwise false
    • isMerge

      public boolean isMerge()
      Tests if this node is responsible for merging branches.
      Returns:
      true if this is a merge node, otherwise false
    • isDummy

      public boolean isDummy()
      Tests if this is a dummy node.
      Returns:
      true if this is a dummy node, otherwise false
    • isNextToBranch

      public boolean isNextToBranch()
      Tests if this node is a successor of the branch node.
      Returns:
      true if this node is a successor of the branch node, otherwise false
    • hasDefVariable

      public boolean hasDefVariable()
      Tests if a variable is defined in this node.
      Returns:
      true if this has any used variable, otherwise false
    • hasUseVariable

      public boolean hasUseVariable()
      Tests if a variable is used in this node.
      Returns:
      true if this has any used variable, otherwise false
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class GraphElement
    • equals

      public boolean equals(CFGNode node)
      Tests if a given CFG node is equal to this node.
      Parameters:
      node - the node to be checked
      Returns:
      the true if the given node is equal to this node
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class GraphNode
    • print

      public void print()
      Displays information on this node.
    • toString

      public String toString()
      Obtains information on this node.
      Overrides:
      toString in class GraphNode
      Returns:
      the string representing the information
    • sortNodes

      public static List<CFGNode> sortNodes(Collection<? extends CFGNode> nodes)
      Sorts the list of CFG nodes
      Parameters:
      nodes - the collection of the CFG nodes to be sorted
      Returns:
      the sorted list of the CFG nodes
    • sortNodesInverse

      public static List<CFGNode> sortNodesInverse(Collection<? extends CFGNode> collection)
      Sorts inversely the list of CFG nodes
      Parameters:
      collection - the collection of the CFG nodes to be sorted
      Returns:
      the sorted list of the CFG nodes
    • isStatement

      public static boolean isStatement(org.eclipse.jdt.core.dom.ASTNode node)
      Tests if a AST node is categorized into the statement.
      Parameters:
      node - an AST node to be checked
      Returns:
      true if the AST node is categorized into the statement, otherwise false
    • isExpression

      public static boolean isExpression(org.eclipse.jdt.core.dom.ASTNode node)
      Tests if a AST node is categorized into the expression.
      Parameters:
      node - an AST node to be checked
      Returns:
      true if the AST node is categorized into the expression, otherwise false
    • isLiteral

      public static boolean isLiteral(org.eclipse.jdt.core.dom.ASTNode node)
      Tests if a AST node is categorized into the literal.
      Parameters:
      node - an AST node to be checked
      Returns:
      true if the AST node is categorized into the literal, otherwise false