All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.toolkits.scalar.BranchedFlowAnalysis Maven / Gradle / Ivy

There is a newer version: 2.5.0-9
Show newest version
/* Soot - a J*va Optimization Framework
 * Copyright (C) 1997-2000 Patrick Lam
 *
 * 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
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * 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-2000.
 * See the 'credits' file distributed with Soot for the complete list of
 * contributors.  (Soot is distributed at http://www.sable.mcgill.ca/soot)
 */



/*
    2000, March 20 - Updated code provided by
                                    Patrick Lam 
                     from 1.beta.4.dev.60
                     to 1.beta.6.dev.34
                     -- Janus (Richard Godard)
*/

package soot.toolkits.scalar;

import soot.*;
import soot.toolkits.graph.*;
import java.util.*;

/** Abstract class providing functionality for branched flow analysis.
 *
 * A branched flow analysis is one which can propagate different
 * information to the successors of a node.  This is useful for
 * propagating information past a statement like if(x >
 * 0): one successor has x > 0 while the other
 * successor has x ≤ 0. */
public abstract class BranchedFlowAnalysis extends AbstractFlowAnalysis
{
    /** Maps graph nodes to OUT sets. */
    protected Map> unitToAfterFallFlow;
    protected Map> unitToAfterBranchFlow;

    public BranchedFlowAnalysis(DirectedGraph graph)
    {
        super(graph);

        unitToAfterFallFlow = new HashMap>(graph.size() * 2 + 1, 0.7f);
        unitToAfterBranchFlow = new HashMap>(graph.size() * 2 + 1, 0.7f);
    }

    /** Given the merge of the in sets, 
     * compute the fallOut and branchOuts
     * set for s. */
    protected abstract void flowThrough(A in, Unit s, 
                                        List fallOut, List branchOuts);

    public A getFallFlowAfter(Unit s)
    {
        List fl = unitToAfterFallFlow.get(s);

        if (fl.isEmpty())
            return newInitialFlow();
        else
            return fl.get(0);
    }


    public List getBranchFlowAfter(Unit s)
    {
        return (unitToAfterBranchFlow.get(s));
    }

    public A getFlowBefore(Unit s)
    {
        return unitToBeforeFlow.get(s);
    }
} // end class BranchedFlowAnalysis





© 2015 - 2024 Weber Informatics LLC | Privacy Policy