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.ast;
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
19 public abstract class TypeReference extends Expression {
20 public TypeBinding binding;
21 public TypeReference() {
24 // allows us to trap completion & selection nodes
26 public void aboutToResolve(Scope scope) {}
28 * Answer a base type reference (can be an array of base type).
30 public static final TypeReference baseTypeReference(int baseType, int dim) {
35 return new SingleTypeReference(VoidBinding.simpleName, 0);
37 return new SingleTypeReference(BooleanBinding.simpleName, 0);
39 return new SingleTypeReference(CharBinding.simpleName, 0);
41 return new SingleTypeReference(FloatBinding.simpleName, 0);
43 return new SingleTypeReference(DoubleBinding.simpleName, 0);
45 return new SingleTypeReference(ByteBinding.simpleName, 0);
47 return new SingleTypeReference(ShortBinding.simpleName, 0);
49 return new SingleTypeReference(IntBinding.simpleName, 0);
51 return new SingleTypeReference(LongBinding.simpleName, 0);
56 return new ArrayTypeReference(VoidBinding.simpleName, dim, 0);
58 return new ArrayTypeReference(BooleanBinding.simpleName, dim, 0);
60 return new ArrayTypeReference(CharBinding.simpleName, dim, 0);
62 return new ArrayTypeReference(FloatBinding.simpleName, dim, 0);
64 return new ArrayTypeReference(DoubleBinding.simpleName, dim, 0);
66 return new ArrayTypeReference(ByteBinding.simpleName, dim, 0);
68 return new ArrayTypeReference(ShortBinding.simpleName, dim, 0);
70 return new ArrayTypeReference(IntBinding.simpleName, dim, 0);
72 return new ArrayTypeReference(LongBinding.simpleName, dim, 0);
75 public abstract TypeReference copyDims(int dim);
76 public int dimensions() {
79 public abstract TypeBinding getTypeBinding(Scope scope);
83 public abstract char [][] getTypeName() ;
84 public boolean isTypeReference() {
87 public TypeBinding resolveType(BlockScope scope) {
88 // handle the error here
89 constant = NotAConstant;
90 if (binding != null) { // is a shared type reference which was already resolved
91 if (!binding.isValidBinding())
92 return null; // already reported error
94 binding = getTypeBinding(scope);
95 if (!binding.isValidBinding()) {
96 scope.problemReporter().invalidType(this, binding);
99 if (isTypeUseDeprecated(binding, scope))
100 scope.problemReporter().deprecatedType(binding, this);
104 public abstract void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope);