Example usage for org.eclipse.jdt.internal.compiler.lookup TypeBinding SHORT

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeBinding SHORT

Introduction

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

Prototype

BaseTypeBinding SHORT

To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeBinding SHORT.

Click Source Link

Usage

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

License:Open Source License

public static TypeBinding getBaseType(char[] name) {
    // list should be optimized (with most often used first)
    int length = name.length;
    if (length > 2 && length < 8) {
        switch (name[0]) {
        case 'i':
            if (length == 3 && name[1] == 'n' && name[2] == 't')
                return TypeBinding.INT;
            break;
        case 'v':
            if (length == 4 && name[1] == 'o' && name[2] == 'i' && name[3] == 'd')
                return TypeBinding.VOID;
            break;
        case 'b':
            if (length == 7 && name[1] == 'o' && name[2] == 'o' && name[3] == 'l' && name[4] == 'e'
                    && name[5] == 'a' && name[6] == 'n')
                return TypeBinding.BOOLEAN;
            if (length == 4 && name[1] == 'y' && name[2] == 't' && name[3] == 'e')
                return TypeBinding.BYTE;
            break;
        case 'c':
            if (length == 4 && name[1] == 'h' && name[2] == 'a' && name[3] == 'r')
                return TypeBinding.CHAR;
            break;
        case 'd':
            if (length == 6 && name[1] == 'o' && name[2] == 'u' && name[3] == 'b' && name[4] == 'l'
                    && name[5] == 'e')
                return TypeBinding.DOUBLE;
            break;
        case 'f':
            if (length == 5 && name[1] == 'l' && name[2] == 'o' && name[3] == 'a' && name[4] == 't')
                return TypeBinding.FLOAT;
            break;
        case 'l':
            if (length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g')
                return TypeBinding.LONG;
            break;
        case 's':
            if (length == 5 && name[1] == 'h' && name[2] == 'o' && name[3] == 'r' && name[4] == 't')
                return TypeBinding.SHORT;
        }//w ww. j  a v a  2s . com
    }
    return null;
}

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

License:Open Source License

private MethodBinding getMethodRef(int index) {
    int start = getConstantPoolStartPosition(index);
    assert (u1At(start) == MethodRefTag);
    int class_index = u2At(start + 1);
    int name_index = u2At(start + 3);
    ReferenceBinding class_rb = getClassBinding(class_index);
    // deactivated, see below. ReferenceBinding actualReceiver = class_rb;
    if (class_rb == null)
        return null;

    char[][] nameandtype = getNameAndType(name_index);
    char[] name = nameandtype[0];
    char[] type = nameandtype[1];
    MethodBinding mb = findMethodBinding(class_rb, name, type);

    // Note: donot revert to actual receiver, because the linkage of
    //       copyInheritanceSrc will otherwise be broken!
    if (mb == null && CharOperation.endsWith(name, IOTConstants._OT_TAG)) {
        // This method is faked within the compiler, will be added by the OTRE.
        return new MethodBinding(ClassFileConstants.AccPublic, name, TypeBinding.SHORT, Binding.NO_PARAMETERS,
                Binding.NO_EXCEPTIONS, class_rb);
    }//www .java 2 s.  co  m
    assert (mb != null);
    return mb;

}

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

License:Open Source License

/** can only transfer some flags once we have the method binding */
public boolean evaluate(MethodInfo info, MethodBinding method, LookupEnvironment environment) {
    if (this._methodInfo != info)
        return false;
    // MODIFIERS and ROLECLASS_METHOD_MODIFIERS_NAME and CALLS_BASE_CTOR are already evaluated at the MethodInfo level.
    if (CharOperation.equals(this._name, IOTConstants.CALLIN_FLAGS)) {
        MethodModel.getModel(method).callinFlags = this._value & 0xFF;
        int typeCode = this._value & IOTConstants.CALLIN_RETURN_MASK;
        if (typeCode != 0) {
            TypeBinding returnType;//from  w w w  .  j a va 2  s. c om
            switch (typeCode) {
            case IOTConstants.CALLIN_RETURN_VOID:
                returnType = TypeBinding.VOID;
                break;
            case IOTConstants.CALLIN_RETURN_BOOLEAN:
                returnType = TypeBinding.BOOLEAN;
                break;
            case IOTConstants.CALLIN_RETURN_BYTE:
                returnType = TypeBinding.BYTE;
                break;
            case IOTConstants.CALLIN_RETURN_CHAR:
                returnType = TypeBinding.CHAR;
                break;
            case IOTConstants.CALLIN_RETURN_SHORT:
                returnType = TypeBinding.SHORT;
                break;
            case IOTConstants.CALLIN_RETURN_DOUBLE:
                returnType = TypeBinding.DOUBLE;
                break;
            case IOTConstants.CALLIN_RETURN_FLOAT:
                returnType = TypeBinding.FLOAT;
                break;
            case IOTConstants.CALLIN_RETURN_INT:
                returnType = TypeBinding.INT;
                break;
            case IOTConstants.CALLIN_RETURN_LONG:
                returnType = TypeBinding.LONG;
                break;
            default:
                throw new InternalCompilerError("Unexpected callin return type code " + typeCode); //$NON-NLS-1$
            }
            MethodModel.saveReturnType(method, returnType);
        }
        return true;
    }
    return false; // not handled, keep it.
}