Java 类soot.jimple.CastExpr 实例源码

项目:JAADAS    文件:BaseSelector.java   
/**
 * the operations that are not relevant for analysis like "not" or casts
 * are removed - array refs are only removed if explicitly stated
 * @param val the value which should be pruned
 * @param keepArrayRef if false then array refs are pruned to the base array object
 * @return the value (possibly pruned to base object)
 */ //we want to keep ArrayRef for objects on the right side of the assignment
public static Value selectBase(Value val, boolean keepArrayRef){
    //we taint base of array instead of array elements
    if (val instanceof ArrayRef && !keepArrayRef) {
        return selectBase(((ArrayRef) val).getBase(), keepArrayRef);
    }

    if (val instanceof CastExpr) {
        return selectBase(((CastExpr) val).getOp(), keepArrayRef);
    }

    // Check for unary operators like "not" or "length"
    if (val instanceof UnopExpr)
        return selectBase(((UnopExpr) val).getOp(), keepArrayRef);

    return val;
}
项目:JAADAS    文件:CastInstruction.java   
public void jimplify (DexBody body) {
     TwoRegisterInstruction i = (TwoRegisterInstruction)instruction;
     int dest = i.getRegisterA();
     int source = i.getRegisterB();
     Type targetType = getTargetType();
     CastExpr cast = Jimple.v().newCastExpr(body.getRegisterLocal(source), targetType);
     assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cast);
     assign.addTag (getTag());
     setUnit(assign);
     addTags(assign);
     body.add(assign);

     if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint cast: "+ assign +" castexpr type: "+ cast.getType()+" cast type: "+ cast.getCastType());
       int op = (int)instruction.getOpcode().value;
       DalvikTyper.v().setType(assign.getLeftOpBox(), cast.getType(), false);
       //DalvikTyper.v().captureAssign((JAssignStmt)assign, op);
     }
 }
项目:JAADAS    文件:CheckCastInstruction.java   
public void jimplify (DexBody body) {
      if(!(instruction instanceof Instruction21c))
          throw new IllegalArgumentException("Expected Instruction21c but got: "+instruction.getClass());

      Instruction21c checkCastInstr = (Instruction21c)instruction;

      Local castValue = body.getRegisterLocal(checkCastInstr.getRegisterA());
      Type checkCastType = DexType.toSoot((TypeReference) checkCastInstr.getReference());

      CastExpr castExpr =  Jimple.v().newCastExpr(castValue, checkCastType);

      //generate "x = (Type) x"
      //splitter will take care of the rest
      assign = Jimple.v().newAssignStmt(castValue, castExpr);

      setUnit(assign);
      addTags(assign);
      body.add(assign);


      if (IDalvikTyper.ENABLE_DVKTYPER) {
    Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
          DalvikTyper.v().setType(assign.getLeftOpBox(), checkCastType, false);
}

  }
项目:JAADAS    文件:DavaBody.java   
private void javafy_expr(ValueBox vb) {
    Expr e = (Expr) vb.getValue();

    if (e instanceof BinopExpr)
        javafy_binop_expr(vb);
    else if (e instanceof UnopExpr)
        javafy_unop_expr(vb);
    else if (e instanceof CastExpr)
        javafy_cast_expr(vb);
    else if (e instanceof NewArrayExpr)
        javafy_newarray_expr(vb);
    else if (e instanceof NewMultiArrayExpr)
        javafy_newmultiarray_expr(vb);
    else if (e instanceof InstanceOfExpr)
        javafy_instanceof_expr(vb);
    else if (e instanceof InvokeExpr)
        javafy_invoke_expr(vb);
    else if (e instanceof NewExpr)
        javafy_new_expr(vb);
}
项目:JAADAS    文件:UnitThrowAnalysis.java   
public void caseCastExpr(CastExpr expr) {
    result = result.add(mgr.RESOLVE_CLASS_ERRORS);
    Type fromType = expr.getOp().getType();
    Type toType = expr.getCastType();
    if (toType instanceof RefLikeType) {
    // fromType might still be unknown when we are called,
    // but toType will have a value.
    FastHierarchy h = Scene.v().getOrMakeFastHierarchy();
    if (fromType == null || fromType instanceof UnknownType ||
        ((! (fromType instanceof NullType)) &&
         (! h.canStoreType(fromType, toType)))) {
        result = result.add(mgr.CLASS_CAST_EXCEPTION);
    }
    }
    result = result.add(mightThrow(expr.getOp()));
}
项目:soot-inflow    文件:PathSummary.java   
/**
 * 
 * @param value
 * @param currUnit currUnit must be after the TaintValue's activation
 * @return ==
 */
public TaintValue isTainted(Value value, Unit currUnit){
    TaintValue result = null;
    Value handledValue = null;
    //[start] array additional, CastExpt
    if(value instanceof ArrayRef){
        handledValue = ((ArrayRef) value).getBase();
    }else if(value instanceof CastExpr){
        handledValue = ((CastExpr) value).getOp();
    }else{
        handledValue = value;
    }
    //[end]
    for(TaintValue tv : taintsSet){
        Unit activation = tv.getActivation();
        Value tmp = tv.getTaintValue();
        if(tmp.toString().equals(handledValue.toString()) && allUnits.indexOf(activation) < allUnits.indexOf(currUnit)){
            result = tv;
            break;
        }
    }
    return result;
}
项目:vasco    文件:CopyConstantAnalysis.java   
private void assign(Local lhs, Value rhs, Map<Local, Constant> input, Map<Local, Constant> output) {
    // First remove casts, if any.
    if (rhs instanceof CastExpr) {
        rhs = ((CastExpr) rhs).getOp();
    }
    // Then check if the RHS operand is a constant or local
    if (rhs instanceof Constant) {
        // If RHS is a constant, it is a direct gen
        output.put(lhs, (Constant) rhs);
    } else if (rhs instanceof Local) {
        // Copy constant-status of RHS to LHS (indirect gen), if exists
        if(input.containsKey(rhs)) {
            output.put(lhs, input.get(rhs));
        }
    } else {
        // RHS is some compound expression, then LHS is non-constant (only kill)
        output.put(lhs, null);
    }           
}
项目:FuzzDroid    文件:JimpleExprVisitorImpl.java   
@Override
public void caseCastExpr(CastExpr v) {
    //just propagate the taint value of previous statement
    Stmt prevStmt = stmtVisitor.getPreviousDataFlowPathElement(currentStatement);
    if(prevStmt == null)
        throw new RuntimeException("there is no previous statement");
    else{           
        this.result = stmtVisitor.getBindingForTaintedValue(prevStmt);
        if(this.result == null)
            throw new RuntimeException("double check this here");
    }
}
项目:cheetah    文件:AnalysisTask.java   
/***** Taints *****/

    private FlowAbstraction getTaint(Value right, Value left, FlowAbstraction source, Unit src) {
        FlowAbstraction fa = null;

        if (right instanceof CastExpr)
            right = ((CastExpr) right).getOp();

        if (right instanceof Local && source.getLocal() == right) {
            fa = FlowAbstraction.v(source.getSource(), left, src, icfg.getMethodOf(src), source);
            fa = fa.append(source.getFields());
        } else if (right instanceof InstanceFieldRef) {
            InstanceFieldRef ifr = (InstanceFieldRef) right;
            if (source.hasPrefix(ifr)) {
                fa = FlowAbstraction.v(source.getSource(), left, src, icfg.getMethodOf(src), source);
                fa = fa.append(source.getPostfix(ifr));
            }
        } else if (right instanceof StaticFieldRef) {
            StaticFieldRef sfr = (StaticFieldRef) right;
            if (source.hasPrefix(sfr)) {
                fa = FlowAbstraction.v(source.getSource(), left, src, icfg.getMethodOf(src), source);
                fa = fa.append(source.getPostfix(sfr));
            }
        } else if (right instanceof ArrayRef) {
            ArrayRef ar = (ArrayRef) right;
            if (ar.getBase() == source.getLocal())
                fa = FlowAbstraction.v(source.getSource(), left, src, icfg.getMethodOf(src), source);
        }
        return fa;
    }
项目:JAADAS    文件:ValueTemplatePrinter.java   
public void caseCastExpr(CastExpr v) {
    String oldName = varName;

    suggestVariableName("type");
    String lhsName = varName;
    ttp.setVariableName(varName);
    v.getType().apply(ttp);

    String rhsName = printValueAssignment(v.getOp(), "op");

    p.println("Value "+oldName+" = Jimple.v().newCastExpr("+lhsName+","+rhsName+");");

    varName = oldName;      
}
项目:JAADAS    文件:ExprVisitor.java   
@Override
public void caseCastExpr(CastExpr ce) {
    Type castType = ce.getCastType();
    Value source = ce.getOp();
    constantV.setOrigStmt(origStmt);
    Register sourceReg = regAlloc.asImmediate(source, constantV);
    if (SootToDexUtils.isObject(castType)) {
        castObject(sourceReg, castType);
    } else {
        castPrimitive(sourceReg, source, castType);
    }
}
项目:JAADAS    文件:CastAndReturnInliner.java   
@Override
protected void internalTransform(Body body, String phaseName,
        Map<String, String> options) {
    Iterator<Unit> it = body.getUnits().snapshotIterator();
    while (it.hasNext()) {
        Unit u = it.next();
        if (u instanceof GotoStmt) {
            GotoStmt gtStmt = (GotoStmt) u;
            if (gtStmt.getTarget() instanceof AssignStmt) {
                AssignStmt assign = (AssignStmt) gtStmt.getTarget();
                if (assign.getRightOp() instanceof CastExpr) {
                    CastExpr ce = (CastExpr) assign.getRightOp();
                    // We have goto that ends up at a cast statement
                    Unit nextStmt = body.getUnits().getSuccOf(assign);
                    if (nextStmt instanceof ReturnStmt) {
                        ReturnStmt retStmt = (ReturnStmt) nextStmt;
                        if (retStmt.getOp() == assign.getLeftOp()) {
                            // We need to replace the GOTO with the return
                            ReturnStmt newStmt = (ReturnStmt) retStmt.clone();
                            newStmt.setOp(ce.getOp());

                            for (Trap t : body.getTraps())
                                for (UnitBox ubox : t.getUnitBoxes())
                                    if (ubox.getUnit() == gtStmt)
                                        ubox.setUnit(newStmt);

                            while (!gtStmt.getBoxesPointingToThis().isEmpty())
                                gtStmt.getBoxesPointingToThis().get(0).setUnit(newStmt);
                            body.getUnits().swapWith(gtStmt, newStmt);
                        }
                    }
                }
            }
        }
    }
}
项目:petablox    文件:StubMethodSupport.java   
/**
 * Stub for static method "void set(Object array, int index, Object value)
 * in class java.lang.reflect.Array.
 * Stub code is as follows:
 * t0 = (Object[])param0
 * t0[0] = param2
 * return
 */
private static SootMethod getArraySetEquiv(SootMethod m) {
    SootMethod s = genericMethod(m, false);
    JimpleBody body =(JimpleBody) s.retrieveActiveBody();
    SootClass c = s.getDeclaringClass();
    Chain<Unit> units = body.getUnits();
    Chain<Local> locals = body.getLocals();

    //t0 = (Object[])param0
    Local l0 = body.getParameterLocal(0);
    CastExpr ce0 = Jimple.v().newCastExpr(l0, ArrayType.v(RefType.v("java.lang.Object"), 1));
    Local t0 = Jimple.v().newLocal("t0", c.getType());
       locals.add(t0);
       units.add(Jimple.v().newAssignStmt(t0, ce0));

       //t0[0] = param2
       Local l2 = body.getParameterLocal(2);
       ArrayRef ar2 = Jimple.v().newArrayRef((Value)t0, (Value)IntConstant.v(0));
       units.add(Jimple.v().newAssignStmt(ar2, l2));

       //return
    units.add(Jimple.v().newReturnVoidStmt());

    methodToStub.put(m, s);
    methodToStub.put(s, s);
    if (Config.verbose >= 2)
        System.out.println("Custom stub (getArraySetEquiv) for method: " + s.getName() + ":" + s.getDeclaringClass());
    return s;
}
项目:matos-tool    文件:MethodSpyAnalysis.java   
/**
 * Analyze an expression (a value) and computes an abstract value representing its contents.
 * @param r the expression to analyse.
 * @param u The unit that encapsulate the value.
 * @param seen What has already be seen (avoid loops).
 * @return
 */
public AbsValue analyze_expr(Value r, Unit u,  Set<Unit> seen) {
    AbsValue result;
    if (r instanceof Local) {
        result = analyzeLocal((Local) r, u, seen);
    } else if (r instanceof StringConstant)
        result = new StringValue(((StringConstant) r).value);
    else if (r instanceof Constant) 
        result = new ConstantValue((Constant) r,((Constant) r).getType());
    else if (r instanceof InvokeExpr) {
        result = analyzeInvoke((InvokeExpr) r,u,seen);
    } else if (r instanceof CastExpr) {
        result = analyze_expr(((CastExpr) r).getOp(),u,seen);
    } else if (r instanceof ParameterRef) {
        result = analyzeParameterRef((ParameterRef) r, u, seen);
    } else if (r instanceof ConditionExpr) {
        result = analyzeConditionExpr((ConditionExpr) r, u, seen);
    } else if (r instanceof InstanceOfExpr) {
        result = analyzeInstanceOfExpr((InstanceOfExpr) r, u, seen);
    } else if (r instanceof StaticFieldRef) {
        result = analyzeStaticFieldRef((StaticFieldRef) r,u,seen);
    } else if (r instanceof InstanceFieldRef) {
        result = analyzeInstanceFieldRef((InstanceFieldRef) r,u,seen);
    } else if (r instanceof ArrayRef) {
        result = analyzeArrayRef((ArrayRef) r,u,seen);
    } else if (r instanceof NewExpr) {
        result = analyzeNewExpr((NewExpr) r, u, seen);
    } else {
        result = new UnknownValue(r.toString());
    }
    return solve_init(result,u,seen);
}
项目:FlowTwist    文件:AnalysisUtil.java   
/**
 * extracts array base values from array refs and values from cast
 * expressions
 */
public static Value getBackwardsBase(Value val) {
    if (val instanceof ArrayRef) {
        ArrayRef arrayRef = (ArrayRef) val;
        return arrayRef.getBase();
    }
    if (val instanceof CastExpr) {
        CastExpr castExpr = (CastExpr) val;
        return castExpr.getOp();
    }
    return val;
}
项目:FlowTwist    文件:ReturnValuePropagator.java   
/**
 * extracts array base values from array refs and values from cast
 * expressions
 */
private Value getBase(Value val) {
    if (val instanceof ArrayRef) {
        ArrayRef arrayRef = (ArrayRef) val;
        return arrayRef.getBase();
    }
    if (val instanceof CastExpr) {
        CastExpr castExpr = (CastExpr) val;
        return castExpr.getOp();
    }
    return val;
}
项目:FlowTwist    文件:DefaultTaintPropagator.java   
@Override
public KillGenInfo propagateNormalFlow(Trackable trackable, Unit curr, Unit succ) {
    Taint taint = (Taint) trackable;
    if (curr instanceof DefinitionStmt) {
        DefinitionStmt defStmt = (DefinitionStmt) curr;

        Value rightBase = AnalysisUtil.getForwardsBase(defStmt.getRightOp());
        Value leftBase = AnalysisUtil.getForwardsBase(defStmt.getLeftOp());

        if (leftBase.equals(rightBase)) // x = x; or x[i] = x[j]; -> do
                                        // nothing
            return identity();

        // kill the LHS if it is assigned another value
        Value left = defStmt.getLeftOp();
        if (left instanceof Local && taint.value.equals(left)) {
            return kill();
        }

        if (rightBase instanceof CastExpr) {
            CastExpr castExpr = (CastExpr) rightBase;
            if (AnalysisUtil.maybeSameLocation(taint.value, castExpr.getOp())) {
                if (AnalysisUtil.isAssignable(taint.type, leftBase.getType())) {
                    return gen(taint.createAlias(leftBase, curr));
                } else {
                    return identity();
                }
            }
        }

        // at assignments, propagate taint from right to left
        if (taint.value.equivTo(rightBase) || AnalysisUtil.maybeSameLocation(taint.value, rightBase)) {
            return gen(taint.createAlias(leftBase, curr));
        }
    }
    return identity();
}
项目:jgs    文件:SecurityConstraintValueReadSwitch.java   
@Override
public void caseCastExpr(CastExpr v) {
    if (v.getCastType() instanceof ArrayType) {
        throw new CastInvalidException(getMsg("exception.analysis.other.cast",
                                              v.getOp().toString()));
    }
    handleUnaryExpr(v.getOp());
}
项目:jgs    文件:AnnotationValueSwitch.java   
@Override
public void caseCastExpr(CastExpr v) {
    rightElement = RightElement.NOT;

    if (actualContext == StmtContext.ASSIGNRIGHT) {
        // new InternalAnalyzerException();
    }
}
项目:vasco    文件:SignAnalysis.java   
private void assign(Local lhs, Value rhs, Map<Local, SignAnalysis.Sign> input, Map<Local, SignAnalysis.Sign> output) {
    // We only care about numeric locals
    if (lhs.getType() instanceof IntType) {         
        // First remove casts, if any.
        if (rhs instanceof CastExpr) {
            rhs = ((CastExpr) rhs).getOp();
        }   
        // Determine the sign of the RHS and add it to the map
        Sign sign = signOf(rhs, input);
        output.put(lhs, sign);
    }
}
项目:JAADAS    文件:DavaBody.java   
private void javafy_cast_expr(ValueBox vb) {
    CastExpr ce = (CastExpr) vb.getValue();
    javafy(ce.getOpBox());
}
项目:JAADAS    文件:ShortcutIfGenerator.java   
public void inASTStatementSequenceNode(ASTStatementSequenceNode node){
    List<Object> stmts = node.getStatements();
    Iterator<Object> stmtIt = stmts.iterator();
    while(stmtIt.hasNext()){
        AugmentedStmt as = (AugmentedStmt)stmtIt.next();
        Stmt s = as.get_Stmt();
        if(! (s instanceof DefinitionStmt))
            continue;

        DefinitionStmt ds = (DefinitionStmt)s;
        ValueBox rightBox = ds.getRightOpBox();

        Value right = rightBox.getValue();

        /*
         * Going to match int i = (int) z where z is a boolean
         * or int i= z i.e. without the cast
         */

        //right type should contain the expected type on the left
        //in the case of the cast this is the cast type else just get the left type
        Type rightType=null;
        ValueBox OpBox = null;

        if(right instanceof CastExpr){
            rightType = ((CastExpr)right).getCastType();
            OpBox = ((CastExpr)right).getOpBox();
        }
        else{
            rightType = ds.getLeftOp().getType();
            OpBox = rightBox;
        }

        if(! (rightType instanceof IntType )){
            continue;
        }               

        Value Op = OpBox.getValue();
        if(! (Op.getType() instanceof BooleanType)){
            continue;
        }

        //ready for the switch
        ImmediateBox trueBox = new ImmediateBox(IntConstant.v(1));
        ImmediateBox falseBox = new ImmediateBox(IntConstant.v(0));

        DShortcutIf shortcut = new DShortcutIf(OpBox,trueBox,falseBox);
        if(DEBUG)
            System.out.println("created: "+shortcut);
        rightBox.setValue(shortcut);
    }

}
项目:JAADAS    文件:AsmMethodSource.java   
private void convertPrimCastInsn(InsnNode insn) {
    int op = insn.getOpcode();
    boolean tod = op == I2L || op == I2D ||
            op == F2L || op == F2D ||
            op == D2L || op == L2D;
    boolean fromd = op == D2L || op == L2D ||
            op == D2I || op == L2I ||
            op == D2F || op == L2F;
    StackFrame frame = getFrame(insn);
    Operand[] out = frame.out();
    Operand opr;
    if (out == null) {
        Type totype;
        if (op == I2L || op == F2L || op == D2L)
            totype = LongType.v();
        else if (op == L2I || op == F2I || op == D2I)
            totype = IntType.v();
        else if (op == I2F || op == L2F || op == D2F)
            totype = FloatType.v();
        else if (op == I2D || op == L2D || op == F2D)
            totype = DoubleType.v();
        else if (op == I2B)
            totype = ByteType.v();
        else if (op == I2S)
            totype = ShortType.v();
        else if (op == I2C)
            totype = CharType.v();
        else
            throw new AssertionError("Unknonw prim cast op: " + op);
        Operand val = fromd ? popImmediateDual() : popImmediate();
        CastExpr cast = Jimple.v().newCastExpr(val.stackOrValue(), totype);
        opr = new Operand(insn, cast);
        val.addBox(cast.getOpBox());
        frame.in(val);
        frame.boxes(cast.getOpBox());
        frame.out(opr);
    } else {
        opr = out[0];
        frame.mergeIn(fromd ? popDual() : pop());
    }
    if (tod)
        pushDual(opr);
    else
        push(opr);
}
项目:petablox    文件:StubMethodSupport.java   
/**
 * Stub for static method "void arraycopy(Object src, int srcPos, Object dest,
 * int destPos, int length)" in class java.lang.System.
 * Stub code is as follows:
 * t0 = (Object[])param0
 * t1 = (Object[])param2
 * t2 = t0[0]
 * t1[0] = t2
 * return
 */
private static SootMethod getArrayCopyEquiv(SootMethod m) {
    SootMethod s = genericMethod(m, false);
    JimpleBody body =(JimpleBody) s.retrieveActiveBody();
    SootClass c = s.getDeclaringClass();
    Chain<Unit> units = body.getUnits();
    Chain<Local> locals = body.getLocals();

    //t0 = (Object[])param0
    Local l0 = body.getParameterLocal(0);
    CastExpr ce0 = Jimple.v().newCastExpr(l0, ArrayType.v(RefType.v("java.lang.Object"), 1));
    Local t0 = Jimple.v().newLocal("t0", ArrayType.v(RefType.v("java.lang.Object"), 1));
       locals.add(t0);
       units.add(Jimple.v().newAssignStmt(t0, ce0));

       //t1 = (Object[])param2
       Local l2 = body.getParameterLocal(2);
    CastExpr ce2 = Jimple.v().newCastExpr(l2, ArrayType.v(RefType.v("java.lang.Object"), 1));
    Local t1 = Jimple.v().newLocal("t1", ArrayType.v(RefType.v("java.lang.Object"), 1));
       locals.add(t1);
       units.add(Jimple.v().newAssignStmt(t1, ce2));

       //t2 = t0[0]
       Local t2 = Jimple.v().newLocal("t2", ArrayType.v(RefType.v("java.lang.Object"), 1));
       locals.add(t2);
       ArrayRef ar1 = Jimple.v().newArrayRef((Value)t0, (Value)IntConstant.v(0));
       units.add(Jimple.v().newAssignStmt(t2, ar1));

       //t1[0] = t2
       ArrayRef ar2 = Jimple.v().newArrayRef((Value)t1, (Value)IntConstant.v(0));
       units.add(Jimple.v().newAssignStmt(ar2, t2));

       //return
    units.add(Jimple.v().newReturnVoidStmt());

    methodToStub.put(m, s);
    methodToStub.put(s, s);
    if (Config.verbose >= 2)
        System.out.println("Custom stub (getArrayCopyEquiv) for method: " + s.getName() + ":" + s.getDeclaringClass());
    return s;
}
项目:petablox    文件:FGStmtSwitch.java   
/** A statement of the form l = (cl) v; */
  protected void caseCastStmt( Local dest, Value src, CastExpr c ) {
// default is to just ignore the cast
caseCopyStmt( dest, src );
  }
项目:petablox    文件:FGStmtSwitch.java   
public final void caseAssignStmt( AssignStmt s ) {
statement = s;
Value lhs = s.getLeftOp();
Value rhs = s.getRightOp();
if( ! (lhs.getType() instanceof RefType)
    &&  ! (lhs.getType() instanceof ArrayType) ) {
    if( rhs instanceof InvokeExpr ) {
        caseInvokeStmt( null, (InvokeExpr) rhs );
        return;
    }
    caseUninterestingStmt( s );
    return;
}
if( rhs instanceof InvokeExpr ) {
    caseInvokeStmt( (Local) lhs, (InvokeExpr) rhs );
    return;
}
if( lhs instanceof Local ) {
    if( rhs instanceof Local ) {
        caseCopyStmt( (Local) lhs, rhs );
    } else if( rhs instanceof InstanceFieldRef ) {
        caseLoadStmt( (Local) lhs, (InstanceFieldRef) rhs );
    } else if( rhs instanceof ArrayRef ) {
        caseArrayLoadStmt( (Local) lhs, (ArrayRef) rhs );
    } else if( rhs instanceof StaticFieldRef ) {
        caseGlobalLoadStmt( (Local) lhs, (StaticFieldRef) rhs );
    } else if( rhs instanceof NewExpr ) {
        caseNewStmt( (Local) lhs, (NewExpr) rhs );
    } else if( rhs instanceof NewArrayExpr ) {
        caseNewArrayStmt( (Local) lhs, (NewArrayExpr) rhs );
    } else if( rhs instanceof NewMultiArrayExpr ) {
        caseNewMultiArrayStmt( (Local) lhs, (NewMultiArrayExpr) rhs );
    } else if( rhs instanceof CastExpr ) {
        CastExpr r = (CastExpr) rhs;
        Value rv = r.getOp();
        caseCastStmt( (Local) lhs, rv, r );
    } else if( rhs instanceof Constant ) {
        caseCopyStmt( (Local) lhs, rhs );
    } else if( rhs instanceof PhiExpr ) {
        casePhiStmt( (Local) lhs, (PhiExpr) rhs );
    } else throw new RuntimeException( "unhandled stmt "+s );
} else if( lhs instanceof InstanceFieldRef ) {
    if( rhs instanceof Local || rhs instanceof Constant) {
        caseStoreStmt( (InstanceFieldRef) lhs, rhs );
    } else throw new RuntimeException( "unhandled stmt "+s );
} else if( lhs instanceof ArrayRef ) {
    if( rhs instanceof Local || rhs instanceof Constant ) {
        caseArrayStoreStmt( (ArrayRef) lhs, rhs );
    } else throw new RuntimeException( "unhandled stmt "+s );
} else if( lhs instanceof StaticFieldRef ) {
    if( rhs instanceof Local || rhs instanceof Constant ) {
    caseGlobalStoreStmt( (StaticFieldRef) lhs, rhs );
    } else throw new RuntimeException( "unhandled stmt "+s );
} else throw new RuntimeException( "unhandled stmt "+s );
  }
项目:petablox    文件:PAGBuilder.java   
void pass1()
{   int count = method.getParameterCount();
    Local[] locals = SootUtilities.getMethArgLocals(method);
    if(locals == null)
        return;
    if(!method.isStatic()) {
        thisVar = locals[0];
        paramVars = new Local[locals.length - 1];
        for(int i=1; i<locals.length; i++){
            paramVars[i-1] = locals[i];
        }
    }
    else{
        paramVars = new Local[locals.length];
        for(int i=0; i<locals.length; i++){
            paramVars[i] = locals[i];
        }

    }       
    if(count > 0){              
        int j = 0;      
        for(Type pType : method.getParameterTypes()){
            if(pType instanceof PrimType){
                if(paramVars != null)
                    domU.add(paramVars[j], method);
                j++;
            }
        }
    }

    Type retType = method.getReturnType();
    if(!(retType instanceof VoidType)){
        retVar = SootUtilities.getReturnLocal(method);   
        if(retType instanceof PrimType && retVar!= null)
                domU.add(retVar,method);    
    } 

    if(!method.isConcrete())
        return;

    Body body = method.retrieveActiveBody();
    LocalsClassifier lc = new LocalsClassifier(body);
    primLocals = lc.primLocals();
    nonPrimLocals = lc.nonPrimLocals();
    for(Local l : body.getLocals()){
        boolean isPrim = primLocals.contains(l);
        if(isPrim)
            domU.add(l,method);
    }

    stmtToCastNode = new HashMap();
    for(Unit unit : body.getUnits()){
        Stmt s = (Stmt) unit;
        if(s instanceof AssignStmt) {
            Value rightOp = ((AssignStmt) s).getRightOp();
            if(rightOp instanceof CastExpr){
                CastExpr castExpr = (CastExpr) rightOp;
                Type castType = castExpr.getCastType();
                if(castType instanceof RefLikeType){            //TODO
                    stmtToCastNode.put(s, castExpr);
                }
            }
        }
    }                       
}
项目:jgs    文件:SecurityConstraintValueWriteSwitch.java   
@Override
public void caseCastExpr(CastExpr v) {
    throwInvalidWriteException(v);
}
项目:jgs    文件:SecurityLevelValueWriteSwitch.java   
/**
 * The method should update the <em>security level</em> of an expression
 * with type {@link CastExpr}, but it is not possible to update the level of
 * such an expression.
 * 
 * @param v
 *            The expression for which the <em>security level</em> should be
 *            updated.
 * @see soot.jimple.ExprSwitch#caseCastExpr(soot.jimple.CastExpr)
 * @throws InvalidSwitchException
 *             Always, because the update is not possible.
 */
@Override
public void caseCastExpr(CastExpr v) {
    throw new SwitchException(getMsg("exception.analysis.switch.update_error",
                                     this.getClass().getSimpleName(),
                                     v.getClass().getSimpleName(),
                                     v.toString(),
                                     getSourceLine()));
}
项目:jgs    文件:AnnotationValueSwitch.java   
/**
 * DOC
 * 
 * @see soot.jimple.ExprSwitch#caseCastExpr(soot.jimple.CastExpr)
 */
@Override
public void caseCastExpr(CastExpr v) {
    v.getOp().apply(this);
}
项目:jgs    文件:SecurityLevelValueReadSwitch.java   
/**
 * Looks up the <em>security level</em> for the given cast expression and
 * stores the level in {@link SecurityLevelValueReadSwitch#level}.
 * 
 * @param v
 *            The cast expression for which the <em>security level</em>
 *            should be looked up.
 * @see soot.jimple.ExprSwitch#caseCastExpr(soot.jimple.CastExpr)
 */
@Override
public void caseCastExpr(CastExpr v) {
    Value value = v.getOp();
    handleOneValue(value, v);
}