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.phpeclipse.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 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
20 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
22 public abstract class TypeReference extends Expression {
24 public TypeReference() {
28 public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
32 // allows us to trap completion & selection nodes
33 public void aboutToResolve(Scope scope) {}
35 * Answer a base type reference (can be an array of base type).
37 //public static final TypeReference baseTypeReference(int baseType, int dim) {
40 // switch (baseType) {
42 // return new SingleTypeReference(VoidBinding.simpleName, 0);
44 // return new SingleTypeReference(BooleanBinding.simpleName, 0);
46 // return new SingleTypeReference(CharBinding.simpleName, 0);
48 // return new SingleTypeReference(FloatBinding.simpleName, 0);
50 // return new SingleTypeReference(DoubleBinding.simpleName, 0);
52 // return new SingleTypeReference(ByteBinding.simpleName, 0);
54 // return new SingleTypeReference(ShortBinding.simpleName, 0);
56 // return new SingleTypeReference(IntBinding.simpleName, 0);
58 // return new SingleTypeReference(LongBinding.simpleName, 0);
61 // switch (baseType) {
63 // return new ArrayTypeReference(VoidBinding.simpleName, dim, 0);
65 // return new ArrayTypeReference(BooleanBinding.simpleName, dim, 0);
67 // return new ArrayTypeReference(CharBinding.simpleName, dim, 0);
69 // return new ArrayTypeReference(FloatBinding.simpleName, dim, 0);
71 // return new ArrayTypeReference(DoubleBinding.simpleName, dim, 0);
73 // return new ArrayTypeReference(ByteBinding.simpleName, dim, 0);
75 // return new ArrayTypeReference(ShortBinding.simpleName, dim, 0);
77 // return new ArrayTypeReference(IntBinding.simpleName, dim, 0);
79 // return new ArrayTypeReference(LongBinding.simpleName, dim, 0);
82 public abstract TypeReference copyDims(int dim);
83 public int dimensions() {
86 public abstract TypeBinding getTypeBinding(Scope scope);
90 public abstract char [][] getTypeName() ;
91 public boolean isTypeReference() {
94 public TypeBinding resolveType(BlockScope scope) {
95 // handle the error here
96 constant = NotAConstant;
97 if (this.resolvedType != null) { // is a shared type reference which was already resolved
98 if (!this.resolvedType.isValidBinding())
99 return null; // already reported error
101 this.resolvedType = getTypeBinding(scope);
102 if (!this.resolvedType.isValidBinding()) {
103 scope.problemReporter().invalidType(this, this.resolvedType);
106 if (isTypeUseDeprecated(this.resolvedType, scope))
107 scope.problemReporter().deprecatedType(this.resolvedType, this);
109 return this.resolvedType;
111 public abstract void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope);