Java 类soot.jimple.DoubleConstant 实例源码

项目:JAADAS    文件:BaseEntryPointCreator.java   
protected Value getSimpleDefaultValue(String t) {
    if (t.equals("java.lang.String"))
        return StringConstant.v("");
    if (t.equals("char"))
        return DIntConstant.v(0, CharType.v());
    if (t.equals("byte"))
        return DIntConstant.v(0, ByteType.v());
    if (t.equals("short"))
        return DIntConstant.v(0, ShortType.v());
    if (t.equals("int"))
        return IntConstant.v(0);
    if (t.equals("float"))
        return FloatConstant.v(0);
    if (t.equals("long"))
        return LongConstant.v(0);
    if (t.equals("double"))
        return DoubleConstant.v(0);
    if (t.equals("boolean"))
        return DIntConstant.v(0, BooleanType.v());

    //also for arrays etc.
    return G.v().soot_jimple_NullConstant();
}
项目:JAADAS    文件:FixUndefinedLocals.java   
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;
}
项目:JAADAS    文件:CPHelper.java   
public static Object isAConstantValue(Value toCheck){
    Object value=null;

    if(toCheck instanceof LongConstant){
        value = new Long(((LongConstant)toCheck).value);
    }
    else if(toCheck instanceof DoubleConstant){
        value = new Double(((DoubleConstant)toCheck).value);
    }
    else if(toCheck instanceof FloatConstant){
        value = new Float(((FloatConstant)toCheck).value);
    }
    else if(toCheck instanceof IntConstant){
        int val = ((IntConstant)toCheck).value;
        value = new Integer(val);           
    }
    return value;
}
项目:JAADAS    文件:CPHelper.java   
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;
}
项目:JAADAS    文件:AsmMethodSource.java   
private Value toSootValue(Object val) throws AssertionError {
    Value v;
    if (val instanceof Integer)
        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);
    else if (val instanceof Double)
        v = DoubleConstant.v((Double) val);
    else if (val instanceof String)
        v = StringConstant.v(val.toString());
    else if (val instanceof org.objectweb.asm.Type)
        v = ClassConstant.v(((org.objectweb.asm.Type) val).getInternalName());
    else if (val instanceof Handle)
        v = MethodHandle.v(toSootMethodRef((Handle) val), ((Handle)val).getTag());
    else
        throw new AssertionError("Unknown constant type: " + val.getClass());
    return v;
}
项目:soot-inflow    文件:BaseEntryPointCreator.java   
protected Value getSimpleDefaultValue(String t) {
    if (t.equals("java.lang.String"))
        return StringConstant.v("");
    if (t.equals("char"))
        return DIntConstant.v(0, CharType.v());
    if (t.equals("byte"))
        return DIntConstant.v(0, ByteType.v());
    if (t.equals("short"))
        return DIntConstant.v(0, ShortType.v());
    if (t.equals("int"))
        return IntConstant.v(0);
    if (t.equals("float"))
        return FloatConstant.v(0);
    if (t.equals("long"))
        return LongConstant.v(0);
    if (t.equals("double"))
        return DoubleConstant.v(0);
    if (t.equals("boolean"))
        return DIntConstant.v(0, BooleanType.v());

    //also for arrays etc.
    return G.v().soot_jimple_NullConstant();
}
项目:JAADAS    文件:AbstractJasminClass.java   
protected String doubleToString(DoubleConstant v) {
    String s = v.toString();

    if(s.equals("#Infinity"))
        s="+DoubleInfinity";
    else if(s.equals("#-Infinity"))
        s="-DoubleInfinity";
    else if(s.equals("#NaN"))
        s="+DoubleNaN";
    return s;
}
项目:JAADAS    文件:AsmMethodSource.java   
private void convertConstInsn(InsnNode insn) {
    int op = insn.getOpcode();
    StackFrame frame = getFrame(insn);
    Operand[] out = frame.out();
    Operand opr;
    if (out == null) {
        Value v;
        if (op == ACONST_NULL)
            v = NullConstant.v();
        else if (op >= ICONST_M1 && op <= ICONST_5)
            v = IntConstant.v(op - ICONST_0);
        else if (op == LCONST_0 || op == LCONST_1)
            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);
        else
            throw new AssertionError("Unknown constant opcode: " + op);
        opr = new Operand(insn, v);
        frame.out(opr);
    } else {
        opr = out[0];
    }
    if (op == LCONST_0 || op == LCONST_1 ||
            op == DCONST_0 || op == DCONST_1) {
        pushDual(opr);
    } else {
        push(opr);
    }
}
项目:JAADAS    文件:ConstantInitializerToTagTransformer.java   
private ConstantValueTag createConstantTagFromValue(Constant rightOp) {
    if (rightOp instanceof DoubleConstant)
        return new DoubleConstantValueTag(((DoubleConstant) rightOp).value);
    else if (rightOp instanceof FloatConstant)
        return new FloatConstantValueTag(((FloatConstant) rightOp).value);
    else if (rightOp instanceof IntConstant)
        return new IntegerConstantValueTag(((IntConstant) rightOp).value);
    else if (rightOp instanceof LongConstant)
        return new LongConstantValueTag(((LongConstant) rightOp).value);
    else if (rightOp instanceof StringConstant)
        return new StringConstantValueTag(((StringConstant) rightOp).value);
    else
        return null;
}
项目:JAADAS    文件:ConstantInitializerToTagTransformer.java   
private boolean checkConstantValue(ConstantValueTag t, Constant rightOp) {
    if (t == null || rightOp == null)
        return true;

    if (t instanceof DoubleConstantValueTag) {
        if (!(rightOp instanceof DoubleConstant))
            return false;
        return ((DoubleConstantValueTag) t).getDoubleValue() == ((DoubleConstant) rightOp).value;
    }
    else if (t instanceof FloatConstantValueTag) {
        if (!(rightOp instanceof FloatConstant))
            return false;
        return ((FloatConstantValueTag) t).getFloatValue() == ((FloatConstant) rightOp).value;
    }
    else if (t instanceof IntegerConstantValueTag) {
        if (!(rightOp instanceof IntConstant))
            return false;
        return ((IntegerConstantValueTag) t).getIntValue() == ((IntConstant) rightOp).value;
    }
    else if (t instanceof LongConstantValueTag) {
        if (!(rightOp instanceof LongConstant))
            return false;
        return ((LongConstantValueTag) t).getLongValue() == ((LongConstant) rightOp).value;
    }
    else if (t instanceof StringConstantValueTag) {
        if (!(rightOp instanceof StringConstant))
            return false;
        return ((StringConstantValueTag) t).getStringValue().equals(((StringConstant) rightOp).value);
    }
    else
        // We don't know the type, so we assume it's alright
        return true;
}
项目:JAADAS    文件:UnitThrowAnalysisTest.java   
@Test
public void testJBinOpExp() {
    Value v = Jimple.v().newAddExpr(IntConstant.v(456), 
            Jimple.v().newLocal("local", IntType.v()));
    assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET,
                unitAnalysis.mightThrow(v)));
    assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES,
            utility.catchableSubset(unitAnalysis.mightThrow(v)));

    v = Jimple.v().newOrExpr(Jimple.v().newLocal("local", LongType.v()),
            LongConstant.v(33));
    assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET,
                unitAnalysis.mightThrow(v)));
    assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES,
            utility.catchableSubset(unitAnalysis.mightThrow(v)));

    v = Jimple.v().newLeExpr(Jimple.v().newLocal("local", FloatType.v()),
            FloatConstant.v(33.42f));
    assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET,
                unitAnalysis.mightThrow(v)));
    assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES,
            utility.catchableSubset(unitAnalysis.mightThrow(v)));

    v = Jimple.v().newEqExpr(DoubleConstant.v(-33.45e-3),
            Jimple.v().newLocal("local", DoubleType.v()));
    assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET,
                unitAnalysis.mightThrow(v)));
    assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES,
            utility.catchableSubset(unitAnalysis.mightThrow(v)));
}
项目:bixie    文件:GlobalsCache.java   
public IdentifierExpression lookupInternDouble(DoubleConstant s) {
    if (!doubleInternMap.containsKey(s.toString())) {
        String name = "$DoubleConst" + doubleInternMap.size();
        doubleInternMap.put(s.toString(),
                this.pf.mkIdentifierExpression(this.getBoogieType(s.getType()), name, true, true, true));
    }
    return doubleInternMap.get(s.toString());
}
项目:averroes    文件:AverroesJimpleBody.java   
/**
 * Return a constant value corresponding to the primary type.
 * 
 * @param type
 * @return
 */
public static Value getPrimValue(PrimType type) {
    if (type instanceof IntegerType) {
        return IntConstant.v(1);
    } else if (type instanceof LongType) {
        return LongConstant.v(1);
    } else if (type instanceof FloatType) {
        return FloatConstant.v(1);
    } else {
        return DoubleConstant.v(1);
    }
}
项目:DroidRA    文件:InstrumentationUtils.java   
public static Value toDefaultSootTypeValue(Type sootType)
{
    String type = sootType.toString();

    if ("boolean".equals(type))
    {
        IntConstant.v(0);
    }
    else if ("byte".equals(type))
    {
        return IntConstant.v(0);
    }
    else if ("char".equals(type))
    {
        return IntConstant.v(0);
    }
    else if ("short".equals(type))
    {
        return IntConstant.v(0);
    }
    else if ("int".equals(type))
    {
        return IntConstant.v(0);
    }
    else if ("long".equals(type))
    {
        return LongConstant.v(0);
    }
    else if ("float".equals(type))
    {
        return FloatConstant.v(0);
    }
    else if ("double".equals(type))
    {
        return DoubleConstant.v(0);
    }

    return NullConstant.v();
}
项目:jar2bpl    文件:GlobalsCache.java   
public IdentifierExpression lookupInternDouble(DoubleConstant s) {
    if (!doubleInternMap.containsKey(s.toString())) {
        String name = "$DoubleConst"+doubleInternMap.size();
        doubleInternMap.put(s.toString(), this.pf.mkIdentifierExpression(this.getBoogieType(s.getType()), name, true, true, true));
    }
    return doubleInternMap.get(s.toString());
}
项目:JAADAS    文件:ValueTemplatePrinter.java   
public void caseDoubleConstant(DoubleConstant v) {
    printConstant(v, Double.toString(v.value));
}
项目:JAADAS    文件:Walker.java   
public void outAFloatConstant(AFloatConstant node)
   {
String s = (String) mProductions.removeLast();

       boolean isDouble = true;
       float value = 0;
       double dvalue = 0;

       if(s.endsWith("f") || s.endsWith("F")) 
         isDouble = false;

       if(s.charAt(0) == '#') {
         if(s.charAt(1) == '-') {
           if(isDouble)
             dvalue = Double.NEGATIVE_INFINITY;
           else
             value = Float.NEGATIVE_INFINITY;
         }
         else if(s.charAt(1) == 'I') {
           if(isDouble)
             dvalue = Double.POSITIVE_INFINITY;
           else
             value = Float.POSITIVE_INFINITY;
         }
         else {
           if(isDouble)
             dvalue = Double.NaN;
           else
             value = Float.NaN;
         }
       }
       else {
         StringBuffer buf = new StringBuffer();          
         if(node.getMinus() != null)
           buf.append('-');
         buf.append(s);
         s = buf.toString();

         if(isDouble)
           dvalue = Double.parseDouble(s);
         else
           value =Float.parseFloat(s);        
       }

       Object res;
       if(isDouble)
         res = DoubleConstant.v(dvalue);
       else
         res = FloatConstant.v(value);

mProductions.addLast(res);
   }
项目:JAADAS    文件:ConstraintCollector.java   
public void caseIfStmt(IfStmt stmt) {
    if (uses) {
        ConditionExpr cond = (ConditionExpr) stmt.getCondition();

        BinopExpr expr = cond;
        Value lv = expr.getOp1();
        Value rv = expr.getOp2();

        TypeVariable lop;
        TypeVariable rop;

        // ******** LEFT ********
        if (lv instanceof Local) {
            lop = resolver.typeVariable((Local) lv);
        } else if (lv instanceof DoubleConstant) {
            lop = resolver.typeVariable(DoubleType.v());
        } else if (lv instanceof FloatConstant) {
            lop = resolver.typeVariable(FloatType.v());
        } else if (lv instanceof IntConstant) {
            lop = resolver.typeVariable(IntType.v());
        } else if (lv instanceof LongConstant) {
            lop = resolver.typeVariable(LongType.v());
        } else if (lv instanceof NullConstant) {
            lop = resolver.typeVariable(NullType.v());
        } else if (lv instanceof StringConstant) {
            lop = resolver.typeVariable(RefType.v("java.lang.String"));
        } else if (lv instanceof ClassConstant) {
            lop = resolver.typeVariable(RefType.v("java.lang.Class"));
        } else {
            throw new RuntimeException("Unhandled binary expression left operand type: " + lv.getClass());
        }

        // ******** RIGHT ********
        if (rv instanceof Local) {
            rop = resolver.typeVariable((Local) rv);
        } else if (rv instanceof DoubleConstant) {
            rop = resolver.typeVariable(DoubleType.v());
        } else if (rv instanceof FloatConstant) {
            rop = resolver.typeVariable(FloatType.v());
        } else if (rv instanceof IntConstant) {
            rop = resolver.typeVariable(IntType.v());
        } else if (rv instanceof LongConstant) {
            rop = resolver.typeVariable(LongType.v());
        } else if (rv instanceof NullConstant) {
            rop = resolver.typeVariable(NullType.v());
        } else if (rv instanceof StringConstant) {
            rop = resolver.typeVariable(RefType.v("java.lang.String"));
        } else if (rv instanceof ClassConstant) {
            rop = resolver.typeVariable(RefType.v("java.lang.Class"));
        } else {
            throw new RuntimeException("Unhandled binary expression right operand type: " + rv.getClass());
        }

        TypeVariable common = resolver.typeVariable();
        rop.addParent(common);
        lop.addParent(common);
    }
}
项目:JAADAS    文件:RegisterAllocator.java   
private Register asConstant(Value v, ConstantVisitor constantV) {
    Constant c = (Constant) v;

    Register constantRegister = null;

    List<Register> rArray = null;
    AtomicInteger iI = null;
    if (c instanceof ClassConstant) {
        rArray = classConstantReg;
        iI = classI;
    } else if (c instanceof NullConstant) {
           rArray = nullConstantReg;
           iI = nullI;
       } else if (c instanceof FloatConstant) {
           rArray = floatConstantReg;
           iI = floatI;
       } else if (c instanceof IntConstant) {
           rArray = intConstantReg;
           iI = intI;
       } else if (c instanceof LongConstant) {
           rArray = longConstantReg;
           iI = longI;
       } else if (c instanceof DoubleConstant) {
           rArray = doubleConstantReg;
           iI = doubleI;
       } else if (c instanceof StringConstant) {
           rArray = stringConstantReg;
           iI = stringI;
       } else {
           throw new RuntimeException("Error. Unknown constant type: '"+ c.getType() +"'");
       }

    if (rArray.size() == 0 || iI.intValue() >= rArray.size()) {
        rArray.add(new Register(c.getType(), nextRegNum));
        nextRegNum += SootToDexUtils.getDexWords(c.getType());
    }

    constantRegister = rArray.get(iI.intValue()).clone();
    iI.set(iI.intValue() + 1);

    // "load" constant into the register...
    constantV.setDestination(constantRegister);
    c.apply(constantV);
    // ...but return an independent register object
    return constantRegister.clone();
}
项目:JAADAS    文件:ConstantVisitor.java   
public void caseDoubleConstant(DoubleConstant d) {
    long longBits = Double.doubleToLongBits(d.value);
       stmtV.addInsn(buildConstWideInsn(longBits), origStmt);
}
项目:JAADAS    文件:UntypedLongOrDoubleConstant.java   
public DoubleConstant toDoubleConstant() {
    return DoubleConstant.v(Double.longBitsToDouble(value));
}
项目:JAADAS    文件:CONSTANT_Double_info.java   
public Value createJimpleConstantValue(cp_info[] constant_pool) {
    return DoubleConstant.v(convert());
}
项目: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 caseDoubleConstant(DoubleConstant c) {
}
项目:bixie    文件:SootValueSwitch.java   
@Override
public void caseDoubleConstant(DoubleConstant arg0) {
    this.expressionStack.push(GlobalsCache.v().lookupInternDouble(arg0));
}
项目:petablox    文件:DomDoubleConst.java   
@Override
public void visit(Value e) {
     if (e instanceof DoubleConstant)
         add(e);
}
项目:petablox    文件:RelDoubleExpr.java   
@Override
public void visit(Value e) {
     if (e instanceof DoubleConstant)
         add(e);
}
项目:jar2bpl    文件:SootValueSwitch.java   
@Override
public void caseDoubleConstant(DoubleConstant arg0) {
    this.expressionStack.push(GlobalsCache.v().lookupInternDouble(arg0));
}
项目:jgs    文件:SecurityConstraintValueWriteSwitch.java   
@Override
public void caseDoubleConstant(DoubleConstant v) {
    throwInvalidWriteException(v);
}
项目:jgs    文件:SecurityConstraintValueReadSwitch.java   
@Override
public void caseDoubleConstant(DoubleConstant v) {
    addReadComponent(getWeakestSecurityLevel());
}
项目:jgs    文件:AnnotationValueSwitch.java   
/**
 * It is not neccessary to treat a constant.
 * @param v a constant
 */
@Override
public void caseDoubleConstant(DoubleConstant v) {
    logger.finest("DoubleConstant identified " + callingStmt.toString());
    rightElement = RightElement.NOT;
}
项目:jgs    文件:SecurityLevelValueWriteSwitch.java   
/**
 * The method should update the <em>security level</em> of a
 * {@link DoubleConstant}, but it is not possible to update the level of a
 * constant.
 * 
 * @param v
 *            The constant for which the <em>security level</em> should be
 *            updated.
 * @see soot.jimple.ConstantSwitch#caseDoubleConstant(soot.jimple.DoubleConstant)
 * @throws InvalidSwitchException
 *             Always, because the update is not possible.
 */
@Override
public void caseDoubleConstant(DoubleConstant 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.ConstantSwitch#caseDoubleConstant(soot.jimple.DoubleConstant)
 */
@Override
public void caseDoubleConstant(DoubleConstant v) {
}
项目:jgs    文件:SecurityLevelValueReadSwitch.java   
/**
 * Looks up the <em>security level</em> for the given constant and stores
 * the level in {@link SecurityLevelValueReadSwitch#level}. For a
 * {@link DoubleConstant} this is the weakest available
 * <em>security level</em>.
 * 
 * @param v
 *            The constant for which the <em>security level</em> should be
 *            looked up.
 * @see soot.jimple.ConstantSwitch#caseDoubleConstant(soot.jimple.DoubleConstant)
 */
@Override
public void caseDoubleConstant(DoubleConstant v) {
    this.level = getWeakestSecurityLevel();
}