KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > base > ast > ArrayTypeD


1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the compiler and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  */

24
25 package org.aspectj.compiler.base.ast;
26
27 import org.aspectj.compiler.base.*;
28 import org.aspectj.compiler.base.cst.*;
29
30 import java.util.*;
31
32
33 /**
34  * @grammar componentTypeD[]
35  * @child TypeD componentTypeD
36  */

37 public class ArrayTypeD extends TypeD {
38     public String JavaDoc getString() {
39         return componentTypeD.getString()+"[]";
40     }
41
42     public String JavaDoc toShortString() {
43         return componentTypeD.toShortString()+"[]";
44     }
45
46     public void unparse(CodeWriter writer) {
47         writer.write(componentTypeD);
48         writer.write("[]");
49     }
50     
51     public void checkSpec() {
52         if (componentTypeD.getType().isVoid()) {
53             showError("can't have an array of void");
54         } else {
55             super.checkSpec();
56         }
57     }
58
59     //??? The call to getArrayType is synchronized. Should we cache
60
//this?
61
public Type getType() {
62         return componentTypeD.getType().getArrayType();
63     }
64
65     //!!! replace with isEquivalent
66
public boolean equals(Object JavaDoc other) {
67         if (!(other instanceof ArrayTypeD)) return false;
68         return componentTypeD.equals(((ArrayTypeD)other).getComponentTypeD());
69     }
70
71     //BEGIN: Generated from @child and @property
72
protected TypeD componentTypeD;
73     public TypeD getComponentTypeD() { return componentTypeD; }
74     public void setComponentTypeD(TypeD _componentTypeD) {
75         if (_componentTypeD != null) _componentTypeD.setParent(this);
76         componentTypeD = _componentTypeD;
77     }
78
79     public ArrayTypeD(SourceLocation location, TypeD _componentTypeD) {
80         super(location);
81         setComponentTypeD(_componentTypeD);
82     }
83     protected ArrayTypeD(SourceLocation source) {
84         super(source);
85     }
86
87     public ASTObject copyWalk(CopyWalker walker) {
88         ArrayTypeD ret = new ArrayTypeD(getSourceLocation());
89         ret.preCopy(walker, this);
90         if (componentTypeD != null) ret.setComponentTypeD( (TypeD)walker.process(componentTypeD) );
91         return ret;
92     }
93
94     public ASTObject getChildAt(int childIndex) {
95         switch(childIndex) {
96         case 0: return componentTypeD;
97         default: return super.getChildAt(childIndex);
98         }
99     }
100      public String JavaDoc getChildNameAt(int childIndex) {
101         switch(childIndex) {
102         case 0: return "componentTypeD";
103         default: return super.getChildNameAt(childIndex);
104         }
105     }
106      public void setChildAt(int childIndex, ASTObject child) {
107         switch(childIndex) {
108         case 0: setComponentTypeD((TypeD)child); return;
109         default: super.setChildAt(childIndex, child); return;
110         }
111     }
112      public int getChildCount() {
113         return 1;
114     }
115
116     public String JavaDoc getDefaultDisplayName() {
117         return "ArrayTypeD()";
118     }
119
120     //END: Generated from @child and @property
121
}
122
Popular Tags