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.*;
16 public abstract class TypeReference extends Expression {
17 public TypeBinding binding;
18 public TypeReference() {
21 // allows us to trap completion & selection nodes
23 public void aboutToResolve(Scope scope) {}
25 * Answer a base type reference (can be an array of base type).
27 public static final TypeReference baseTypeReference(int baseType, int dim) {
32 return new SingleTypeReference(VoidBinding.simpleName, 0);
34 return new SingleTypeReference(BooleanBinding.simpleName, 0);
36 return new SingleTypeReference(CharBinding.simpleName, 0);
38 return new SingleTypeReference(FloatBinding.simpleName, 0);
40 return new SingleTypeReference(DoubleBinding.simpleName, 0);
42 return new SingleTypeReference(ByteBinding.simpleName, 0);
44 return new SingleTypeReference(ShortBinding.simpleName, 0);
46 return new SingleTypeReference(IntBinding.simpleName, 0);
48 return new SingleTypeReference(LongBinding.simpleName, 0);
53 return new ArrayTypeReference(VoidBinding.simpleName, dim, 0);
55 return new ArrayTypeReference(BooleanBinding.simpleName, dim, 0);
57 return new ArrayTypeReference(CharBinding.simpleName, dim, 0);
59 return new ArrayTypeReference(FloatBinding.simpleName, dim, 0);
61 return new ArrayTypeReference(DoubleBinding.simpleName, dim, 0);
63 return new ArrayTypeReference(ByteBinding.simpleName, dim, 0);
65 return new ArrayTypeReference(ShortBinding.simpleName, dim, 0);
67 return new ArrayTypeReference(IntBinding.simpleName, dim, 0);
69 return new ArrayTypeReference(LongBinding.simpleName, dim, 0);
72 public abstract TypeReference copyDims(int dim);
73 public int dimensions() {
76 public abstract TypeBinding getTypeBinding(Scope scope);
80 public abstract char [][] getTypeName() ;
81 public boolean isTypeReference() {
84 public TypeBinding resolveType(BlockScope scope) {
85 // handle the error here
86 constant = NotAConstant;
87 if (binding != null) { // is a shared type reference which was already resolved
88 if (!binding.isValidBinding())
89 return null; // already reported error
91 binding = getTypeBinding(scope);
92 if (!binding.isValidBinding()) {
93 scope.problemReporter().invalidType(this, binding);
96 if (isTypeUseDeprecated(binding, scope))
97 scope.problemReporter().deprecatedType(binding, this);
101 public abstract void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope);