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,
28 FlowContext flowContext, FlowInfo flowInfo) {
32 // allows us to trap completion & selection nodes
33 public void aboutToResolve(Scope scope) {
37 * Answer a base type reference (can be an array of base type).
39 // public static final TypeReference baseTypeReference(int baseType, int
43 // switch (baseType) {
45 // return new SingleTypeReference(VoidBinding.simpleName, 0);
47 // return new SingleTypeReference(BooleanBinding.simpleName, 0);
49 // return new SingleTypeReference(CharBinding.simpleName, 0);
51 // return new SingleTypeReference(FloatBinding.simpleName, 0);
53 // return new SingleTypeReference(DoubleBinding.simpleName, 0);
55 // return new SingleTypeReference(ByteBinding.simpleName, 0);
57 // return new SingleTypeReference(ShortBinding.simpleName, 0);
59 // return new SingleTypeReference(IntBinding.simpleName, 0);
61 // return new SingleTypeReference(LongBinding.simpleName, 0);
64 // switch (baseType) {
66 // return new ArrayTypeReference(VoidBinding.simpleName, dim, 0);
68 // return new ArrayTypeReference(BooleanBinding.simpleName, dim, 0);
70 // return new ArrayTypeReference(CharBinding.simpleName, dim, 0);
72 // return new ArrayTypeReference(FloatBinding.simpleName, dim, 0);
74 // return new ArrayTypeReference(DoubleBinding.simpleName, dim, 0);
76 // return new ArrayTypeReference(ByteBinding.simpleName, dim, 0);
78 // return new ArrayTypeReference(ShortBinding.simpleName, dim, 0);
80 // return new ArrayTypeReference(IntBinding.simpleName, dim, 0);
82 // return new ArrayTypeReference(LongBinding.simpleName, dim, 0);
85 public abstract TypeReference copyDims(int dim);
87 public int dimensions() {
91 public abstract TypeBinding getTypeBinding(Scope scope);
96 public abstract char[][] getTypeName();
98 public boolean isTypeReference() {
102 public TypeBinding resolveType(BlockScope scope) {
103 // handle the error here
104 constant = NotAConstant;
105 if (this.resolvedType != null) { // is a shared type reference which
106 // was already resolved
107 if (!this.resolvedType.isValidBinding())
108 return null; // already reported error
110 this.resolvedType = getTypeBinding(scope);
111 if (!this.resolvedType.isValidBinding()) {
112 scope.problemReporter().invalidType(this, this.resolvedType);
115 if (isTypeUseDeprecated(this.resolvedType, scope))
116 scope.problemReporter().deprecatedType(this.resolvedType, this);
118 return this.resolvedType;
121 public abstract void traverse(ASTVisitor visitor, ClassScope classScope);