Example usage for org.eclipse.jdt.internal.compiler.lookup TypeIds T_undefined

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeIds T_undefined

Introduction

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

Prototype

int T_undefined

To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeIds T_undefined.

Click Source Link

Usage

From source file:com.google.gwt.dev.jjs.impl.TypeMap.java

License:Apache License

private JNode internalGet(Binding binding, boolean failOnNull) {
    JNode cached = crossRefMap.get(binding);
    if (cached != null) {
        return cached;
    } else if (binding instanceof BaseTypeBinding) {
        BaseTypeBinding baseTypeBinding = (BaseTypeBinding) binding;
        // see org.eclipse.jdt.internal.compiler.lookup.TypeIds constants
        switch (baseTypeBinding.id) {
        case TypeIds.T_JavaLangObject:
            // here for consistency, should already be cached
            return program.getTypeJavaLangObject();
        case TypeIds.T_char:
            return program.getTypePrimitiveChar();
        case TypeIds.T_byte:
            return program.getTypePrimitiveByte();
        case TypeIds.T_short:
            return program.getTypePrimitiveShort();
        case TypeIds.T_boolean:
            return program.getTypePrimitiveBoolean();
        case TypeIds.T_void:
            return program.getTypeVoid();
        case TypeIds.T_long:
            return program.getTypePrimitiveLong();
        case TypeIds.T_double:
            return program.getTypePrimitiveDouble();
        case TypeIds.T_float:
            return program.getTypePrimitiveFloat();
        case TypeIds.T_int:
            return program.getTypePrimitiveInt();
        case TypeIds.T_JavaLangString:
            // here for consistency, should already be cached
            return program.getTypeJavaLangString();
        case TypeIds.T_null:
            return program.getTypeNull();
        case TypeIds.T_undefined:
        default:/*from  w  w w  .j a  v a2  s .  co  m*/
            return null;
        }
    } else if (binding instanceof ArrayBinding) {
        ArrayBinding arrayBinding = (ArrayBinding) binding;
        JType elementType = (JType) get(arrayBinding.elementsType(), failOnNull);
        if (elementType == null) {
            return null;
        }
        return program.getTypeArray(elementType);
    } else if (binding instanceof BinaryTypeBinding) {
        BinaryTypeBinding binaryBinding = (BinaryTypeBinding) binding;
        String name = BuildTypeMap.dotify(binaryBinding.compoundName);

        // There may be many BinaryTypeBindings for a single binary type
        JDeclaredType type = externalTypesByName.get(name);
        if (type != null) {
            put(binding, type);
        }
        return type;
    } else if (binding instanceof MethodBinding) {
        MethodBinding b = (MethodBinding) binding;
        JMethod cachedMethod = (JMethod) crossRefMap.get(b);
        if (cachedMethod == null) {
            JDeclaredType type = (JDeclaredType) get(b.declaringClass, failOnNull);
            if (type == null) {
                return type;
            }
            cachedMethod = getMethodForBinding(type, b);
            if (cachedMethod != null) {
                put(b, cachedMethod);
            }
        } else {
            // Happens sometimes when looking up the type to resolve the binding
            // causes us to also resolve the binding.
        }

        return cachedMethod;
    } else if (binding instanceof FieldBinding) {
        FieldBinding b = (FieldBinding) binding;
        JField cachedField = (JField) crossRefMap.get(b);

        if (cachedField == null) {
            JDeclaredType type = (JDeclaredType) get(b.declaringClass, failOnNull);
            if (type == null) {
                return null;
            }
            cachedField = getFieldForBinding(type, b);
            if (cachedField != null) {
                put(b, cachedField);
            }
        } else {
            // Happens sometimes when looking up the type to resolve the binding
            // causes us to also resolve the binding.
        }

        return cachedField;
    }

    return null;
}