@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); } }
@Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { // Check for all assignments that perform casts on primitive constants for (Unit u : b.getUnits()) { if (u instanceof AssignStmt) { AssignStmt assign = (AssignStmt) u; if (assign.getRightOp() instanceof CastExpr) { CastExpr ce = (CastExpr) assign.getRightOp(); if (ce.getOp() instanceof Constant) { // a = (float) 42 if (ce.getType() instanceof FloatType && ce.getOp() instanceof IntConstant) { IntConstant it = (IntConstant) ce.getOp(); assign.setRightOp(FloatConstant.v(it.value)); } // a = (double) 42 else if (ce.getType() instanceof DoubleType && ce.getOp() instanceof IntConstant) { IntConstant it = (IntConstant) ce.getOp(); assign.setRightOp(DoubleConstant.v(it.value)); } } } } } }
public void caseCastExpr(CastExpr ce) { inCastExpr(ce); Type type = ce.getCastType(); caseType(type); caseExprOrRefValueBox(ce.getOpBox()); // Value op = ce.getOp(); // decideCaseExprOrRef(op); outCastExpr(ce); }
public boolean canContainValue(Value value) { return value instanceof ConcreteRef || value instanceof InvokeExpr || value instanceof NewArrayExpr || value instanceof NewMultiArrayExpr || value instanceof Local || value instanceof NullConstant || value instanceof StringConstant || value instanceof ClassConstant || (value instanceof CastExpr && canContainValue(((CastExpr) value).getOp())); } }
Value rhs = as.getRightOp(); if (rhs instanceof CastExpr) { Type t = ((CastExpr) rhs).getCastType(); if (t instanceof RefType && !types.contains(t)) { types.add(t);
} else if (stmt.getRightOp() instanceof CastExpr) { CastExpr ce = (CastExpr) stmt.getRightOp(); if (ce.getOp() instanceof UntypedConstant) { UntypedConstant uc = (UntypedConstant) ce.getOp(); ce.setOp(uc.defineType(IntType.v())); return; } else if (t instanceof FloatOpTag) { ce.setOp(uc.defineType(FloatType.v())); return; } else if (t instanceof DoubleOpTag) { ce.setOp(uc.defineType(DoubleType.v())); return; } else if (t instanceof LongOpTag) { ce.setOp(uc.defineType(LongType.v())); return; ce.setOp(uc.defineType(RefType.v("java.lang.Object")));
t = c.getType(); if (t instanceof ArrayType) { ok = true;
if (ce.getCastType() instanceof ArrayType) { ce.setCastType(getArrayReplacementType((ArrayType) ce.getCastType()));
private void javafy_cast_expr(ValueBox vb) { CastExpr ce = (CastExpr) vb.getValue(); javafy(ce.getOpBox()); }
/** * Handle like a trivial assignment. **/ public void caseCastExpr(CastExpr v) { setResult(fetchNode(v.getOp())); }
public void outDefinitionStmt(DefinitionStmt s) { // checking casting here because we want to see if the expr // on the right of def stmt is a cast expr not whether it contains a cast expr if (definedLocal != null && s.getRightOp() instanceof CastExpr) { Type castType = ((CastExpr) s.getRightOp()).getCastType(); info.addCastString(definedLocal, castType.toString()); } inDefinitionStmt = false; definedLocal = null; }
if (ass.getRightOp() instanceof CastExpr) { CastExpr c = (CastExpr) ass.getRightOp(); if (c.getType() instanceof NullType) { ass.setRightOp(nullConstant);
public soot.jimple.CastExpr newCastExpr(Value op1, Type t, ASTNode location) { soot.jimple.CastExpr expr = Jimple.v().newCastExpr(op1, t); createTag(expr, location); soot.tagkit.Tag op1tag = getTag(op1); if(op1tag != null) expr.getOpBox().addTag(op1tag); return expr; }
@Override public void caseCastExpr(CastExpr expr) { if (expr.getCastType() instanceof PrimType) { // No exception are thrown for primitive casts return; } Type fromType = expr.getOp().getType(); Type toType = expr.getCastType(); result = result.add(mgr.RESOLVE_CLASS_ERRORS); 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())); } };
rhs = castExpr.getOp();
usedAsFloatingPoint = isFloatingPointLike(((CastExpr) r).getCastType()); doBreak = true; } else if (r instanceof InvokeExpr) {
rightType = ((CastExpr) right).getCastType(); OpBox = ((CastExpr) right).getOpBox(); } else { rightType = ds.getLeftOp().getType();
targetType = cast.getType();