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 it is created.
17 * Some are initialized only when needed.
19 * Accessors have been provided for some public fields so all TypeBindings have the same API...
20 * but access public fields directly whenever possible.
21 * Non-public fields have accessors which should be used everywhere you expect the field to be initialized.
23 * null is NOT a valid value for a non-public field... it just means the field is not initialized.
25 abstract public class TypeBinding extends Binding implements BaseTypes, TagBits, TypeConstants, TypeIds {
27 public int tagBits = 0; // See values in the interface TagBits below
29 * Answer the receiver's binding type from Binding.BindingID.
32 public final int bindingType() {
35 /* Answer true if the receiver can be instantiated
38 public boolean canBeInstantiated() {
41 /* Answer the receiver's constant pool name.
43 * NOTE: This method should only be used during/after code gen.
46 public abstract char[] constantPoolName(); /* java/lang/Object */
48 return new String(readableName());
51 * Answer the receiver's dimensions - 0 for non-array types
53 public int dimensions(){
56 public abstract PackageBinding getPackage();
57 /* Answer true if the receiver is an array
60 public final boolean isArrayType() {
61 return (tagBits & IsArrayType) != 0;
63 /* Answer true if the receiver is a base type
66 public final boolean isBaseType() {
67 return (tagBits & IsBaseType) != 0;
69 public boolean isClass() {
72 /* Answer true if the receiver type can be assigned to the argument type (right)
75 public abstract boolean isCompatibleWith(TypeBinding right);
76 /* Answer true if the receiver's hierarchy has problems (always false for arrays & base types)
79 public final boolean isHierarchyInconsistent() {
80 return (tagBits & HierarchyHasProblems) != 0;
82 public boolean isInterface() {
85 public final boolean isNumericType() {
100 public TypeBinding leafComponentType(){
105 * Answer the qualified name of the receiver's package separated by periods
106 * or an empty string if its the default package.
108 * For example, {java.util.Hashtable}.
111 public char[] qualifiedPackageName() {
112 PackageBinding packageBinding = getPackage();
113 return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR
114 ? CharOperation.NO_CHAR
115 : packageBinding.readableName();
118 * Answer the source name for the type.
119 * In the case of member types, as the qualified name from its top level type.
120 * For example, for a member type N defined inside M & A: "A.M.N".
123 public abstract char[] qualifiedSourceName();
124 /* Answer the receiver's signature.
126 * Arrays & base types do not distinguish between signature() & constantPoolName().
128 * NOTE: This method should only be used during/after code gen.
131 public char[] signature() {
132 return constantPoolName();
134 public abstract char[] sourceName();