Example usage for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccBridge

List of usage examples for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccBridge

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccBridge.

Prototype

int AccBridge

To view the source code for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccBridge.

Click Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectMapper.java

License:Open Source License

/**
 * Test whether candidate is a suitable adjustment for toLookFor.
 * Traversal uses copyInheritanceSrc and overriddenTSuper.
 * Rank is determined by depth of traversal needed to find a connection.
 *
 * PRE: length of parameterlists has been checked.
 *
 * @return a small positiv integer value if suitable. Integer.MAX_VALUE if candidate is not suitable.
 *//*from  w  ww . j av a2s.  c  o  m*/
private static int rankMethod(MethodBinding toLookFor, MethodBinding candidate, int currentRank) {
    currentRank++;
    if (candidate == null || toLookFor == null)
        return Integer.MAX_VALUE;
    toLookFor = toLookFor.original();
    candidate = candidate.original();
    if (candidate == toLookFor)
        return currentRank;
    if (currentRank > 0 // at top level we search all methods by this name any way.
            && (candidate.modifiers & ClassFileConstants.AccBridge) != 0) {
        // bridge method: there must be a matching regular method: find it:
        MethodBinding[] otherMethods = candidate.declaringClass.getMethods(candidate.selector);
        methods: for (MethodBinding other : otherMethods) {
            if (other != candidate && other.parameters.length == candidate.parameters.length) {
                for (int i = 0; i < other.parameters.length; i++)
                    if (TypeBinding.notEquals(other.parameters[i], candidate.parameters[i]))
                        continue methods;
                if (other == toLookFor)
                    return currentRank;
                break;
            }
        }
    }
    int rank = rankMethod(toLookFor, candidate.copyInheritanceSrc, currentRank);
    if (rank < Integer.MAX_VALUE)
        return rank;
    rank = rankMethod(toLookFor.copyInheritanceSrc, candidate, currentRank);
    if (rank < Integer.MAX_VALUE)
        return rank;
    if (candidate.overriddenTSupers != null)
        for (int i = 0; i < candidate.overriddenTSupers.length; i++) {
            rank = rankMethod(toLookFor, candidate.overriddenTSupers[i], currentRank);
            if (rank < Integer.MAX_VALUE)
                return rank;
        }
    if (toLookFor.overriddenTSupers != null)
        for (int i = 0; i < toLookFor.overriddenTSupers.length; i++) {
            rank = rankMethod(toLookFor.overriddenTSupers[i], candidate, currentRank);
            if (rank < Integer.MAX_VALUE)
                return rank;
        }
    return Integer.MAX_VALUE;
}