本文整理汇总了Java中soot.jimple.IdentityStmt类的典型用法代码示例。如果您正苦于以下问题:Java IdentityStmt类的具体用法?Java IdentityStmt怎么用?Java IdentityStmt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IdentityStmt类属于soot.jimple包,在下文中一共展示了IdentityStmt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: caseIdentityStmt
import soot.jimple.IdentityStmt; //导入依赖的package包/类
public void caseIdentityStmt(IdentityStmt stmt) {
Value l = stmt.getLeftOp();
Value r = stmt.getRightOp();
if (l instanceof Local) {
if (((Local) l).getType() instanceof IntegerType) {
TypeNode left = ClassHierarchy.v().typeNode(
(((Local) l).getType()));
TypeNode right = ClassHierarchy.v().typeNode(r.getType());
if (!right.hasAncestor_1(left)) {
if (fix) {
((soot.jimple.internal.JIdentityStmt) stmt)
.setLeftOp(insertCastAfter((Local) l,
getTypeForCast(left),
getTypeForCast(right), stmt));
} else {
error("Type Error(16)");
}
}
}
}
}
示例2: caseIdentityStmt
import soot.jimple.IdentityStmt; //导入依赖的package包/类
public void caseIdentityStmt(IdentityStmt stmt) {
Value l = stmt.getLeftOp();
Value r = stmt.getRightOp();
if (l instanceof Local) {
TypeVariable left = resolver.typeVariable((Local) l);
if (!(r instanceof CaughtExceptionRef)) {
TypeVariable right = resolver.typeVariable(r.getType());
right.addParent(left);
} else {
List<RefType> exceptionTypes = TrapManager.getExceptionTypesOf(stmt, stmtBody);
Iterator<RefType> typeIt = exceptionTypes.iterator();
while (typeIt.hasNext()) {
Type t = typeIt.next();
resolver.typeVariable(t).addParent(left);
}
if (uses) {
left.addParent(resolver.typeVariable(RefType.v("java.lang.Throwable")));
}
}
}
}
示例3: caseIdentityStmt
import soot.jimple.IdentityStmt; //导入依赖的package包/类
@Override
public void caseIdentityStmt(IdentityStmt stmt) {
Value lhs = stmt.getLeftOp();
Value rhs = stmt.getRightOp();
if (rhs instanceof CaughtExceptionRef) {
// save the caught exception with move-exception
Register localReg = regAlloc.asLocal(lhs);
addInsn(new Insn11x(Opcode.MOVE_EXCEPTION, localReg), stmt);
this.insnRegisterMap.put(insns.get(insns.size() - 1), LocalRegisterAssignmentInformation.v(localReg, (Local)lhs));
} else if (rhs instanceof ThisRef || rhs instanceof ParameterRef) {
/*
* do not save the ThisRef or ParameterRef in a local, because it always has a parameter register already.
* at least use the local for further reference in the statements
*/
Local localForThis = (Local) lhs;
regAlloc.asParameter(belongingMethod, localForThis);
parameterInstructionsList.add(LocalRegisterAssignmentInformation.v(regAlloc.asLocal(localForThis).clone(), localForThis));
} else {
throw new Error("unknown Value as right-hand side of IdentityStmt: " + rhs);
}
}
示例4: internalTransform
import soot.jimple.IdentityStmt; //导入依赖的package包/类
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
if (!b.getMethod().isSynchronized() || b.getMethod().isStatic())
return;
Iterator<Unit> it = b.getUnits().snapshotIterator();
while (it.hasNext()) {
Unit u = it.next();
if (u instanceof IdentityStmt)
continue;
// This the first real statement. If it is not a MonitorEnter
// instruction, we generate one
if (!(u instanceof EnterMonitorStmt)) {
b.getUnits().insertBeforeNoRedirect(Jimple.v().newEnterMonitorStmt(b.getThisLocal()), u);
// We also need to leave the monitor when the method terminates
UnitGraph graph = new ExceptionalUnitGraph(b);
for (Unit tail : graph.getTails())
b.getUnits().insertBefore(Jimple.v().newExitMonitorStmt(b.getThisLocal()), tail);
}
break;
}
}
示例5: getParameterLocal
import soot.jimple.IdentityStmt; //导入依赖的package包/类
/** Return LHS of the first identity stmt assigning from \@parameter i. **/
public Local getParameterLocal(int i)
{
for (Unit s : getUnits())
{
if (s instanceof IdentityStmt &&
((IdentityStmt)s).getRightOp() instanceof ParameterRef)
{
IdentityStmt is = (IdentityStmt)s;
ParameterRef pr = (ParameterRef)is.getRightOp();
if (pr.getIndex() == i)
return (Local)is.getLeftOp();
}
}
throw new RuntimeException("couldn't find parameterref" + i +"! in "+getMethod());
}
示例6: getParameterLocals
import soot.jimple.IdentityStmt; //导入依赖的package包/类
/**
* Get all the LHS of the identity statements assigning from parameter references.
*
* @return a list of size as per <code>getMethod().getParameterCount()</code> with all elements ordered as per the parameter index.
* @throws RuntimeException if a parameterref is missing
*/
public List<Local> getParameterLocals(){
final int numParams = getMethod().getParameterCount();
final List<Local> retVal = new ArrayList<Local>(numParams);
//Parameters are zero-indexed, so the keeping of the index is safe
for (Unit u : getUnits()){
if (u instanceof IdentityStmt){
IdentityStmt is = ((IdentityStmt)u);
if (is.getRightOp() instanceof ParameterRef){
ParameterRef pr = (ParameterRef) is.getRightOp();
retVal.add(pr.getIndex(), (Local) is.getLeftOp());
}
}
}
if (retVal.size() != numParams){
//FLANKER FIX BEGIN
//throw new RuntimeException("couldn't find parameterref! in " + getMethod());
return retVal;
//FLANKER FIX END
}
return retVal;
}
示例7: instrumentDummyMainMethod
import soot.jimple.IdentityStmt; //导入依赖的package包/类
public void instrumentDummyMainMethod(SootMethod mainMethod)
{
Body body = mainMethod.getActiveBody();
PatchingChain<Unit> units = body.getUnits();
for (Iterator<Unit> iter = units.snapshotIterator(); iter.hasNext(); )
{
Stmt stmt = (Stmt) iter.next();
if (stmt instanceof IdentityStmt)
{
continue;
}
//For the purpose of confusion dex optimization (because of the strategy of generating dummyMain method)
AssignStmt aStmt = (AssignStmt) stmt;
SootMethod fuzzyMe = generateFuzzyMethod(mainMethod.getDeclaringClass());
InvokeExpr invokeExpr = Jimple.v().newVirtualInvokeExpr(body.getThisLocal(), fuzzyMe.makeRef());
Unit assignU = Jimple.v().newAssignStmt(aStmt.getLeftOp(), invokeExpr);
units.insertAfter(assignU, aStmt);
break;
}
}
示例8: removeMoves
import soot.jimple.IdentityStmt; //导入依赖的package包/类
public static void removeMoves(SootMethod m) {
List<Unit> moves = new ArrayList<Unit>();
Body b = m.retrieveActiveBody();
PatchingChain<Unit> upc = b.getUnits();
Iterator<Unit> uit = upc.iterator();
while (uit.hasNext()) {
Unit u = (Unit)uit.next();
if (!(u instanceof IdentityStmt) && (u instanceof JAssignStmt) && SootUtilities.isMoveInst((JAssignStmt)u))
moves.add(u);
}
for (int i = 0; i < moves.size(); i++) {
JAssignStmt curr = (JAssignStmt)moves.get(i);
Local left = (Local)curr.leftBox.getValue();
Local right = (Local)curr.rightBox.getValue();
Unit currSucc = upc.getSuccOf(curr);
moveLabel(m, curr, currSucc);
upc.remove(curr);
List<ValueBox> useList = b.getUseBoxes();
for (int j = 0; j < useList.size(); j++) {
if (useList.get(j).getValue() == left)
useList.get(j).setValue(right);
}
}
}
示例9: caseIdentityStmt
import soot.jimple.IdentityStmt; //导入依赖的package包/类
public final void caseIdentityStmt(IdentityStmt s) {
statement = s;
Value lhs = s.getLeftOp();
Value rhs = s.getRightOp();
if( !( lhs.getType() instanceof RefType )
&& !(lhs.getType() instanceof ArrayType ) ) {
caseUninterestingStmt( s );
return;
}
Local llhs = (Local) lhs;
if( rhs instanceof CaughtExceptionRef ) {
caseCatchStmt( llhs, (CaughtExceptionRef) rhs );
} else {
IdentityRef rrhs = (IdentityRef) rhs;
caseIdentityStmt( llhs, rrhs );
}
}
示例10: getFirstNonIdentityStmt
import soot.jimple.IdentityStmt; //导入依赖的package包/类
public static Stmt getFirstNonIdentityStmt(SootMethod sootMethod)
{
Stmt rtVal = null;
Body b = sootMethod.retrieveActiveBody();
PatchingChain<Unit> units = b.getUnits();
for (Iterator<Unit> iter = units.iterator(); iter.hasNext(); )
{
Stmt stmt = (Stmt) iter.next();
if ( ! (stmt instanceof IdentityStmt) )
{
rtVal = stmt;
}
}
return rtVal;
}
示例11: initialSeeds
import soot.jimple.IdentityStmt; //导入依赖的package包/类
@Override
public Set<Unit> initialSeeds(AnalysisContext config) {
Set<Unit> res = Sets.newHashSet();
for (Iterator<MethodOrMethodContext> iter = Scene.v().getReachableMethods().listener(); iter.hasNext();) {
SootMethod m = iter.next().method();
if (AnalysisUtil.methodMayBeCallableFromApplication(m) && m.hasActiveBody()) {
ActiveBodyVerifier.assertActive(m);
PatchingChain<Unit> units = m.getActiveBody().getUnits();
for (Unit u : units) {
if (u instanceof IdentityStmt) {
IdentityStmt idStmt = (IdentityStmt) u;
if (idStmt.getRightOp().toString().contains("@parameter"))
res.add(u);
}
}
}
}
System.out.println("forwards from all parameters initial seeds: " + res.size());
return res;
}
示例12: propagateNormalFlow
import soot.jimple.IdentityStmt; //导入依赖的package包/类
@Override
public KillGenInfo propagateNormalFlow(Trackable taint, Unit curr, Unit succ) {
if (!(curr instanceof IdentityStmt))
return identity();
IdentityStmt idStmt = (IdentityStmt) curr;
Value left = AnalysisUtil.getBackwardsBase(idStmt.getLeftOp());
Taint t = (Taint) taint;
if (!AnalysisUtil.maybeSameLocation(t.value, left))
return identity();
if (idStmt.getRightOp() instanceof ParameterRef) {
if (t.value instanceof Local) {
SootMethod m = context.icfg.getMethodOf(idStmt);
if (AnalysisUtil.methodMayBeCallableFromApplication(m) && transitiveSinkCaller.isTransitiveCallerOfAnySink(m)) {
context.reporter.reportTrackable(new Report(context, taint, curr));
}
}
}
return identity();
}
示例13: getParameterValues
import soot.jimple.IdentityStmt; //导入依赖的package包/类
private Value[] getParameterValues(SootMethod destinationMethod) {
int paramsFound = 0;
Value[] result = new Value[destinationMethod.getParameterCount()];
for (Unit unit : destinationMethod.getActiveBody().getUnits()) {
if (!(unit instanceof IdentityStmt))
continue;
Value rightOp = ((IdentityStmt) unit).getRightOp();
if (!(rightOp instanceof ParameterRef))
continue;
ParameterRef paramRef = (ParameterRef) rightOp;
result[paramRef.getIndex()] = paramRef;
paramsFound++;
if (paramsFound == result.length)
break;
}
return result;
}
示例14: findparamlocal
import soot.jimple.IdentityStmt; //导入依赖的package包/类
public static Local findparamlocal(PatchingChain<Unit> units) {
// TODO HACK! assume the second identity stmt is always for the required
// parameter
boolean thislocalseen = false;
for (Unit unit : units)
{
if (unit instanceof IdentityStmt)
{
if (thislocalseen)
{
IdentityStmt istmt = (IdentityStmt) unit;
return (Local) istmt.getLeftOp();
}
else
{
thislocalseen = true;
}
}
}
throw new RuntimeException("Parameter Local not found (maybe method has no parameters?)");
}
示例15: findsecondparamlocal
import soot.jimple.IdentityStmt; //导入依赖的package包/类
public static Local findsecondparamlocal(PatchingChain<Unit> units)
{
// TODO HACK! assume the second identity stmts are in the order
// "this","param1","param2"...
int localsseen = 0;
for (Unit unit : units)
{
if (unit instanceof IdentityStmt)
{
if (localsseen == 2)
{
IdentityStmt istmt = (IdentityStmt) unit;
return (Local) istmt.getLeftOp();
}
localsseen++;
}
}
throw new RuntimeException("Parameter Local not found (maybe method has no parameters?)");
}