proguard.optimize.evaluation.StoringInvocationUnit Java Examples

The following examples show how to use proguard.optimize.evaluation.StoringInvocationUnit. 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: ConstantParameterFilter.java    From bazel with Apache License 2.0 6 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // All parameters of non-static methods are shifted by one in the local
    // variable frame.
    int firstParameterIndex =
        (programMethod.getAccessFlags() & ClassConstants.ACC_STATIC) != 0 ?
            0 : 1;

    int parameterCount =
        ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass));

    for (int index = firstParameterIndex; index < parameterCount; index++)
    {
        Value value = StoringInvocationUnit.getMethodParameterValue(programMethod, index);
        if (value != null &&
            value.isParticular())
        {
            constantParameterVisitor.visitProgramMethod(programClass, programMethod);
        }
    }
}
 
Example #2
Source File: ConstantParameterFilter.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // All parameters of non-static methods are shifted by one in the local
    // variable frame.
    boolean isStatic =
        (programMethod.getAccessFlags() & AccessConstants.STATIC) != 0;

    int parameterStart = isStatic ? 0 : 1;
    int parameterCount =
        ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass),
                                               isStatic);

    for (int index = parameterStart; index < parameterCount; index++)
    {
        Value value = StoringInvocationUnit.getMethodParameterValue(programMethod, index);
        if (value != null &&
            value.isParticular())
        {
            constantParameterVisitor.visitProgramMethod(programClass, programMethod);
        }
    }
}
 
Example #3
Source File: MemberDescriptorSpecializer.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
    Value parameterValue = StoringInvocationUnit.getFieldValue(programField);
    if (parameterValue.computationalType() == Value.TYPE_REFERENCE)
    {
        Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();
        if (programField.referencedClass != referencedClass)
        {
            if (DEBUG)
            {
                System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass));
                System.out.println("  "+programField.referencedClass.getName()+" -> "+referencedClass.getName());
            }

            programField.referencedClass = referencedClass;

            // Visit the field, if required.
            if (extraParameterMemberVisitor != null)
            {
                extraParameterMemberVisitor.visitProgramField(programClass, programField);
            }
        }
    }
}
 
Example #4
Source File: MemberDescriptorSpecializer.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
    Value parameterValue = StoringInvocationUnit.getFieldValue(programField);
    if (parameterValue.computationalType() == Value.TYPE_REFERENCE)
    {
        Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();
        if (programField.referencedClass != referencedClass)
        {
            if (DEBUG)
            {
                System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass));
                System.out.println("  "+programField.referencedClass.getName()+" -> "+referencedClass.getName());
            }

            programField.referencedClass = referencedClass;

            // Visit the field, if required.
            if (extraParameterMemberVisitor != null)
            {
                extraParameterMemberVisitor.visitProgramField(programClass, programField);
            }
        }
    }
}
 
Example #5
Source File: ConstantParameterFilter.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // All parameters of non-static methods are shifted by one in the local
    // variable frame.
    int firstParameterIndex =
        (programMethod.getAccessFlags() & ClassConstants.ACC_STATIC) != 0 ?
            0 : 1;

    int parameterCount =
        ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass));

    for (int index = firstParameterIndex; index < parameterCount; index++)
    {
        Value value = StoringInvocationUnit.getMethodParameterValue(programMethod, index);
        if (value != null &&
            value.isParticular())
        {
            constantParameterVisitor.visitProgramMethod(programClass, programMethod);
        }
    }
}
 
Example #6
Source File: ConstantParameterFilter.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // All parameters of non-static methods are shifted by one in the local
    // variable frame.
    int firstParameterIndex =
        (programMethod.getAccessFlags() & ClassConstants.INTERNAL_ACC_STATIC) != 0 ?
            0 : 1;

    int parameterCount =
        ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass));

    for (int index = firstParameterIndex; index < parameterCount; index++)
    {
        Value value = StoringInvocationUnit.getMethodParameterValue(programMethod, index);
        if (value != null &&
            value.isParticular())
        {
            constantParameterVisitor.visitProgramMethod(programClass, programMethod);
        }
    }
}
 
Example #7
Source File: MemberDescriptorSpecializer.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
    Value parameterValue = StoringInvocationUnit.getFieldValue(programField);
    if (parameterValue.computationalType() == Value.TYPE_REFERENCE)
    {
        Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();
        if (programField.referencedClass != referencedClass)
        {
            if (DEBUG)
            {
                System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass));
                System.out.println("  "+programField.referencedClass.getName()+" -> "+referencedClass.getName());
            }

            programField.referencedClass = referencedClass;

            // Visit the field, if required.
            if (extraParameterMemberVisitor != null)
            {
                extraParameterMemberVisitor.visitProgramField(programClass, programField);
            }
        }
    }
}
 
Example #8
Source File: MemberDescriptorSpecializer.java    From bazel with Apache License 2.0 6 votes vote down vote up
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
    Value parameterValue = StoringInvocationUnit.getFieldValue(programField);
    if (parameterValue.computationalType() == Value.TYPE_REFERENCE)
    {
        Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();
        if (programField.referencedClass != referencedClass)
        {
            if (DEBUG)
            {
                System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass));
                System.out.println("  "+programField.referencedClass.getName()+" -> "+referencedClass.getName());
            }

            programField.referencedClass = referencedClass;

            // Visit the field, if required.
            if (extraParameterMemberVisitor != null)
            {
                extraParameterMemberVisitor.visitProgramField(programClass, programField);
            }
        }
    }
}
 
Example #9
Source File: ConstantMemberFilter.java    From bazel with Apache License 2.0 5 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    Value value = StoringInvocationUnit.getMethodReturnValue(programMethod);
    if (value != null &&
        value.isParticular())
    {
        constantMemberVisitor.visitProgramMethod(programClass, programMethod);
    }
}
 
Example #10
Source File: ConstantMemberFilter.java    From bazel with Apache License 2.0 5 votes vote down vote up
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
    Value value = StoringInvocationUnit.getFieldValue(programField);
    if (value != null &&
        value.isParticular())
    {
        constantMemberVisitor.visitProgramField(programClass, programField);
    }
}
 
Example #11
Source File: ConstantMemberFilter.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    Value value = StoringInvocationUnit.getMethodReturnValue(programMethod);
    if (value != null &&
        value.isParticular())
    {
        constantMemberVisitor.visitProgramMethod(programClass, programMethod);
    }
}
 
Example #12
Source File: ConstantMemberFilter.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
    Value value = StoringInvocationUnit.getFieldValue(programField);
    if (value != null &&
        value.isParticular())
    {
        constantMemberVisitor.visitProgramField(programClass, programField);
    }
}
 
Example #13
Source File: ConstantMemberFilter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    Value value = StoringInvocationUnit.getMethodReturnValue(programMethod);
    if (value != null &&
        value.isParticular())
    {
        constantMemberVisitor.visitProgramMethod(programClass, programMethod);
    }
}
 
Example #14
Source File: ConstantMemberFilter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
    Value value = StoringInvocationUnit.getFieldValue(programField);
    if (value != null &&
        value.isParticular())
    {
        constantMemberVisitor.visitProgramField(programClass, programField);
    }
}
 
Example #15
Source File: WrapperClassMarker.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // Is the method an initializer?
    if (ClassUtil.isInitializer(programMethod.getName(programClass)))
    {
        // Does it have exactly one parameter?
        if (ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass)) == 1)
        {
            // Is the parameter a non-null reference?
            Value value =
                StoringInvocationUnit.getMethodParameterValue(programMethod, 1);

            if (value != null                                     &&
                value.computationalType() == Value.TYPE_REFERENCE &&
                value.referenceValue().isNotNull() == Value.ALWAYS)
            {
                // Does the method initialize the field?
                programMethod.attributesAccept(programClass, this);
            }
            else
            {
                wrapCounter = Integer.MIN_VALUE;
            }
        }
        else
        {
            wrapCounter = Integer.MIN_VALUE;
        }
    }
}
 
Example #16
Source File: ConstantMemberFilter.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    Value value = StoringInvocationUnit.getMethodReturnValue(programMethod);
    if (value != null &&
        value.isParticular())
    {
        constantMemberVisitor.visitProgramMethod(programClass, programMethod);
    }
}
 
Example #17
Source File: ConstantMemberFilter.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
    Value value = StoringInvocationUnit.getFieldValue(programField);
    if (value != null &&
        value.isParticular())
    {
        constantMemberVisitor.visitProgramField(programClass, programField);
    }
}
 
Example #18
Source File: MemberDescriptorSpecializer.java    From bazel with Apache License 2.0 4 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // All parameters of non-static methods are shifted by one in the local
    // variable frame.
    int firstParameterIndex =
        (programMethod.getAccessFlags() & ClassConstants.ACC_STATIC) != 0 ?
            0 : 1;

    int parameterCount =
        ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass));

    int classIndex = 0;

    // Go over the parameters.
    for (int parameterIndex = firstParameterIndex; parameterIndex < parameterCount; parameterIndex++)
    {
        Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex);
         if (parameterValue.computationalType() == Value.TYPE_REFERENCE)
         {
             Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();
             if (programMethod.referencedClasses[classIndex] != referencedClass)
             {
                 if (DEBUG)
                 {
                     System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass));
                     System.out.println("  "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName());
                 }

                 programMethod.referencedClasses[classIndex] = referencedClass;

                 // Visit the method, if required.
                 if (extraParameterMemberVisitor != null)
                 {
                     extraParameterMemberVisitor.visitProgramMethod(programClass, programMethod);
                 }
             }

             classIndex++;
         }
    }
}
 
Example #19
Source File: MemberDescriptorSpecializer.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // All parameters of non-static methods are shifted by one in the local
    // variable frame.
    int firstParameterIndex =
        (programMethod.getAccessFlags() & ClassConstants.ACC_STATIC) != 0 ?
            0 : 1;

    int parameterCount =
        ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass));

    int classIndex = 0;

    // Go over the parameters.
    for (int parameterIndex = firstParameterIndex; parameterIndex < parameterCount; parameterIndex++)
    {
        Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex);
         if (parameterValue.computationalType() == Value.TYPE_REFERENCE)
         {
             Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();
             if (programMethod.referencedClasses[classIndex] != referencedClass)
             {
                 if (DEBUG)
                 {
                     System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass));
                     System.out.println("  "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName());
                 }

                 programMethod.referencedClasses[classIndex] = referencedClass;

                 // Visit the method, if required.
                 if (extraParameterMemberVisitor != null)
                 {
                     extraParameterMemberVisitor.visitProgramMethod(programClass, programMethod);
                 }
             }

             classIndex++;
         }
    }
}
 
Example #20
Source File: MemberDescriptorSpecializer.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // All parameters of non-static methods are shifted by one in the local
    // variable frame.
    int firstParameterIndex =
        (programMethod.getAccessFlags() & ClassConstants.INTERNAL_ACC_STATIC) != 0 ?
            0 : 1;

    int parameterCount =
        ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass));

    int classIndex = 0;

    // Go over the parameters.
    for (int parameterIndex = firstParameterIndex; parameterIndex < parameterCount; parameterIndex++)
    {
        Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex);
         if (parameterValue.computationalType() == Value.TYPE_REFERENCE)
         {
             Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();
             if (programMethod.referencedClasses[classIndex] != referencedClass)
             {
                 if (DEBUG)
                 {
                     System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass));
                     System.out.println("  "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName());
                 }

                 programMethod.referencedClasses[classIndex] = referencedClass;

                 // Visit the method, if required.
                 if (extraParameterMemberVisitor != null)
                 {
                     extraParameterMemberVisitor.visitProgramMethod(programClass, programMethod);
                 }
             }

             classIndex++;
         }
    }
}
 
Example #21
Source File: MemberDescriptorSpecializer.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
    // All parameters of non-static methods are shifted by one in the local
    // variable frame.
    boolean isStatic =
        (programMethod.getAccessFlags() & AccessConstants.STATIC) != 0;

    int parameterStart = isStatic ? 0 : 1;
    int parameterCount =
        ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass),
                                               isStatic);

    int classIndex = 0;

    // Go over the parameters.
    for (int parameterIndex = parameterStart; parameterIndex < parameterCount; parameterIndex++)
    {
        Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex);
         if (parameterValue.computationalType() == Value.TYPE_REFERENCE)
         {
             Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();
             if (programMethod.referencedClasses[classIndex] != referencedClass)
             {
                 if (DEBUG)
                 {
                     System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass));
                     System.out.println("  "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName());
                 }

                 programMethod.referencedClasses[classIndex] = referencedClass;

                 // Visit the method, if required.
                 if (extraParameterMemberVisitor != null)
                 {
                     extraParameterMemberVisitor.visitProgramMethod(programClass, programMethod);
                 }
             }

             classIndex++;
         }
    }
}