Package org.jtool.cfg

Class CFGStatement

Direct Known Subclasses:
CFGException, CFGMethodCall, CFGParameter, CFGReceiver

public class CFGStatement extends CFGNode
A statement node of a CFG, which stores variables defined and used in it.
  • Field Details

  • Constructor Details

    • CFGStatement

      public CFGStatement(org.eclipse.jdt.core.dom.ASTNode node, CFGNode.Kind kind)
      Creates a new object that represents a statement. 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

    • addDefVariable

      public void addDefVariable(JVariableReference jv)
      Adds a variable to the collection of variables defined in this node. This method is not intended to be invoked by clients.
      Parameters:
      jv - the variable to be added
    • addUseVariable

      public void addUseVariable(JVariableReference jv)
      Adds a variable to the collection of variables used in this node. This method is not intended to be invoked by clients.
      Parameters:
      jv - the variable to be added
    • addDefVariables

      public void addDefVariables(List<JVariableReference> jvs)
      Adds variables to the collection of variables defined in this node. This method is not intended to be invoked by clients.
      Parameters:
      jvs - the collection of the variables to be added
    • addUseVariables

      public void addUseVariables(List<JVariableReference> jvs)
      Adds variables to the collection of variables used in this node. This method is not intended to be invoked by clients.
      Parameters:
      jvs - the collection of the variables to be added
    • removeDefVariable

      public boolean removeDefVariable(JReference jv)
      Removes a variable from the collection of variables defined in this node. This method is not intended to be invoked by clients.
      Parameters:
      jv - the collection of the variables to be removed
      Returns:
      true if the removal is successfully done, otherwise false
    • removeUseVariable

      public boolean removeUseVariable(JReference jv)
      Removes a variable from the collection of variables used in this node. This method is not intended to be invoked by clients.
      Parameters:
      jv - the collection of the variables to be removed
      Returns:
      true if the removal is successfully done, otherwise false
    • clearDefVariables

      public void clearDefVariables()
      Clears the collection of variables defined in this node. This method is not intended to be invoked by clients.
    • clearUseVariables

      public void clearUseVariables()
      Clears the collection of variables defined in this node. This method is not intended to be invoked by clients.
    • setDefVariables

      public void setDefVariables(List<JVariableReference> jvs)
      Sets the collection of variables defined in this node. This method is not intended to be invoked by clients.
      Parameters:
      jvs - the collection of the variables to be set
    • setUseVariables

      public void setUseVariables(List<JVariableReference> jvs)
      Sets the collection of variables used in this node. This method is not intended to be invoked by clients.
      Parameters:
      jvs - the collection of the variables to be set
    • setDefVariable

      public void setDefVariable(JVariableReference jv)
      Sets the collection that stores a variable defined in this node. This method is not intended to be invoked by clients.
      Parameters:
      jv - the variable to be set
    • setUseVariable

      public void setUseVariable(JVariableReference jv)
      Sets the collection that stores a variable used in this node. This method is not intended to be invoked by clients.
      Parameters:
      jv - the variable to be set
    • getDefVariables

      public List<JVariableReference> getDefVariables()
      Returns variables defined in this node.
      Returns:
      the collection of the defined variables
    • getUseVariables

      public List<JVariableReference> getUseVariables()
      Returns variables used in this node.
      Returns:
      the collection of the used variables
    • defineVariable

      public boolean defineVariable(JVariableReference jv)
      Tests if this node defines a given variable.
      Parameters:
      jv - the variable to be checked
      Returns:
      true if the variable is defined in this node, otherwise false
    • useVariable

      public boolean useVariable(JVariableReference jv)
      Tests if this node uses a given variable.
      Parameters:
      jv - the variable to be checked
      Returns:
      true if the variable is used in this node, otherwise false
    • hasDefVariable

      public boolean hasDefVariable()
      Tests if this node defines any variable.
      Overrides:
      hasDefVariable in class CFGNode
      Returns:
      true if there is a defined variable found in this node, otherwise false
    • hasUseVariable

      public boolean hasUseVariable()
      Tests if this node uses any variable.
      Overrides:
      hasUseVariable in class CFGNode
      Returns:
      true if there is a used variable found in this node, otherwise false
    • getDefVariable

      public JVariableReference getDefVariable(String name)
      Returns a variable having a given name from the collection of variables defined in this node.
      Parameters:
      name - the name of the variable
      Returns:
      the found variable, or null if no variable is found
    • getUseVariable

      public JVariableReference getUseVariable(String name)
      Returns a variable having a given name from the collection of variables used in this node.
      Parameters:
      name - the name of the variable
      Returns:
      the found variable, or null if no variable is found
    • getDefFirst

      public JVariableReference getDefFirst()
      Returns the first one from the collection of variables defined in this node.
      Returns:
      the defined variable at the first position, or null if this node never defines any variable
    • getUseFirst

      public JVariableReference getUseFirst()
      Returns the first one from the collection of variables used in this node.
      Returns:
      the used variable at the first position, or null if this node never uses any variable
    • getDefLast

      public JVariableReference getDefLast()
      Returns the last one from the collection of variables defined in this node.
      Returns:
      the defined variable at the last position, or null if this node never defines any variable
    • getUseLast

      public JVariableReference getUseLast()
      Returns the last one from the collection of variables used in this node.
      Returns:
      the used variable at the last position, or null if this node never uses any variable
    • findPrimaryUseVariables

      public List<JVariableReference> findPrimaryUseVariables()
      Obtains primary variables used in this assignment node.
      Returns:
      the collection of the primary variables
    • findPrimaryUseVariables

      public List<JVariableReference> findPrimaryUseVariables(org.eclipse.jdt.core.dom.Expression expr)
      Obtains primary variables used in this node.
      Parameters:
      expr - the expression that contains used variables
      Returns:
      the collection of the primary variables
    • toString

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

      protected String toStringForVariables(List<JVariableReference> jvars)
      Obtains information on variables.
      Parameters:
      jvars - the set of variables
      Returns:
      the string representing the information