1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.lookup;
13 import net.sourceforge.phpdt.core.compiler.CharOperation;
16 * Not all fields defined by this type (& its subclasses) are initialized when
17 * it is created. Some are initialized only when needed.
19 * Accessors have been provided for some public fields so all TypeBindings have
20 * the same API... but access public fields directly whenever possible.
21 * Non-public fields have accessors which should be used everywhere you expect
22 * the field to be initialized.
24 * null is NOT a valid value for a non-public field... it just means the field
27 abstract public class TypeBinding extends Binding implements BaseTypes,
28 TagBits, TypeConstants, TypeIds {
31 public int tagBits = 0; // See values in the interface TagBits below
33 * API Answer the receiver's binding type from Binding.BindingID.
36 public final int bindingType() {
41 * Answer true if the receiver can be instantiated
44 public boolean canBeInstantiated() {
49 * Answer the receiver's constant pool name.
51 * NOTE: This method should only be used during/after code gen.
54 public abstract char[] constantPoolName(); /* java/lang/Object */
57 return new String(readableName());
61 * Answer the receiver's dimensions - 0 for non-array types
63 public int dimensions() {
67 public abstract PackageBinding getPackage();
70 * Answer true if the receiver is an array
73 public final boolean isArrayType() {
74 return (tagBits & IsArrayType) != 0;
78 * Answer true if the receiver is a base type
81 public final boolean isBaseType() {
82 return (tagBits & IsBaseType) != 0;
85 public boolean isClass() {
90 * Answer true if the receiver type can be assigned to the argument type
94 public abstract boolean isCompatibleWith(TypeBinding right);
97 * Answer true if the receiver's hierarchy has problems (always false for
98 * arrays & base types)
101 public final boolean isHierarchyInconsistent() {
102 return (tagBits & HierarchyHasProblems) != 0;
105 public boolean isInterface() {
109 public final boolean isNumericType() {
124 public TypeBinding leafComponentType() {
129 * Answer the qualified name of the receiver's package separated by periods
130 * or an empty string if its the default package.
132 * For example, {java.util.Hashtable}.
135 public char[] qualifiedPackageName() {
136 PackageBinding packageBinding = getPackage();
137 return packageBinding == null
138 || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? CharOperation.NO_CHAR
139 : packageBinding.readableName();
143 * Answer the source name for the type. In the case of member types, as the
144 * qualified name from its top level type. For example, for a member type N
145 * defined inside M & A: "A.M.N".
148 public abstract char[] qualifiedSourceName();
151 * Answer the receiver's signature.
153 * Arrays & base types do not distinguish between signature() &
154 * constantPoolName().
156 * NOTE: This method should only be used during/after code gen.
159 public char[] signature() {
160 return constantPoolName();
163 public abstract char[] sourceName();