soot.dava.toolkits.base.renamer.infoGatheringAnalysis Maven / Gradle / Ivy
package soot.dava.toolkits.base.renamer;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Nomair A. Naeem
* %%
* This program 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 program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import soot.BooleanType;
import soot.Local;
import soot.RefType;
import soot.SootField;
import soot.SootMethod;
import soot.SootMethodRef;
import soot.Type;
import soot.Value;
import soot.dava.DavaBody;
import soot.dava.DecompilationException;
import soot.dava.internal.AST.ASTBinaryCondition;
import soot.dava.internal.AST.ASTDoWhileNode;
import soot.dava.internal.AST.ASTForLoopNode;
import soot.dava.internal.AST.ASTIfElseNode;
import soot.dava.internal.AST.ASTIfNode;
import soot.dava.internal.AST.ASTMethodNode;
import soot.dava.internal.AST.ASTSwitchNode;
import soot.dava.internal.AST.ASTTryNode;
import soot.dava.internal.AST.ASTUnaryCondition;
import soot.dava.internal.AST.ASTWhileNode;
import soot.dava.internal.asg.AugmentedStmt;
import soot.dava.internal.javaRep.DIntConstant;
import soot.dava.toolkits.base.AST.analysis.DepthFirstAdapter;
import soot.grimp.NewInvokeExpr;
import soot.grimp.internal.GAssignStmt;
import soot.jimple.ArrayRef;
import soot.jimple.CastExpr;
import soot.jimple.ConditionExpr;
import soot.jimple.DefinitionStmt;
import soot.jimple.EqExpr;
import soot.jimple.InstanceFieldRef;
import soot.jimple.InvokeExpr;
import soot.jimple.NeExpr;
import soot.jimple.StaticFieldRef;
import soot.jimple.Stmt;
import soot.jimple.internal.AbstractInstanceFieldRef;
//import soot.util.*;
public class infoGatheringAnalysis extends DepthFirstAdapter {
public boolean DEBUG = false;
public final static int CLASSNAME = 0; // used by renamer
public final static int METHODNAME = 1;
public final static int GETSET = 2;
public final static int IF = 3;
public final static int WHILE = 4;
public final static int SWITCH = 5;
public final static int ARRAYINDEX = 6;
public final static int MAINARG = 7; // used by renamer
public final static int FIELDASSIGN = 8; // used by renamer
public final static int FORLOOPUPDATE = 9; // used by renamer
public final static int CAST = 10;
public final static int NUMBITS = 11;
// dataset to store all information gathered
heuristicSet info;
// if we are within a subtree rooted at a definitionStmt this boolean is true
boolean inDefinitionStmt = false;
// whenever there is a definition to a local definedLocal will contain a ref to the local
Local definedLocal = null;
// if we are within a subtree rooted at a ifNode or IfElseNode this boolean is true
boolean inIf = false;
// if we are within a subtree rooted at a WhileNode or DoWhileNode this boolean is true
boolean inWhile = false;
// if we are within a subtree rooted at a ForLoop this boolean is true
boolean inFor = false;
public infoGatheringAnalysis(DavaBody davaBody) {
info = new heuristicSet();
List localList = new ArrayList();
/*
* Get locals info out of davaBody Copied with modifications from DavaPrinter method printLocalsInBody
*/
HashSet params = new HashSet();
// params.addAll(davaBody.get_ParamMap().values());
// params.addAll(davaBody.get_CaughtRefs());
HashSet