1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 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 org.eclipse.jdt.internal.compiler.lookup;
13 public final class BaseTypeBinding extends TypeBinding {
15 public char[] simpleName;
16 private char[] constantPoolName;
18 BaseTypeBinding(int id, char[] name, char[] constantPoolName) {
20 this.tagBits |= IsBaseType;
22 this.simpleName = name;
23 this.constantPoolName = constantPoolName;
26 /* Answer the receiver's constant pool name.
28 public char[] constantPoolName() {
30 return constantPoolName;
33 public PackageBinding getPackage() {
38 /* Answer true if the receiver type can be assigned to the argument type (right)
40 public final boolean isCompatibleWith(TypeBinding right) {
44 if (!right.isBaseType())
45 return this == NullBinding;
95 return (id == T_byte);
100 public static final boolean isNarrowing(int left, int right) {
102 //can "left" store a "right" using some narrowing conversion
103 //(is left smaller than right)
106 return right == T_boolean;
112 if (right == T_short)
123 if (right == T_float)
126 if (right == T_double)
133 public static final boolean isWidening(int left, int right) {
135 //can "left" store a "right" using some widening conversion
136 //(is left "bigger" than right)
139 return right == T_boolean;
141 return right == T_char;
143 if (right == T_double)
146 if (right == T_float)
157 if (right == T_short)
167 public char[] qualifiedSourceName() {
171 public char[] readableName() {
175 public char[] shortReadableName() {
179 public char[] sourceName() {
183 public String toString() {
184 return new String(constantPoolName) + " (id=" + id + ")"; //$NON-NLS-1$ //$NON-NLS-2$