Class Body

java.lang.Object
sootup.core.model.Body
All Implemented Interfaces:
HasPosition

public class Body extends Object implements HasPosition
Class that models the Jimple body (code attribute) of a method.
Author:
Linghui Luo
  • Method Details

    • getThisLocal

      public static Local getThisLocal(StmtGraph<?> stmtGraph)
      Returns the LHS of the first identity stmt assigning from \@this.
      Returns:
      The this local
    • getMethodSignature

      @Nonnull public MethodSignature getMethodSignature()
      Returns the MethodSignature associated with this Body.
      Returns:
      the method that owns this body.
    • getLocalCount

      public int getLocalCount()
      Returns the number of locals declared in this body.
    • getLocals

      public Set<Local> getLocals()
      Returns a backed chain of the locals declared in this Body.
    • getTraps

      @Nonnull @Deprecated public List<Trap> getTraps()
      Deprecated.
      Returns an unmodifiable view of the traps found in this Body. @Deprecated the exceptional flow information is already integrated into the StmtGraphs BasicBlocks.getExceptionalFlows() - exists to make porting tools from Soot easier
    • getThisStmt

      @Nullable public Stmt getThisStmt()
      Return unit containing the \@this-assignment *
    • getThisLocal

      @Nullable public Local getThisLocal()
      Return LHS of the first identity stmt assigning from \@this.
    • getParameterLocal

      @Nonnull public Local getParameterLocal(int i)
      Return LHS of the first identity stmt assigning from \@parameter i.
    • getParameterLocals

      @Nonnull public Collection<Local> getParameterLocals()
      Get all the LHS of the identity statements assigning from parameter references.
      Returns:
      a list of size as per getMethod().getParameterCount() with all elements ordered as per the parameter index.
      Throws:
      RuntimeException - if a JParameterRef is missing
    • getStmts

      @Nonnull public List<Stmt> getStmts()
      returns the control flow graph that represents this body into a linear List of statements. for more detailed information of the underlying CFG - or just parts of it - have a look at getStmtGraph()
      Returns:
      the statements in this Body
    • getStmtGraph

      @Nonnull public StmtGraph<?> getStmtGraph()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getPosition

      @Nonnull public Position getPosition()
      Description copied from interface: HasPosition
      Line and column information of the corresponding code object that this represents.
      Specified by:
      getPosition in interface HasPosition
      Returns:
      a Position containing position information.
    • getBranchTargetsOf

      @Nonnull public List<Stmt> getBranchTargetsOf(@Nonnull BranchingStmt fromStmt)
      returns a List of Branch targets of Branching Stmts
    • isStmtBranchTarget

      public boolean isStmtBranchTarget(@Nonnull Stmt targetStmt)
    • getFirstNonIdentityStmt

      @Nonnull public Stmt getFirstNonIdentityStmt()
      Returns the first non-identity stmt in this body.
    • getUses

      public Stream<Value> getUses()
      Returns the results of iterating through all Stmts in this Body and querying them for Values defined. All of the Values found are then returned as a List.
      Returns:
      a List of all the Values for Values defined by this Body's Stmts.
    • getDefs

      public Collection<LValue> getDefs()
      Returns the results of iterating through all Stmts in this Body and querying them for Values defined. All of the Values found are then returned as a List.
      Returns:
      a List of all the Values for Values defined by this Body's Stmts.
    • getDefs

      public static Collection<LValue> getDefs(StmtGraph<?> graph)
    • withLocals

      @Nonnull public Body withLocals(@Nonnull Set<Local> locals)
    • builder

      public static Body.BodyBuilder builder()
    • builder

      public static Body.BodyBuilder builder(@Nonnull MutableStmtGraph graph)
    • builder

      public static Body.BodyBuilder builder(@Nonnull Body body, Set<MethodModifier> modifiers)
    • collectDefs

      public static Map<LValue,Collection<Stmt>> collectDefs(Collection<Stmt> stmts)
      Collects all defining statements of a Local from a list of statements
      Parameters:
      stmts - The searched list of statements
      Returns:
      A map of Locals and their using statements
    • collectUses

      public static Map<Value,Collection<Stmt>> collectUses(Collection<Stmt> stmts)
      Collects all using statements of a Local from a list of statements
      Parameters:
      stmts - The searched list of statements
      Returns:
      A map of Locals and their using statements