Refactored packagename to net.sourceforge.phpdt.internal.compiler.ast
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / TypeReference.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
12
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;
20
21 public abstract class TypeReference extends Expression {
22
23 public TypeReference() {
24                 super () ;
25                 }
26
27 public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
28         return flowInfo;
29 }
30
31 // allows us to trap completion & selection nodes
32 public void aboutToResolve(Scope scope) {}
33 /*
34  * Answer a base type reference (can be an array of base type).
35  */
36 //public static final TypeReference baseTypeReference(int baseType, int dim) {
37 //      
38 //      if (dim == 0) {
39 //              switch (baseType) {
40 //                      case (T_void) :
41 //                              return new SingleTypeReference(VoidBinding.simpleName, 0);
42 //                      case (T_boolean) :
43 //                              return new SingleTypeReference(BooleanBinding.simpleName, 0);
44 //                      case (T_char) :
45 //                              return new SingleTypeReference(CharBinding.simpleName, 0);
46 //                      case (T_float) :
47 //                              return new SingleTypeReference(FloatBinding.simpleName, 0);
48 //                      case (T_double) :
49 //                              return new SingleTypeReference(DoubleBinding.simpleName, 0);
50 //                      case (T_byte) :
51 //                              return new SingleTypeReference(ByteBinding.simpleName, 0);
52 //                      case (T_short) :
53 //                              return new SingleTypeReference(ShortBinding.simpleName, 0);
54 //                      case (T_int) :
55 //                              return new SingleTypeReference(IntBinding.simpleName, 0);
56 //                      default : //T_long      
57 //                              return new SingleTypeReference(LongBinding.simpleName, 0);
58 //              }
59 //      }
60 //      switch (baseType) {
61 //              case (T_void) :
62 //                      return new ArrayTypeReference(VoidBinding.simpleName, dim, 0);
63 //              case (T_boolean) :
64 //                      return new ArrayTypeReference(BooleanBinding.simpleName, dim, 0);
65 //              case (T_char) :
66 //                      return new ArrayTypeReference(CharBinding.simpleName, dim, 0);
67 //              case (T_float) :
68 //                      return new ArrayTypeReference(FloatBinding.simpleName, dim, 0);
69 //              case (T_double) :
70 //                      return new ArrayTypeReference(DoubleBinding.simpleName, dim, 0);
71 //              case (T_byte) :
72 //                      return new ArrayTypeReference(ByteBinding.simpleName, dim, 0);
73 //              case (T_short) :
74 //                      return new ArrayTypeReference(ShortBinding.simpleName, dim, 0);
75 //              case (T_int) :
76 //                      return new ArrayTypeReference(IntBinding.simpleName, dim, 0);
77 //              default : //T_long      
78 //                      return new ArrayTypeReference(LongBinding.simpleName, dim, 0);
79 //      }
80 //}
81 public abstract TypeReference copyDims(int dim);
82 public int dimensions() {
83         return 0;
84 }
85 public abstract TypeBinding getTypeBinding(Scope scope);
86 /**
87  * @return char[][]
88  */
89 public abstract char [][] getTypeName() ;
90 public boolean isTypeReference() {
91         return true;
92 }
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
99         } else {
100                 this.resolvedType = getTypeBinding(scope);
101                 if (!this.resolvedType.isValidBinding()) {
102                         scope.problemReporter().invalidType(this, this.resolvedType);
103                         return null;
104                 }
105                 if (isTypeUseDeprecated(this.resolvedType, scope))
106                         scope.problemReporter().deprecatedType(this.resolvedType, this);
107         }
108         return this.resolvedType;
109 }
110 public abstract void traverse(ASTVisitor visitor, ClassScope classScope);
111 }