Java Code Examples for proguard.classfile.VisitorAccepter

The following examples show how to use proguard.classfile.VisitorAccepter. These examples are extracted from open source projects. 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 Project: java-n-IDE-for-Android   Source File: ClassShrinker.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Removes all VisitorAccepter objects that are not marked as being used
 * from the given array.
 * @return the new number of VisitorAccepter objects.
 */
private int shrinkArray(VisitorAccepter[] array, int length)
{
    int counter = 0;

    // Shift the used objects together.
    for (int index = 0; index < length; index++)
    {
        if (usageMarker.isUsed(array[index]))
        {
            array[counter++] = array[index];
        }
    }

    // Clear the remaining array elements.
    for (int index = counter; index < length; index++)
    {
        array[index] = null;
    }

    return counter;
}
 
Example 2
private void checkCause(VisitorAccepter visitorAccepter)
{
    if (ShortestUsageMarker.this.isUsed(visitorAccepter))
    {
        ShortestUsageMark shortestUsageMark = ShortestUsageMarker.this.getShortestUsageMark(visitorAccepter);

        // Check the class of this mark, if any
        isRecursing = shortestUsageMark.isCausedBy(checkClass);

        // Check the causing class or method, if still necessary.
        if (!isRecursing)
        {
            shortestUsageMark.acceptClassVisitor(this);
            shortestUsageMark.acceptMemberVisitor(this);
        }
    }
}
 
Example 3
private void printReason(VisitorAccepter visitorAccepter)
{
    if (shortestUsageMarker.isUsed(visitorAccepter))
    {
        ShortestUsageMark shortestUsageMark = shortestUsageMarker.getShortestUsageMark(visitorAccepter);

        // Print the reason for keeping this class.
        ps.print("  " + shortestUsageMark.getReason());

        // Print the class or method that is responsible, with its reasons.
        shortestUsageMark.acceptClassVisitor(this);
        shortestUsageMark.acceptMemberVisitor(this);
    }
    else
    {
        ps.println("  is not being kept.\n");
    }
}
 
Example 4
Source Project: java-n-IDE-for-Android   Source File: AttributeShrinker.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Removes all VisitorAccepter objects that are not marked as being used
 * from the given array.
 * @return the new number of VisitorAccepter objects.
 */
private static int shrinkArray(VisitorAccepter[] array, int length)
{
    int counter = 0;

    // Shift the used objects together.
    for (int index = 0; index < length; index++)
    {
        if (AttributeUsageMarker.isUsed(array[index]))
        {
            array[counter++] = array[index];
        }
    }

    // Clear the remaining array elements.
    for (int index = counter; index < length; index++)
    {
        array[index] = null;
    }

    return counter;
}
 
Example 5
protected void markAsUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    ShortestUsageMark shortestUsageMark =
        visitorInfo != null                           &&
        visitorInfo instanceof ShortestUsageMark &&
        !((ShortestUsageMark)visitorInfo).isCertain() &&
        !currentUsageMark.isShorter((ShortestUsageMark)visitorInfo) ?
            new ShortestUsageMark((ShortestUsageMark)visitorInfo, true):
            currentUsageMark;

    visitorAccepter.setVisitorInfo(shortestUsageMark);
}
 
Example 6
protected boolean shouldBeMarkedAsUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return //!(visitorAccepter instanceof Clazz &&
           //  isCausedBy(currentUsageMark, (Clazz)visitorAccepter)) &&
           (visitorInfo == null                           ||
           !(visitorInfo instanceof ShortestUsageMark)   ||
           !((ShortestUsageMark)visitorInfo).isCertain() ||
           currentUsageMark.isShorter((ShortestUsageMark)visitorInfo));
}
 
Example 7
protected boolean isUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return visitorInfo != null                      &&
           visitorInfo instanceof ShortestUsageMark &&
           ((ShortestUsageMark)visitorInfo).isCertain();
}
 
Example 8
protected boolean shouldBeMarkedAsPossiblyUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return visitorInfo == null                         ||
           !(visitorInfo instanceof ShortestUsageMark) ||
           (!((ShortestUsageMark)visitorInfo).isCertain() &&
            currentUsageMark.isShorter((ShortestUsageMark)visitorInfo));
}
 
Example 9
protected boolean isPossiblyUsed(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return visitorInfo != null                      &&
           visitorInfo instanceof ShortestUsageMark &&
           !((ShortestUsageMark)visitorInfo).isCertain();
}
 
Example 10
Source Project: java-n-IDE-for-Android   Source File: MemberObfuscator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Assigns a fixed new name to the given class member.
 * @param member the class member.
 * @param name   the new name.
 */
static void setFixedNewMemberName(Member member, String name)
{
    VisitorAccepter lastVisitorAccepter = MethodLinker.lastVisitorAccepter(member);

    if (!(lastVisitorAccepter instanceof LibraryMember) &&
        !(lastVisitorAccepter instanceof MyFixedName))
    {
        lastVisitorAccepter.setVisitorInfo(new MyFixedName(name));
    }
    else
    {
        lastVisitorAccepter.setVisitorInfo(name);
    }
}
 
Example 11
Source Project: java-n-IDE-for-Android   Source File: MemberObfuscator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns whether the new name of the given class member is fixed.
 * @param member the class member.
 * @return whether its new name is fixed.
 */
static boolean hasFixedNewMemberName(Member member)
{
    VisitorAccepter lastVisitorAccepter = MethodLinker.lastVisitorAccepter(member);

    return lastVisitorAccepter instanceof LibraryMember ||
           lastVisitorAccepter instanceof MyFixedName;
}
 
Example 12
Source Project: java-n-IDE-for-Android   Source File: UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Marks the given visitor accepter as being used.
 */
protected void markAsUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(USED);
}
 
Example 13
Source Project: java-n-IDE-for-Android   Source File: UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given visitor accepter should still be marked as
 * being used.
 */
protected boolean shouldBeMarkedAsUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() != USED;
}
 
Example 14
Source Project: java-n-IDE-for-Android   Source File: UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given visitor accepter has been marked as being used.
 */
protected boolean isUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == USED;
}
 
Example 15
Source Project: java-n-IDE-for-Android   Source File: UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Marks the given visitor accepter as possibly being used.
 */
protected void markAsPossiblyUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(POSSIBLY_USED);
}
 
Example 16
Source Project: java-n-IDE-for-Android   Source File: UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given visitor accepter should still be marked as
 * possibly being used.
 */
protected boolean shouldBeMarkedAsPossiblyUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() != USED &&
           visitorAccepter.getVisitorInfo() != POSSIBLY_USED;
}
 
Example 17
Source Project: java-n-IDE-for-Android   Source File: UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given visitor accepter has been marked as possibly
 * being used.
 */
protected boolean isPossiblyUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == POSSIBLY_USED;
}
 
Example 18
Source Project: java-n-IDE-for-Android   Source File: UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Clears any usage marks from the given visitor accepter.
 */
protected void markAsUnused(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(null);
}
 
Example 19
protected void markAsPossiblyUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(new ShortestUsageMark(currentUsageMark, false));
}
 
Example 20
protected ShortestUsageMark getShortestUsageMark(VisitorAccepter visitorAccepter)
{
    Object visitorInfo = visitorAccepter.getVisitorInfo();

    return (ShortestUsageMark)visitorInfo;
}
 
Example 21
Source Project: java-n-IDE-for-Android   Source File: ClassPrinter.java    License: Apache License 2.0 4 votes vote down vote up
private String visitorInfo(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == null ? "-" : "+";
}
 
Example 22
Source Project: java-n-IDE-for-Android   Source File: ClassCleaner.java    License: Apache License 2.0 4 votes vote down vote up
private void clean(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(null);
}
 
Example 23
Source Project: java-n-IDE-for-Android   Source File: KeepMarker.java    License: Apache License 2.0 4 votes vote down vote up
private static void markAsKept(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(KEPT);
}
 
Example 24
Source Project: java-n-IDE-for-Android   Source File: KeepMarker.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean isKept(VisitorAccepter visitorAccepter)
{
    return MethodLinker.lastVisitorAccepter(visitorAccepter).getVisitorInfo() == KEPT;
}
 
Example 25
Source Project: java-n-IDE-for-Android   Source File: Utf8UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Marks the given VisitorAccepter as being used.
 * In this context, the VisitorAccepter will be a Utf8Constant object.
 */
private static void markAsUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(USED);
}
 
Example 26
Source Project: java-n-IDE-for-Android   Source File: Utf8UsageMarker.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns whether the given VisitorAccepter has been marked as being used.
 * In this context, the VisitorAccepter will be a Utf8Constant object.
 */
static boolean isUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == USED;
}
 
Example 27
/**
 * Marks the given VisitorAccepter as being used.
 * In this context, the VisitorAccepter will be a NameAndTypeConstant object.
 */
private static void markAsUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(USED);
}
 
Example 28
/**
 * Returns whether the given VisitorAccepter has been marked as being used.
 * In this context, the VisitorAccepter will be a NameAndTypeConstant object.
 */
static boolean isUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == USED;
}
 
Example 29
/**
 * Marks the given VisitorAccepter as being used (or useful).
 * In this context, the VisitorAccepter will be an Attribute object.
 */
private static void markAsUsed(VisitorAccepter visitorAccepter)
{
    visitorAccepter.setVisitorInfo(USED);
}
 
Example 30
/**
 * Returns whether the given VisitorAccepter has been marked as being used.
 * In this context, the VisitorAccepter will be an Attribute object.
 */
static boolean isUsed(VisitorAccepter visitorAccepter)
{
    return visitorAccepter.getVisitorInfo() == USED;
}