Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* Soot - a J*va Optimization Framework
   * Copyright (C) 1999 Patrice Pominville, Raja Vallee-Rai
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  * Modified by the Sable Research Group and others 1997-2003.  
  * See the 'credits' file distributed with Soot for the complete list of
  * contributors.  (Soot is distributed at
 package soot.toolkits.graph;
 import java.util.*;
 import soot.*;
A CFG where the nodes are Block instances, and where soot.Units which include array references start new blocks. Exceptional control flow is ignored, so the graph will be a forest where each exception handler constitutes a disjoint subgraph.
 public class ArrayRefBlockGraph extends BlockGraph 

Constructs an ArrayRefBlockGraph from the given soot.Body.

Note that this constructor builds a BriefUnitGraph internally when splitting body's soot.Units into Blocks. Callers who need both a BriefUnitGraph and an ArrayRefBlockGraph should use the constructor taking the BriefUnitGraph as a parameter, as a minor optimization.

the Body instance from which the graph is built.
     public  ArrayRefBlockGraph(Body body)
         this(new BriefUnitGraph(body));

Constructs an ArrayRefBlockGraph corresponding to the Unit-level control flow represented by the passed BriefUnitGraph.

unitGraph The BriefUnitGraph for which to build an ArrayRefBlockGraph.
     public  ArrayRefBlockGraph(BriefUnitGraph unitGraph)


Utility method for computing the basic block leaders for a soot.Body, given its UnitGraph (i.e., the instructions which begin new basic blocks).

This implementation chooses as block leaders all the Units that BlockGraph.computerLeaders(), and adds:

  • All Units which contain an array reference, as defined by Stmt.containsArrayRef() and Inst.containsArrayRef().
  • The first Unit not covered by each soot.Trap (i.e., the Unit returned by Trap.getLastUnit().

unitGraph is the Unit-level CFG which is to be split into basic blocks.
the java.util.Set of soot.Units in unitGraph which are block leaders.
    protected Set<UnitcomputeLeaders(UnitGraph unitGraph) {
	Body body = unitGraph.getBody();
	if (body != ) {
	    throw new RuntimeException("ArrayRefBlockGraph.computeLeaders() called with a UnitGraph that doesn't match its mBody.");
        Set<Unitleaders = super.computeLeaders(unitGraph);
	for (Iterator it = body.getUnits().iterator(); it.hasNext(); ) {
	    Unit unit = (;
	    if (((unit instanceof Stmt) && ((Stmtunit).containsArrayRef())) {
	return leaders;
New to GrepCode? Check out our FAQ X