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;
13 public final class BaseTypeBinding extends TypeBinding {
14 public char[] simpleName;
15 private char [] constantPoolName;
16 BaseTypeBinding(int id, char[] name, char[] constantPoolName) {
17 this.tagBits |= IsBaseType;
19 this.simpleName = name;
20 this.constantPoolName = constantPoolName;
22 /* Answer the receiver's constant pool name.
25 public char[] constantPoolName() {
26 return constantPoolName;
28 public PackageBinding getPackage() {
31 /* Answer true if the receiver type can be assigned to the argument type (right)
34 final boolean isCompatibleWith(TypeBinding right) {
37 if (!right.isBaseType())
38 return this == NullBinding;
88 return (id == T_byte);
92 public static final boolean isNarrowing(int left, int right) {
93 //can "left" store a "right" using some narrowing conversion
94 //(is left smaller than right)
98 return right == T_boolean;
101 if (right == T_byte) return true;
103 if (right == T_short) return true;
104 if (right == T_char) return true;
106 if (right == T_int) return true;
108 if (right == T_long) return true;
110 if (right == T_float) return true;
112 if (right == T_double) return true;
117 public static final boolean isWidening(int left, int right) {
118 //can "left" store a "right" using some widening conversion
119 //(is left "bigger" than right)
123 return right == T_boolean;
125 return right == T_char;
127 if (right == T_double) return true;
129 if (right == T_float) return true;
131 if (right == T_long) return true;
133 if (right == T_int) return true;
134 if (right == T_char) return true;
136 if (right == T_short) return true;
138 if (right == T_byte) return true;
143 public char[] qualifiedSourceName() {
146 public char[] readableName() {
149 public char[] sourceName() {
152 public String toString() {
153 return new String(constantPoolName) + " (id=" + id + ")"; //$NON-NLS-1$ //$NON-NLS-2$