Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* 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.
*/
package soot.jimple.toolkits.annotation.parity;
import soot.*;
import soot.util.*;
import java.util.*;
import soot.jimple.*;
import soot.toolkits.graph.*;
import soot.toolkits.scalar.*;
import soot.options.*;
// STEP 1: What are we computing?
// SETS OF PAIRS of form (X, T) => Use ArraySparseSet.
//
// STEP 2: Precisely define what we are computing.
// For each statement compute the parity of all variables
// in the program.
//
// STEP 3: Decide whether it is a backwards or forwards analysis.
// FORWARDS
//
//
public class ParityAnalysis extends ForwardFlowAnalysis {
private UnitGraph g;
private final static String TOP = "top";
private final static String BOTTOM = "bottom";
private final static String EVEN = "even";
private final static String ODD = "odd";
private LiveLocals filter;
public ParityAnalysis(UnitGraph g, LiveLocals filter)
{
super(g);
this.g = g;
this.filter = filter;
filterUnitToBeforeFlow = new HashMap();
buildBeforeFilterMap();
filterUnitToAfterFlow = new HashMap();
doAnalysis();
}
public ParityAnalysis(UnitGraph g){
super(g);
this.g = g;
doAnalysis();
}
private void buildBeforeFilterMap(){
Iterator it = g.getBody().getUnits().iterator();
while (it.hasNext()){
Stmt s = (Stmt)it.next();
//if (!(s instanceof DefinitionStmt)) continue;
//Value left = ((DefinitionStmt)s).getLeftOp();
//if (!(left instanceof Local)) continue;
//if (!((left.getType() instanceof IntegerType) || (left.getType() instanceof LongType))) continue;
List list = filter.getLiveLocalsBefore(s);
HashMap map = new HashMap();
Iterator listIt = list.iterator();
while (listIt.hasNext()){
map.put(listIt.next(), BOTTOM);
}
filterUnitToBeforeFlow.put(s, map);
}
//System.out.println("init filtBeforeMap: "+filterUnitToBeforeFlow);
}
// STEP 4: Is the merge operator union or intersection?
//
// merge | bottom | even | odd | top
// -------+--------+--------+-------+--------
// bottom | bottom | even | odd | top
// -------+--------+--------+-------+--------
// even | even | even | top | top
// -------+--------+--------+-------+--------
// odd | odd | top | odd | top
// -------+--------+--------+-------+--------
// top | top | top | top | top
//
protected void merge(Object in1, Object in2, Object out)
{
HashMap inMap1 = (HashMap) in1;
HashMap inMap2 = (HashMap) in2;
HashMap