@Override public NumericConstant negate() { return FloatConstant.v(-(this.value)); }
@Override public FloatConstant getConstant() { return FloatConstant.v(value); }
public FloatConstant toFloatConstant() { return FloatConstant.v(Float.intBitsToFloat((int) value)); }
@Override public NumericConstant subtract(NumericConstant c) { assertInstanceOf(c); return FloatConstant.v(this.value - ((FloatConstant) c).value); }
@Override public NumericConstant multiply(NumericConstant c) { assertInstanceOf(c); return FloatConstant.v(this.value * ((FloatConstant) c).value); }
@Override public NumericConstant add(NumericConstant c) { assertInstanceOf(c); return FloatConstant.v(this.value + ((FloatConstant) c).value); }
@Override public NumericConstant divide(NumericConstant c) { assertInstanceOf(c); return FloatConstant.v(this.value / ((FloatConstant) c).value); }
public Value createJimpleConstantValue(cp_info[] constant_pool) { return FloatConstant.v(convert()); } }
@Override public NumericConstant remainder(NumericConstant c) { assertInstanceOf(c); return FloatConstant.v(this.value % ((FloatConstant) c).value); }
/** * @ast method * @aspect Expressions * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/Expressions.jrag:26 */ public soot.Value eval(Body b) { return soot.jimple.FloatConstant.v(constant().floatValue()); } /**
/** * Gets the constant value 0 with the given type (integer, float, etc.) * * @param type * The type for which to get the constant zero value * @return The constant zero value of the given type */ private Value getZeroConst(Type type) { if (type instanceof IntType) { return IntConstant.v(0); } else if (type instanceof LongType) { return LongConstant.v(0); } else if (type instanceof FloatType) { return FloatConstant.v(0); } else if (type instanceof DoubleType) { return DoubleConstant.v(0); } throw new RuntimeException("Unsupported numeric type"); }
/** * Returns a needed constant given a type and val */ @Override protected soot.jimple.Constant getConstant(soot.Type type, int val) { if (type instanceof soot.DoubleType) { return soot.jimple.DoubleConstant.v(val); } else if (type instanceof soot.FloatType) { return soot.jimple.FloatConstant.v(val); } else if (type instanceof soot.LongType) { return soot.jimple.LongConstant.v(val); } else { return soot.jimple.IntConstant.v(val); } }
/** * Replace 0 with null in the given unit. * * @param u * the unit where 0 will be replaced with null. */ private void replaceWithFloatingPoint(Unit u) { if (u instanceof AssignStmt) { AssignStmt s = (AssignStmt) u; Value v = s.getRightOp(); if ((v instanceof IntConstant)) { int vVal = ((IntConstant) v).value; s.setRightOp(FloatConstant.v(Float.intBitsToFloat(vVal))); } else if (v instanceof LongConstant) { long vVal = ((LongConstant) v).value; s.setRightOp(DoubleConstant.v(Double.longBitsToDouble(vVal))); } } }
public static Value createConstant(Object toConvert) { if (toConvert instanceof Long) { return LongConstant.v(((Long) toConvert).longValue()); } else if (toConvert instanceof Double) { return DoubleConstant.v(((Double) toConvert).doubleValue()); } else if (toConvert instanceof Boolean) { boolean val = ((Boolean) toConvert).booleanValue(); if (val) { return DIntConstant.v(1, BooleanType.v()); } else { return DIntConstant.v(0, BooleanType.v()); } } else if (toConvert instanceof Float) { return FloatConstant.v(((Float) toConvert).floatValue()); } else if (toConvert instanceof Integer) { return IntConstant.v(((Integer) toConvert).intValue()); } else { return null; } }
v = IntConstant.v((Integer) val); } else if (val instanceof Float) { v = FloatConstant.v((Float) val); } else if (val instanceof Long) { v = LongConstant.v((Long) val);
v = LongConstant.v(op - LCONST_0); } else if (op >= FCONST_0 && op <= FCONST_2) { v = FloatConstant.v(op - FCONST_0); } else if (op == DCONST_0 || op == DCONST_1) { v = DoubleConstant.v(op - DCONST_0);
/** * @ast method * @aspect Expressions * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/Expressions.jrag:718 */ public static soot.Value emitConstant(Constant constant) { if(constant instanceof Constant.ConstantInt) return IntType.emitConstant(constant.intValue()); else if(constant instanceof Constant.ConstantLong) return soot.jimple.LongConstant.v(constant.longValue()); else if(constant instanceof Constant.ConstantFloat) return soot.jimple.FloatConstant.v(constant.floatValue()); else if(constant instanceof Constant.ConstantDouble) return soot.jimple.DoubleConstant.v(constant.doubleValue()); else if(constant instanceof Constant.ConstantChar) return IntType.emitConstant(constant.intValue()); else if(constant instanceof Constant.ConstantBoolean) return BooleanType.emitConstant(constant.booleanValue()); else if(constant instanceof Constant.ConstantString) return soot.jimple.StringConstant.v(constant.stringValue()); throw new Error("Unexpected constant"); } /**
@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 static PushInst getPushInitializer(Local l, Type t) { if (t instanceof IntegerType) { return Baf.v().newPushInst(IntConstant.v(soot.jbco.util.Rand.getInt())); } else if (t instanceof RefLikeType || t instanceof StmtAddressType) { return Baf.v().newPushInst(NullConstant.v()); } else if (t instanceof LongType) { return Baf.v().newPushInst(LongConstant.v(soot.jbco.util.Rand.getLong())); } else if (t instanceof FloatType) { return Baf.v().newPushInst(FloatConstant.v(soot.jbco.util.Rand.getFloat())); } else if (t instanceof DoubleType) { return Baf.v().newPushInst(DoubleConstant.v(soot.jbco.util.Rand.getDouble())); } return null; }
private static Value getConstantType(Type t) { if (t instanceof BooleanType) { return IntConstant.v(Rand.getInt(1)); } if (t instanceof IntType) { return IntConstant.v(Rand.getInt()); } if (t instanceof CharType) { return Jimple.v().newCastExpr(IntConstant.v(Rand.getInt()), CharType.v()); } if (t instanceof ByteType) { return Jimple.v().newCastExpr(IntConstant.v(Rand.getInt()), ByteType.v()); } if (t instanceof LongType) { return LongConstant.v(Rand.getLong()); } if (t instanceof FloatType) { return FloatConstant.v(Rand.getFloat()); } if (t instanceof DoubleType) { return DoubleConstant.v(Rand.getDouble()); } return Jimple.v().newCastExpr(NullConstant.v(), t); }