1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.lookup;
14 * Not all fields defined by this type (& its subclasses) are initialized when it is created.
15 * Some are initialized only when needed.
17 * Accessors have been provided for some public fields so all TypeBindings have the same API...
18 * but access public fields directly whenever possible.
19 * Non-public fields have accessors which should be used everywhere you expect the field to be initialized.
21 * null is NOT a valid value for a non-public field... it just means the field is not initialized.
23 abstract public class TypeBinding extends Binding implements BaseTypes, TagBits, TypeConstants, TypeIds {
25 public int tagBits = 0; // See values in the interface TagBits below
27 * Answer the receiver's binding type from Binding.BindingID.
30 public final int bindingType() {
33 /* Answer true if the receiver can be instantiated
36 public boolean canBeInstantiated() {
39 /* Answer the receiver's constant pool name.
41 * NOTE: This method should only be used during/after code gen.
44 public abstract char[] constantPoolName(); /* java/lang/Object */
46 return new String(readableName());
48 public abstract PackageBinding getPackage();
49 /* Answer true if the receiver is an array
52 public final boolean isArrayType() {
53 return (tagBits & IsArrayType) != 0;
55 /* Answer true if the receiver is a base type
58 public final boolean isBaseType() {
59 return (tagBits & IsBaseType) != 0;
61 public boolean isClass() {
64 /* Answer true if the receiver type can be assigned to the argument type (right)
67 abstract boolean isCompatibleWith(TypeBinding right);
68 /* Answer true if the receiver's hierarchy has problems (always false for arrays & base types)
71 public final boolean isHierarchyInconsistent() {
72 return (tagBits & HierarchyHasProblems) != 0;
74 public boolean isInterface() {
77 public final boolean isNumericType() {
92 public TypeBinding leafComponentType(){
97 * Answer the qualified name of the receiver's package separated by periods
98 * or an empty string if its the default package.
100 * For example, {java.util.Hashtable}.
103 public char[] qualifiedPackageName() {
104 return getPackage() == null ? NoChar : getPackage().readableName();
107 * Answer the source name for the type.
108 * In the case of member types, as the qualified name from its top level type.
109 * For example, for a member type N defined inside M & A: "A.M.N".
112 public abstract char[] qualifiedSourceName();
113 /* Answer the receiver's signature.
115 * Arrays & base types do not distinguish between signature() & constantPoolName().
117 * NOTE: This method should only be used during/after code gen.
120 public char[] signature() {
121 return constantPoolName();
123 public abstract char[] sourceName();