1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 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 net.sourceforge.phpdt.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.ASTVisitor;
14 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
15 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
16 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
18 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
19 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
21 public abstract class TypeReference extends Expression {
23 public TypeReference() {
27 public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
31 // allows us to trap completion & selection nodes
32 public void aboutToResolve(Scope scope) {}
34 * Answer a base type reference (can be an array of base type).
36 //public static final TypeReference baseTypeReference(int baseType, int dim) {
39 // switch (baseType) {
41 // return new SingleTypeReference(VoidBinding.simpleName, 0);
43 // return new SingleTypeReference(BooleanBinding.simpleName, 0);
45 // return new SingleTypeReference(CharBinding.simpleName, 0);
47 // return new SingleTypeReference(FloatBinding.simpleName, 0);
49 // return new SingleTypeReference(DoubleBinding.simpleName, 0);
51 // return new SingleTypeReference(ByteBinding.simpleName, 0);
53 // return new SingleTypeReference(ShortBinding.simpleName, 0);
55 // return new SingleTypeReference(IntBinding.simpleName, 0);
57 // return new SingleTypeReference(LongBinding.simpleName, 0);
60 // switch (baseType) {
62 // return new ArrayTypeReference(VoidBinding.simpleName, dim, 0);
64 // return new ArrayTypeReference(BooleanBinding.simpleName, dim, 0);
66 // return new ArrayTypeReference(CharBinding.simpleName, dim, 0);
68 // return new ArrayTypeReference(FloatBinding.simpleName, dim, 0);
70 // return new ArrayTypeReference(DoubleBinding.simpleName, dim, 0);
72 // return new ArrayTypeReference(ByteBinding.simpleName, dim, 0);
74 // return new ArrayTypeReference(ShortBinding.simpleName, dim, 0);
76 // return new ArrayTypeReference(IntBinding.simpleName, dim, 0);
78 // return new ArrayTypeReference(LongBinding.simpleName, dim, 0);
81 public abstract TypeReference copyDims(int dim);
82 public int dimensions() {
85 public abstract TypeBinding getTypeBinding(Scope scope);
89 public abstract char [][] getTypeName() ;
90 public boolean isTypeReference() {
93 public TypeBinding resolveType(BlockScope scope) {
94 // handle the error here
95 constant = NotAConstant;
96 if (this.resolvedType != null) { // is a shared type reference which was already resolved
97 if (!this.resolvedType.isValidBinding())
98 return null; // already reported error
100 this.resolvedType = getTypeBinding(scope);
101 if (!this.resolvedType.isValidBinding()) {
102 scope.problemReporter().invalidType(this, this.resolvedType);
105 if (isTypeUseDeprecated(this.resolvedType, scope))
106 scope.problemReporter().deprecatedType(this.resolvedType, this);
108 return this.resolvedType;
110 public abstract void traverse(ASTVisitor visitor, ClassScope classScope);