Java 类soot.jimple.internal.JIfStmt 实例源码

项目:JAADAS    文件:IfTestInstruction.java   
protected IfStmt ifStatement(DexBody body) {
      Instruction22t i = (Instruction22t) instruction;
      Local one = body.getRegisterLocal(i.getRegisterA());
      Local other = body.getRegisterLocal(i.getRegisterB());
      BinopExpr condition = getComparisonExpr(one, other);
      jif = (JIfStmt)Jimple.v().newIfStmt(condition, targetInstruction.getUnit());
      // setUnit() is called in ConditionalJumpInstruction

if (IDalvikTyper.ENABLE_DVKTYPER) {
    Debug.printDbg(IDalvikTyper.DEBUG, "constraint if: "+ jif +" condition: "+ condition);
    DalvikTyper.v().addConstraint(condition.getOp1Box(), condition.getOp2Box());
      }


      return jif;

  }
项目:cheetah    文件:AndroidEntryPointCreatorJIT.java   
private void createIfStmt(Unit target, Body body) {
    if (target == null) {
        return;
    }
    JEqExpr cond = new JEqExpr(intCounter, IntConstant.v(conditionCounter++));
    JIfStmt ifStmt = new JIfStmt(cond, target);
    body.getUnits().add(ifStmt);
}
项目:JAADAS    文件:AndroidEntryPointCreator.java   
private void createIfStmt(Unit target){
    if(target == null){
        return;
    }
    JEqExpr cond = new JEqExpr(intCounter, IntConstant.v(conditionCounter++));
    JIfStmt ifStmt = new JIfStmt(cond, target);
    body.getUnits().add(ifStmt);
}
项目:JAADAS    文件:NullnessAnalysis.java   
private void handleIfStmt(JIfStmt ifStmt, AnalysisInfo in, AnalysisInfo out, AnalysisInfo outBranch) {
    Value condition = ifStmt.getCondition();
    if(condition instanceof JInstanceOfExpr) {
        //a instanceof X ; if this succeeds, a is not null
        JInstanceOfExpr expr = (JInstanceOfExpr) condition;
        handleInstanceOfExpression(expr, in, out, outBranch);
    } else if(condition instanceof JEqExpr || condition instanceof JNeExpr) {
        //a==b or a!=b
        AbstractBinopExpr eqExpr = (AbstractBinopExpr) condition;
        handleEqualityOrNonEqualityCheck(eqExpr, in, out, outBranch);
    }       
}
项目:JAADAS    文件:IfTestzInstruction.java   
protected IfStmt ifStatement(DexBody body) {
      Instruction21t i = (Instruction21t) instruction;
      BinopExpr condition = getComparisonExpr(body, i.getRegisterA());
      jif = (JIfStmt) Jimple.v().newIfStmt(condition,
                                  targetInstruction.getUnit());
      // setUnit() is called in ConditionalJumpInstruction


if (IDalvikTyper.ENABLE_DVKTYPER) {
    Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ jif);
         int op = instruction.getOpcode().value;
         switch (op) {
         case 0x38:
         case 0x39:
           //DalvikTyper.v().addConstraint(condition.getOp1Box(), condition.getOp2Box());
           break;
         case 0x3a:
         case 0x3b:
         case 0x3c:
         case 0x3d:
           DalvikTyper.v().setType(condition.getOp1Box(), BooleanType.v(), true);
           break;
         default:
           throw new RuntimeException("error: unknown op: 0x"+ Integer.toHexString(op));
         }
      }

return jif;

  }
项目:petablox    文件:DomP.java   
@Override
public String toFIString(Unit u) {       
    StringBuilder sb = new StringBuilder();
    boolean printId = Utils.buildBoolProperty("petablox.printrel.printID", false);
    if (printId) sb.append("(" + indexOf(u) + ")");
    String type;
    if(u instanceof JAssignStmt)
        type = "Assign";
    else if(u instanceof JBreakpointStmt)
        type = "Breakpoint";
    else if(u instanceof JGotoStmt)
        type = "Goto";
    else if(u instanceof JIfStmt) 
        type = "If";
    else if(u instanceof JIdentityStmt) 
        type = "Identity";
    else if(u instanceof JInvokeStmt) 
        type = "Invoke";
    else if(u instanceof JLookupSwitchStmt) 
        type = "LookupSwitch";
    else if(u instanceof JNopStmt)
        type = "Nop";
    else if(u instanceof JRetStmt) 
        type = "Return";
    else if(u instanceof JTableSwitchStmt) 
        type = "TablelSwitch";
    else if(u instanceof JThrowStmt) 
        type = "Throw";
    else
        type = "Other";
    sb.append(type);
    sb.append(": " + SootUtilities.getMethod(u).getName() + "@" + SootUtilities.getMethod(u).getDeclaringClass().getName());
    return sb.toString();
}
项目:soot-inflow    文件:AndroidEntryPointCreator.java   
private void createIfStmt(Unit target){
    if(target == null){
        return;
    }
    JEqExpr cond = new JEqExpr(intCounter, IntConstant.v(conditionCounter++));
    JIfStmt ifStmt = new JIfStmt(cond, target);
    body.getUnits().add(ifStmt);
}
项目:JAADAS    文件:DefaultEntryPointCreator.java   
@Override
protected SootMethod createDummyMainInternal(SootMethod mainMethod) {
    Map<String, Set<String>> classMap =
            SootMethodRepresentationParser.v().parseClassNames(methodsToCall, false);

    // create new class:
    Body body = mainMethod.getActiveBody();
        LocalGenerator generator = new LocalGenerator(body);
    HashMap<String, Local> localVarsForClasses = new HashMap<String, Local>();

    // create constructors:
    for(String className : classMap.keySet()){
        SootClass createdClass = Scene.v().forceResolve(className, SootClass.BODIES);
        createdClass.setApplicationClass();

        Local localVal = generateClassConstructor(createdClass, body);
        if (localVal == null) {
            logger.warn("Cannot generate constructor for class: {}", createdClass);
            continue;
        }
        localVarsForClasses.put(className, localVal);
    }

    // add entrypoint calls
    int conditionCounter = 0;
    JNopStmt startStmt = new JNopStmt();
    JNopStmt endStmt = new JNopStmt();
    Value intCounter = generator.generateLocal(IntType.v());
    body.getUnits().add(startStmt);
    for (Entry<String, Set<String>> entry : classMap.entrySet()){
        Local classLocal = localVarsForClasses.get(entry.getKey());
        for (String method : entry.getValue()){
            SootMethodAndClass methodAndClass =
                    SootMethodRepresentationParser.v().parseSootMethodString(method);
            SootMethod currentMethod = findMethod(Scene.v().getSootClass(methodAndClass.getClassName()),
                    methodAndClass.getSubSignature());
            if (currentMethod == null) {
                logger.warn("Entry point not found: {}", method);
                continue;
            }

            JEqExpr cond = new JEqExpr(intCounter, IntConstant.v(conditionCounter));
            conditionCounter++;
            JNopStmt thenStmt = new JNopStmt();
            JIfStmt ifStmt = new JIfStmt(cond, thenStmt);
            body.getUnits().add(ifStmt);
            buildMethodCall(currentMethod, body, classLocal, generator);
            body.getUnits().add(thenStmt);
        }
    }
    body.getUnits().add(endStmt);
    JGotoStmt gotoStart = new JGotoStmt(startStmt);
    body.getUnits().add(gotoStart);

    body.getUnits().add(Jimple.v().newReturnVoidStmt());
    NopEliminator.v().transform(body);
    eliminateSelfLoops(body);
    return mainMethod;
}
项目:petablox    文件:VisitorHandler.java   
private void visitIfInsts(JIfStmt s) {
    if (ifVisitors != null) {
        for (IIfInstVisitor v : ifVisitors)
            v.visit(s);
    }
}
项目:petablox    文件:RelIfInst.java   
public void visit(JIfStmt s) {
    add(s, s.getCondition(), s.getTarget());
}
项目:soot-inflow    文件:DefaultEntryPointCreator.java   
/**
 * Soot requires a main method, so we create a dummy method which calls all entry functions.
 * 
 * @param classMap
 *            the methods to call (signature as String)
 * @param createdClass
 *            the class which contains the methods
 * @return list of entryPoints
 */
@Override
protected SootMethod createDummyMainInternal(List<String> methods) {
    Map<String, List<String>> classMap =
            SootMethodRepresentationParser.v().parseClassNames(methods, false);

    // create new class:
        JimpleBody body = Jimple.v().newBody();
        SootMethod mainMethod = createEmptyMainMethod(body);

        LocalGenerator generator = new LocalGenerator(body);
    HashMap<String, Local> localVarsForClasses = new HashMap<String, Local>();

    // create constructors:
    for(String className : classMap.keySet()){
        SootClass createdClass = Scene.v().forceResolve(className, SootClass.BODIES);
        createdClass.setApplicationClass();

        Local localVal = generateClassConstructor(createdClass, body);
        if (localVal == null) {
            logger.warn("Cannot generate constructor for class: {}", createdClass);
            continue;
        }
        localVarsForClasses.put(className, localVal);
    }

    // add entrypoint calls
    int conditionCounter = 0;
    JNopStmt startStmt = new JNopStmt();
    JNopStmt endStmt = new JNopStmt();
    Value intCounter = generator.generateLocal(IntType.v());
    body.getUnits().add(startStmt);
    for (Entry<String, List<String>> entry : classMap.entrySet()){
        Local classLocal = localVarsForClasses.get(entry.getKey());
        for (String method : entry.getValue()){
            SootMethodAndClass methodAndClass =
                    SootMethodRepresentationParser.v().parseSootMethodString(method);
            SootMethod currentMethod = findMethod(Scene.v().getSootClass(methodAndClass.getClassName()),
                    methodAndClass.getSubSignature());
            if (currentMethod == null) {
                logger.warn("Entry point not found: {}", method);
                continue;
            }

            JEqExpr cond = new JEqExpr(intCounter, IntConstant.v(conditionCounter));
            conditionCounter++;
            JNopStmt thenStmt = new JNopStmt();
            JIfStmt ifStmt = new JIfStmt(cond, thenStmt);
            body.getUnits().add(ifStmt);
            buildMethodCall(currentMethod, body, classLocal, generator);
            body.getUnits().add(thenStmt);
        }
    }
    body.getUnits().add(endStmt);
    JGotoStmt gotoStart = new JGotoStmt(startStmt);
    body.getUnits().add(gotoStart);

    body.getUnits().add(Jimple.v().newReturnVoidStmt());
    return mainMethod;
}
项目:petablox    文件:IIfInstVisitor.java   
public void visit(JIfStmt s);