Example usage for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding METHOD_EMUL

List of usage examples for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding METHOD_EMUL

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding METHOD_EMUL.

Prototype

int METHOD_EMUL

To view the source code for org.eclipse.jdt.internal.compiler.lookup SourceTypeBinding METHOD_EMUL.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding addSyntheticMethod(FieldBinding targetField, boolean isReadAccess,
        boolean isSuperAccess) {
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
        this.synthetics[SourceTypeBinding.METHOD_EMUL] = new HashMap(5);

    SyntheticMethodBinding accessMethod = null;
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(targetField);//from  w  ww .  ja v a  2s . co  m
    if (accessors == null) {
        accessMethod = new SyntheticMethodBinding(targetField, isReadAccess, isSuperAccess, this);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(targetField,
                accessors = new SyntheticMethodBinding[2]);
        accessors[isReadAccess ? 0 : 1] = accessMethod;
    } else {
        if ((accessMethod = accessors[isReadAccess ? 0 : 1]) == null) {
            accessMethod = new SyntheticMethodBinding(targetField, isReadAccess, isSuperAccess, this);
            accessors[isReadAccess ? 0 : 1] = accessMethod;
        }
    }
    return accessMethod;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding addSyntheticEnumMethod(char[] selector) {
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
        this.synthetics[SourceTypeBinding.METHOD_EMUL] = new HashMap(5);

    SyntheticMethodBinding accessMethod = null;
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(selector);//from   ww w  . j  a  v a  2s. co m
    if (accessors == null) {
        accessMethod = new SyntheticMethodBinding(this, selector);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(selector, accessors = new SyntheticMethodBinding[2]);
        accessors[0] = accessMethod;
    } else {
        if ((accessMethod = accessors[0]) == null) {
            accessMethod = new SyntheticMethodBinding(this, selector);
            accessors[0] = accessMethod;
        }
    }
    return accessMethod;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding addSyntheticMethodForSwitchEnum(TypeBinding enumBinding) {
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
        this.synthetics[SourceTypeBinding.METHOD_EMUL] = new HashMap(5);

    SyntheticMethodBinding accessMethod = null;
    char[] selector = CharOperation.concat(TypeConstants.SYNTHETIC_SWITCH_ENUM_TABLE,
            enumBinding.constantPoolName());
    CharOperation.replace(selector, '/', '$');
    final String key = new String(selector);
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(key);//from w  w w  .j av a  2  s. co m
    // first add the corresponding synthetic field
    if (accessors == null) {
        // then create the synthetic method
        final SyntheticFieldBinding fieldBinding = addSyntheticFieldForSwitchEnum(selector, key);
        accessMethod = new SyntheticMethodBinding(fieldBinding, this, enumBinding, selector);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(key, accessors = new SyntheticMethodBinding[2]);
        accessors[0] = accessMethod;
    } else {
        if ((accessMethod = accessors[0]) == null) {
            final SyntheticFieldBinding fieldBinding = addSyntheticFieldForSwitchEnum(selector, key);
            accessMethod = new SyntheticMethodBinding(fieldBinding, this, enumBinding, selector);
            accessors[0] = accessMethod;
        }
    }
    return accessMethod;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding addSyntheticMethodForEnumInitialization(int begin, int end) {
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
        this.synthetics[SourceTypeBinding.METHOD_EMUL] = new HashMap(5);

    SyntheticMethodBinding accessMethod = new SyntheticMethodBinding(this, begin, end);
    SyntheticMethodBinding[] accessors = new SyntheticMethodBinding[2];
    this.synthetics[SourceTypeBinding.METHOD_EMUL].put(accessMethod.selector, accessors);
    accessors[0] = accessMethod;//from  w  w  w  .  j a v  a  2s .c  o  m
    return accessMethod;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding addSyntheticMethod(MethodBinding targetMethod, boolean isSuperAccess) {
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
        this.synthetics[SourceTypeBinding.METHOD_EMUL] = new HashMap(5);

    SyntheticMethodBinding accessMethod = null;
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(targetMethod);/*from   w  w  w  .j  av a 2 s. co m*/
    if (accessors == null) {
        accessMethod = new SyntheticMethodBinding(targetMethod, isSuperAccess, this);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(targetMethod,
                accessors = new SyntheticMethodBinding[2]);
        accessors[isSuperAccess ? 0 : 1] = accessMethod;
    } else {
        if ((accessMethod = accessors[isSuperAccess ? 0 : 1]) == null) {
            accessMethod = new SyntheticMethodBinding(targetMethod, isSuperAccess, this);
            accessors[isSuperAccess ? 0 : 1] = accessMethod;
        }
    }
    if (targetMethod.declaringClass.isStatic()) {
        if ((targetMethod.isConstructor() && targetMethod.parameters.length >= 0xFE)
                || targetMethod.parameters.length >= 0xFF) {
            this.scope.problemReporter().tooManyParametersForSyntheticMethod(targetMethod.sourceMethod());
        }
    } else if ((targetMethod.isConstructor() && targetMethod.parameters.length >= 0xFD)
            || targetMethod.parameters.length >= 0xFE) {
        this.scope.problemReporter().tooManyParametersForSyntheticMethod(targetMethod.sourceMethod());
    }
    return accessMethod;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding addSyntheticBridgeMethod(MethodBinding inheritedMethodToBridge,
        MethodBinding targetMethod) {//from w ww  .  j  av a2 s  . co m
    if (isInterface())
        return null; // only classes & enums get bridge methods
    // targetMethod may be inherited
    if (inheritedMethodToBridge.returnType.erasure() == targetMethod.returnType.erasure()
            && inheritedMethodToBridge.areParameterErasuresEqual(targetMethod)) {
        return null; // do not need bridge method
    }
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null) {
        this.synthetics[SourceTypeBinding.METHOD_EMUL] = new HashMap(5);
    } else {
        // check to see if there is another equivalent inheritedMethod already added
        Iterator synthMethods = this.synthetics[SourceTypeBinding.METHOD_EMUL].keySet().iterator();
        while (synthMethods.hasNext()) {
            Object synthetic = synthMethods.next();
            if (synthetic instanceof MethodBinding) {
                MethodBinding method = (MethodBinding) synthetic;
                if (CharOperation.equals(inheritedMethodToBridge.selector, method.selector)
                        && inheritedMethodToBridge.returnType.erasure() == method.returnType.erasure()
                        && inheritedMethodToBridge.areParameterErasuresEqual(method)) {
                    return null;
                }
            }
        }
    }

    SyntheticMethodBinding accessMethod = null;
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(inheritedMethodToBridge);
    if (accessors == null) {
        accessMethod = new SyntheticMethodBinding(inheritedMethodToBridge, targetMethod, this);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(inheritedMethodToBridge,
                accessors = new SyntheticMethodBinding[2]);
        accessors[1] = accessMethod;
    } else {
        if ((accessMethod = accessors[1]) == null) {
            accessMethod = new SyntheticMethodBinding(inheritedMethodToBridge, targetMethod, this);
            accessors[1] = accessMethod;
        }
    }
    return accessMethod;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding addSyntheticBridgeMethod(MethodBinding inheritedMethodToBridge) {
    if (this.scope.compilerOptions().complianceLevel <= ClassFileConstants.JDK1_5) {
        return null;
    }/*www  .  j  av  a 2s .c  o m*/
    if (isInterface())
        return null;
    if (inheritedMethodToBridge.isAbstract() || inheritedMethodToBridge.isFinal()
            || inheritedMethodToBridge.isStatic()) {
        return null;
    }
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null) {
        this.synthetics[SourceTypeBinding.METHOD_EMUL] = new HashMap(5);
    } else {
        // check to see if there is another equivalent inheritedMethod already added
        Iterator synthMethods = this.synthetics[SourceTypeBinding.METHOD_EMUL].keySet().iterator();
        while (synthMethods.hasNext()) {
            Object synthetic = synthMethods.next();
            if (synthetic instanceof MethodBinding) {
                MethodBinding method = (MethodBinding) synthetic;
                if (CharOperation.equals(inheritedMethodToBridge.selector, method.selector)
                        && inheritedMethodToBridge.returnType.erasure() == method.returnType.erasure()
                        && inheritedMethodToBridge.areParameterErasuresEqual(method)) {
                    return null;
                }
            }
        }
    }

    SyntheticMethodBinding accessMethod = null;
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(inheritedMethodToBridge);
    if (accessors == null) {
        accessMethod = new SyntheticMethodBinding(inheritedMethodToBridge, this);
        this.synthetics[SourceTypeBinding.METHOD_EMUL].put(inheritedMethodToBridge,
                accessors = new SyntheticMethodBinding[2]);
        accessors[0] = accessMethod;
    } else {
        if ((accessMethod = accessors[0]) == null) {
            accessMethod = new SyntheticMethodBinding(inheritedMethodToBridge, this);
            accessors[0] = accessMethod;
        }
    }
    return accessMethod;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding getSyntheticBridgeMethod(MethodBinding inheritedMethodToBridge) {
    if (this.synthetics == null)
        return null;
    if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
        return null;
    SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL]
            .get(inheritedMethodToBridge);
    if (accessors == null)
        return null;
    return accessors[1];
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public SyntheticMethodBinding[] syntheticMethods() {
    if (this.synthetics == null || this.synthetics[SourceTypeBinding.METHOD_EMUL] == null
            || this.synthetics[SourceTypeBinding.METHOD_EMUL].size() == 0) {
        return null;
    }/*from  w w w . jav a  2 s  .com*/
    // difficult to compute size up front because of the embedded arrays so assume there is only 1
    int index = 0;
    SyntheticMethodBinding[] bindings = new SyntheticMethodBinding[1];
    Iterator methodArrayIterator = this.synthetics[SourceTypeBinding.METHOD_EMUL].values().iterator();
    while (methodArrayIterator.hasNext()) {
        SyntheticMethodBinding[] methodAccessors = (SyntheticMethodBinding[]) methodArrayIterator.next();
        for (int i = 0, max = methodAccessors.length; i < max; i++) {
            if (methodAccessors[i] != null) {
                if (index + 1 > bindings.length) {
                    System.arraycopy(bindings, 0, (bindings = new SyntheticMethodBinding[index + 1]), 0, index);
                }
                bindings[index++] = methodAccessors[i];
            }
        }
    }
    // sort them in according to their own indexes
    int length;
    SyntheticMethodBinding[] sortedBindings = new SyntheticMethodBinding[length = bindings.length];
    for (int i = 0; i < length; i++) {
        SyntheticMethodBinding binding = bindings[i];
        sortedBindings[binding.index] = binding;
    }
    return sortedBindings;
}