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

The following examples show how to use proguard.evaluation.value.Value#ALWAYS . 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: Processor.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitTableSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, TableSwitchInstruction tableSwitchInstruction)
{
    IntegerValue indexValue = stack.ipop();

    // If there is no definite branch in any of the cases below,
    // branch to the default offset.
    branchUnit.branch(clazz, codeAttribute,
                      offset,
                      offset + tableSwitchInstruction.defaultOffset);

    for (int index = 0; index < tableSwitchInstruction.jumpOffsets.length; index++)
    {
        int conditional = indexValue.equal(valueFactory.createIntegerValue(
            tableSwitchInstruction.lowCase + index));
        branchUnit.branchConditionally(clazz, codeAttribute,
                                       offset,
                                       offset + tableSwitchInstruction.jumpOffsets[index],
                                       conditional);

        // If this branch is always taken, we can skip the rest.
        if (conditional == Value.ALWAYS)
        {
            break;
        }
    }
}
 
Example 2
Source File: Processor.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitLookUpSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LookUpSwitchInstruction lookUpSwitchInstruction)
{
    IntegerValue indexValue = stack.ipop();

    // If there is no definite branch in any of the cases below,
    // branch to the default offset.
    branchUnit.branch(clazz, codeAttribute,
                      offset,
                      offset + lookUpSwitchInstruction.defaultOffset);

    for (int index = 0; index < lookUpSwitchInstruction.jumpOffsets.length; index++)
    {
        int conditional = indexValue.equal(valueFactory.createIntegerValue(
            lookUpSwitchInstruction.cases[index]));
        branchUnit.branchConditionally(clazz, codeAttribute,
                                       offset,
                                       offset + lookUpSwitchInstruction.jumpOffsets[index],
                                       conditional);

        // If this branch is always taken, we can skip the rest.
        if (conditional == Value.ALWAYS)
        {
            break;
        }
    }
}
 
Example 3
Source File: TracedBranchUnit.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void branchConditionally(Clazz         clazz,
                                CodeAttribute codeAttribute,
                                int           offset,
                                int           branchTarget,
                                int           conditional)
{
    if      (conditional == Value.ALWAYS)
    {
        // Always branch.
        super.branch(clazz, codeAttribute, offset, branchTarget);
    }
    else if (conditional != Value.NEVER)
    {
        // Maybe branch.
        super.branchConditionally(clazz, codeAttribute, offset, branchTarget, conditional);
    }
    else
    {
        super.setCalled();
    }
}
 
Example 4
Source File: TracedBranchUnit.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
public void branchConditionally(Clazz         clazz,
                                CodeAttribute codeAttribute,
                                int           offset,
                                int           branchTarget,
                                int           conditional)
{
    if      (conditional == Value.ALWAYS)
    {
        // Always branch.
        super.branch(clazz, codeAttribute, offset, branchTarget);
    }
    else if (conditional != Value.NEVER)
    {
        // Maybe branch.
        super.branchConditionally(clazz, codeAttribute, offset, branchTarget, conditional);
    }
    else
    {
        super.setCalled();
    }
}
 
Example 5
Source File: TracedBranchUnit.java    From bazel with Apache License 2.0 6 votes vote down vote up
public void branchConditionally(Clazz         clazz,
                                CodeAttribute codeAttribute,
                                int           offset,
                                int           branchTarget,
                                int           conditional)
{
    if      (conditional == Value.ALWAYS)
    {
        // Always branch.
        super.branch(clazz, codeAttribute, offset, branchTarget);
    }
    else if (conditional != Value.NEVER)
    {
        // Maybe branch.
        super.branchConditionally(clazz, codeAttribute, offset, branchTarget, conditional);
    }
    else
    {
        super.setCalled();
    }
}
 
Example 6
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+"]");
}