Java 类soot.jimple.AddExpr 实例源码

项目:FuzzDroid    文件:TimingBombTransformer.java   
private void prepareAlarmManagerSet(Body body, InvokeStmt setStmt, SootMethodRef reportRef) {
    Value oldVal = setStmt.getInvokeExpr().getArg(1);

    Local longLocal = UtilInstrumenter.generateFreshLocal(body, LongType.v());
    SootMethod currentTimeMillis = Scene.v().getMethod("<java.lang.System: long currentTimeMillis()>");     
    StaticInvokeExpr timeInvoke = Jimple.v().newStaticInvokeExpr(currentTimeMillis.makeRef());      
    AssignStmt timeInitalize = Jimple.v().newAssignStmt(longLocal, timeInvoke);

    AddExpr addTime = Jimple.v().newAddExpr(longLocal, LongConstant.v(2000L));
    AssignStmt timeAssign = Jimple.v().newAssignStmt(longLocal, addTime);


    body.getUnits().insertBefore(timeInitalize, setStmt);
    body.getUnits().insertBefore(timeAssign, setStmt);

    InvokeExpr expr = setStmt.getInvokeExpr();
    expr.setArg(0, IntConstant.v(0));
    expr.setArg(1, longLocal);

    // Report the change
    InvokeStmt reportStmt = Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(
            reportRef, oldVal, longLocal));
    reportStmt.addTag(new InstrumentedCodeTag());
    body.getUnits().insertAfter(reportStmt, setStmt);
}
项目:FuzzDroid    文件:JimpleExprVisitorImpl.java   
@Override
public void caseAddExpr(AddExpr v) {
    Value op1 = v.getOp1();
    Value op2 = v.getOp2();

    if(stmtVisitor.hasBindingForValue(op1)) {
        this.result = stmtVisitor.getLatestBindingForValue(op1);
    }else if(stmtVisitor.hasBindingForValue(op2)) {
        this.result = stmtVisitor.getLatestBindingForValue(op2);
    }else
        throw new RuntimeException("This should not happen...");

}
项目:JAADAS    文件:AsmMethodSource.java   
private void convertIincInsn(IincInsnNode insn) {
    Local local = getLocal(insn.var);
    assignReadOps(local);
    if (!units.containsKey(insn)) {
        AddExpr add = Jimple.v().newAddExpr(local, IntConstant.v(insn.incr));
        setUnit(insn, Jimple.v().newAssignStmt(local, add));
    }
}
项目:petablox    文件:RelAddExpr.java   
@Override
public void visit(Value e) {
    if (e instanceof AddExpr) {
        AddExpr ae = (AddExpr) e;
        add(e, ae.getOp1(), ae.getOp2());
    }
}
项目:JAADAS    文件:ValueTemplatePrinter.java   
public void caseAddExpr(AddExpr v) {
    printBinaryExpr(v);
}
项目:JAADAS    文件:UseChecker.java   
private void handleBinopExpr(BinopExpr be, Stmt stmt, Type tlhs)
{
    Value opl = be.getOp1(), opr = be.getOp2();
    Type tl = AugEvalFunction.eval_(this.tg, opl, stmt, this.jb),
        tr = AugEvalFunction.eval_(this.tg, opr, stmt, this.jb);

    if ( be instanceof AddExpr
        || be instanceof SubExpr
        || be instanceof MulExpr
        || be instanceof DivExpr
        || be instanceof RemExpr
        || be instanceof GeExpr
        || be instanceof GtExpr
        || be instanceof LeExpr
        || be instanceof LtExpr
        || be instanceof ShlExpr
        || be instanceof ShrExpr
        || be instanceof UshrExpr )
    {
        if ( tlhs instanceof IntegerType )
        {
            be.setOp1(this.uv.visit(opl, IntType.v(), stmt));
            be.setOp2(this.uv.visit(opr, IntType.v(), stmt));
        }
    }
    else if ( be instanceof CmpExpr
        || be instanceof CmpgExpr
        || be instanceof CmplExpr )
    {
        // No checks in the original assigner
    }
    else if ( be instanceof AndExpr
        || be instanceof OrExpr
        || be instanceof XorExpr )
    {
        be.setOp1(this.uv.visit(opl, tlhs, stmt));
        be.setOp2(this.uv.visit(opr, tlhs, stmt));
    }
    else if ( be instanceof EqExpr
        || be instanceof NeExpr )
    {
        if ( tl instanceof BooleanType && tr instanceof BooleanType )
        { }
        else if ( tl instanceof Integer1Type || tr instanceof Integer1Type )
        { }
        else if ( tl instanceof IntegerType )
        {
            be.setOp1(this.uv.visit(opl, IntType.v(), stmt));
            be.setOp2(this.uv.visit(opr, IntType.v(), stmt));
        }
    }
}
项目:JAADAS    文件:ExprVisitor.java   
@Override
public void caseAddExpr(AddExpr ae) {
       stmtV.addInsn(buildCalculatingBinaryInsn("ADD", ae.getOp1(), ae.getOp2()), origStmt);
}
项目:JAADAS    文件:SimplifyExpressions.java   
public NumericConstant getResult(BinopExpr binop){
    if(DEBUG)
        System.out.println("Binop expr"+binop);
    Value leftOp = binop.getOp1();
    Value rightOp = binop.getOp2();

    int op = 0;
    if(binop instanceof AddExpr){
        op=1;
    }
    else if(binop instanceof SubExpr || 
            binop instanceof DCmpExpr || binop instanceof DCmpgExpr
            || binop instanceof DCmplExpr){
        op=2;
    }
    else if(binop instanceof MulExpr){
        op=3;
    }

    if(op == 0){
        if(DEBUG){
            System.out.println("not add sub or mult");
            System.out.println(binop.getClass().getName());
        }           
        return null;
    }
    NumericConstant constant = null;
    if(leftOp instanceof LongConstant  && rightOp instanceof LongConstant){
        if(DEBUG)
            System.out.println("long constants!!");
        if(op ==1)
            constant = ((LongConstant)leftOp).add((LongConstant)rightOp);
        else if(op ==2)
            constant = ((LongConstant)leftOp).subtract((LongConstant)rightOp);
        else if (op ==3)
            constant = ((LongConstant)leftOp).multiply((LongConstant)rightOp);
    }
    else if(leftOp instanceof DoubleConstant  && rightOp instanceof DoubleConstant){
        if(DEBUG)
            System.out.println("double constants!!");
        if(op ==1)
            constant = ((DoubleConstant)leftOp).add((DoubleConstant)rightOp);
        else if(op ==2)
            constant = ((DoubleConstant)leftOp).subtract((DoubleConstant)rightOp);
        else if (op ==3)
            constant = ((DoubleConstant)leftOp).multiply((DoubleConstant)rightOp);

    }
    else if(leftOp instanceof FloatConstant  && rightOp instanceof FloatConstant){
        if(DEBUG)
            System.out.println("Float constants!!");
        if(op ==1)
            constant = ((FloatConstant)leftOp).add((FloatConstant)rightOp);
        else if(op ==2)
            constant = ((FloatConstant)leftOp).subtract((FloatConstant)rightOp);
        else if (op ==3)
            constant = ((FloatConstant)leftOp).multiply((FloatConstant)rightOp);
    }
    else if(leftOp instanceof IntConstant  && rightOp instanceof IntConstant){
        if(DEBUG)
            System.out.println("Integer constants!!");
        if(op ==1)
            constant = ((IntConstant)leftOp).add((IntConstant)rightOp);
        else if(op ==2)
            constant = ((IntConstant)leftOp).subtract((IntConstant)rightOp);
        else if (op ==3)
            constant = ((IntConstant)leftOp).multiply((IntConstant)rightOp);
    }

    return constant;
}
项目:JAADAS    文件:UnitThrowAnalysis.java   
public void caseAddExpr(AddExpr expr) {
    caseBinopExpr(expr);
}
项目:bixie    文件:SootValueSwitch.java   
@Override
public void caseAddExpr(AddExpr arg0) {
    translateBinOp(arg0);
}
项目:jar2bpl    文件:SootValueSwitch.java   
@Override
public void caseAddExpr(AddExpr arg0) {
    translateBinOp(arg0);
}
项目:jgs    文件:AnnotationValueSwitch.java   
/**
 * DOC
 * 
 * @see soot.jimple.ExprSwitch#caseAddExpr(soot.jimple.AddExpr)
 */
@Override
public void caseAddExpr(AddExpr v) {
    v.getOp1().apply(this);
    v.getOp2().apply(this);
}
项目:jgs    文件:SecurityConstraintValueWriteSwitch.java   
@Override
public void caseAddExpr(AddExpr v) {
    throwInvalidWriteException(v);
}
项目:jgs    文件:SecurityConstraintValueReadSwitch.java   
@Override
public void caseAddExpr(AddExpr v) {
    handleBinaryExpr(v.getOp1(), v.getOp2());
}
项目:jgs    文件:AnnotationValueSwitch.java   
/**
 * It is not neccessary to treat arithmetic expressions. The SecurityLevels
 * of this expressions are treated at an other place.
 * @param v an arithmetic expression
 */
@Override
public void caseAddExpr(AddExpr v) {
    logger.finest("Add Expr identified " + callingStmt.toString());
    rightElement = RightElement.NOT;
}
项目:vasco    文件:SignAnalysis.java   
private Sign signOf(Value value, Map<Local, Sign> dfv) {
    if (value instanceof Local) {
        // if the value is a local variable, then look-up the data-flow map
        Local local = (Local) value;
        if (dfv.containsKey(local)) {
            return dfv.get(local);
        } else {
            return Sign.TOP;
        }
    } else if (value instanceof NumericConstant) {
        // If the value is a constant, we can get a definite sign
        NumericConstant num = (NumericConstant) value;
        NumericConstant zero = IntConstant.v(0);
        NumericConstant one = IntConstant.v(1);
        if (num.lessThan(zero).equals(one)) {
            return NEGATIVE;
        } else if (num.greaterThan(zero).equals(one)) {
            return POSITIVE;
        } else {
            return ZERO;
        }
    } else if (value instanceof BinopExpr) {
        BinopExpr expr = (BinopExpr) value;
        Value op1 = expr.getOp1();
        Value op2 = expr.getOp2();
        Sign sign1 = signOf(op1, dfv);
        Sign sign2 = signOf(op2, dfv);
        if (value instanceof AddExpr) {
            // Handle arithmetic plus
            return sign1.plus(sign2);
        } else if (value instanceof MulExpr) {
            // Handle arithmetic multiplication
            return sign1.mult(sign2);
        } else {
            // We do not handle other types of binary expressions
            return BOTTOM;
        }
    } else if (value instanceof UnopExpr) { 
        if (value instanceof AbstractNegExpr) {
            // Handle unary minus
            Value op = ((AbstractNegExpr) value).getOp();
            Sign sign = signOf(op, dfv);
            return sign.negate();
        } else {
            // We do not handle other types of binary expressions
            return BOTTOM;
        }
    } else {
        // We do not handle other types of compound expressions
        return BOTTOM;
    }
}
项目:jgs    文件:SecurityLevelValueWriteSwitch.java   
/**
 * The method should update the <em>security level</em> of a {@link AddExpr}
 * , but it is not possible to update the level of an expression.
 * 
 * @param v
 *            The expression for which the <em>security level</em> should be
 *            updated.
 * @see soot.jimple.ExprSwitch#caseAddExpr(soot.jimple.AddExpr)
 * @throws InvalidSwitchException
 *             Always, because the update is not possible.
 */
@Override
public void caseAddExpr(AddExpr v) {
    throw new SwitchException(getMsg("exception.analysis.switch.update_error",
                                     this.getClass().getSimpleName(),
                                     v.getClass().getSimpleName(),
                                     v.toString(),
                                     getSourceLine()));
}
项目:jgs    文件:SecurityLevelValueReadSwitch.java   
/**
 * Looks up the <em>security level</em> for the given binary expression and
 * stores the level in {@link SecurityLevelValueReadSwitch#level}. For a
 * {@link AddExpr} this is the strongest operand <em>security level</em> of
 * the given binary expression.
 * 
 * @param v
 *            The expression for which the <em>security level</em> should be
 *            looked up.
 * @see soot.jimple.ExprSwitch#caseAddExpr(soot.jimple.AddExpr)
 * @see SecurityLevelValueReadSwitch#handleBinaryOperation(BinopExpr)
 */
@Override
public void caseAddExpr(AddExpr v) {
    handleBinaryOperation(v);
}