Java Code Examples for proguard.evaluation.value.Value#TYPE_DOUBLE

The following examples show how to use proguard.evaluation.value.Value#TYPE_DOUBLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EvaluationShrinker.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the opcode of a push instruction corresponding to the given
 * computational type.
 * @param computationalType the computational type to be pushed on the stack.
 */
private byte pushOpcode(int computationalType)
{
    switch (computationalType)
    {
        case Value.TYPE_INTEGER:            return InstructionConstants.OP_ICONST_0;
        case Value.TYPE_LONG:               return InstructionConstants.OP_LCONST_0;
        case Value.TYPE_FLOAT:              return InstructionConstants.OP_FCONST_0;
        case Value.TYPE_DOUBLE:             return InstructionConstants.OP_DCONST_0;
        case Value.TYPE_REFERENCE:
        case Value.TYPE_INSTRUCTION_OFFSET: return InstructionConstants.OP_ACONST_NULL;
    }

    throw new IllegalArgumentException("No push opcode for computational type ["+computationalType+"]");
}
 
Example 2
Source File: EvaluationSimplifier.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Replaces the push instruction at the given offset by a simpler push
 * instruction, if possible.
 */
private void replaceAnyPushInstruction(Clazz       clazz,
                                       int         offset,
                                       Instruction instruction)
{
    Value pushedValue = partialEvaluator.getStackAfter(offset).getTop(0);
    if (pushedValue.isParticular())
    {
        switch (pushedValue.computationalType())
        {
            case Value.TYPE_INTEGER:
                replaceIntegerPushInstruction(clazz, offset, instruction);
                break;
            case Value.TYPE_LONG:
                replaceLongPushInstruction(clazz, offset, instruction);
                break;
            case Value.TYPE_FLOAT:
                replaceFloatPushInstruction(clazz, offset, instruction);
                break;
            case Value.TYPE_DOUBLE:
                replaceDoublePushInstruction(clazz, offset, instruction);
                break;
            case Value.TYPE_REFERENCE:
                replaceReferencePushInstruction(clazz, offset, instruction);
                break;
        }
    }
}
 
Example 3
Source File: CodePreverifier.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Creates and returns the verification type corresponding to the given
 * value. If necessary, a class constant is added to the constant pool of
 * the given class.
 */
private VerificationType correspondingVerificationType(ProgramClass  programClass,
                                                       ProgramMethod programMethod,
                                                       CodeAttribute codeAttribute,
                                                       int           offset,
                                                       boolean       isVariable0,
                                                       Value value,
                                                       Value producerValue)
{
    if (value == null)
    {
        return VerificationTypeFactory.createTopType();
    }

    int type = value.computationalType();

    switch (type)
    {
        case Value.TYPE_INSTRUCTION_OFFSET:
        case Value.TYPE_INTEGER:   return VerificationTypeFactory.createIntegerType();
        case Value.TYPE_LONG:      return VerificationTypeFactory.createLongType();
        case Value.TYPE_FLOAT:     return VerificationTypeFactory.createFloatType();
        case Value.TYPE_DOUBLE:    return VerificationTypeFactory.createDoubleType();
        case Value.TYPE_TOP:       return VerificationTypeFactory.createTopType();
        case Value.TYPE_REFERENCE:
            // Is it a Null type?
            ReferenceValue referenceValue = value.referenceValue();
            if (referenceValue.isNull() == Value.ALWAYS)
            {
                return VerificationTypeFactory.createNullType();
            }

            // Does the reference type have a single producer?
            if (offset != PartialEvaluator.AT_METHOD_ENTRY)
            {
                InstructionOffsetValue producers = producerValue.instructionOffsetValue();
                if (producers.instructionOffsetCount() == 1)
                {
                    int producerOffset = producers.instructionOffset(0);

                    // Follow any dup or swap instructions.
                    while (producerOffset != PartialEvaluator.AT_METHOD_ENTRY &&
                           isDupOrSwap(codeAttribute.code[producerOffset]))
                    {
                        producers      = partialEvaluator.getStackBefore(producerOffset).getTopProducerValue(0).instructionOffsetValue();
                        producerOffset = producers.instructionOffset(0);
                    }

                    // Are we in an instance initialization method,
                    // before the super initialization, loading "this"?
                    if (partialEvaluator.isInitializer()                       &&
                        offset <= partialEvaluator.superInitializationOffset() &&
                        (isVariable0 ||
                         producerOffset > PartialEvaluator.AT_METHOD_ENTRY &&
                         codeAttribute.code[producerOffset] == InstructionConstants.OP_ALOAD_0))
                    {
                        // It's an UninitializedThis type.
                        return VerificationTypeFactory.createUninitializedThisType();
                    }

                    // Is the reference type newly created and still
                    // uninitialized?
                    if (producerOffset > PartialEvaluator.AT_METHOD_ENTRY &&
                        offset <= partialEvaluator.initializationOffset(producerOffset))
                    {
                        // It's an Uninitialized type.
                        return VerificationTypeFactory.createUninitializedType(producerOffset);
                    }
                }
            }

            // It's an ordinary Object type.
            return VerificationTypeFactory.createObjectType(createClassConstant(programClass, referenceValue));
    }

    throw new IllegalArgumentException("Unknown computational type ["+type+"]");
}