|
1 |
| package edu.rice.cs.dynamicjava.symbol.type; |
|
2 |
| |
|
3 |
| import edu.rice.cs.dynamicjava.symbol.*; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| @SuppressWarnings("unused") |
|
14 |
| public abstract class TypeDepthFirstVisitor<RetType> extends TypeVisitorLambda<RetType> { |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
0
| public RetType defaultCase(Type that) {
|
|
21 |
0
| throw new IllegalArgumentException("Visitor " + getClass().getName() + " does not support visiting values of type " + that.getClass().getName());
|
|
22 |
| } |
|
23 |
| |
|
24 |
| |
|
25 |
0
| public RetType forTypeOnly(Type that) {
|
|
26 |
0
| return defaultCase(that);
|
|
27 |
| } |
|
28 |
| |
|
29 |
0
| public RetType forValidTypeOnly(ValidType that) {
|
|
30 |
0
| return forTypeOnly(that);
|
|
31 |
| } |
|
32 |
| |
|
33 |
0
| public RetType forPrimitiveTypeOnly(PrimitiveType that) {
|
|
34 |
0
| return forValidTypeOnly(that);
|
|
35 |
| } |
|
36 |
| |
|
37 |
0
| public RetType forBooleanTypeOnly(BooleanType that) {
|
|
38 |
0
| return forPrimitiveTypeOnly(that);
|
|
39 |
| } |
|
40 |
| |
|
41 |
0
| public RetType forNumericTypeOnly(NumericType that) {
|
|
42 |
0
| return forPrimitiveTypeOnly(that);
|
|
43 |
| } |
|
44 |
| |
|
45 |
0
| public RetType forIntegralTypeOnly(IntegralType that) {
|
|
46 |
0
| return forNumericTypeOnly(that);
|
|
47 |
| } |
|
48 |
| |
|
49 |
0
| public RetType forCharTypeOnly(CharType that) {
|
|
50 |
0
| return forIntegralTypeOnly(that);
|
|
51 |
| } |
|
52 |
| |
|
53 |
0
| public RetType forIntegerTypeOnly(IntegerType that) {
|
|
54 |
0
| return forIntegralTypeOnly(that);
|
|
55 |
| } |
|
56 |
| |
|
57 |
0
| public RetType forByteTypeOnly(ByteType that) {
|
|
58 |
0
| return forIntegerTypeOnly(that);
|
|
59 |
| } |
|
60 |
| |
|
61 |
0
| public RetType forShortTypeOnly(ShortType that) {
|
|
62 |
0
| return forIntegerTypeOnly(that);
|
|
63 |
| } |
|
64 |
| |
|
65 |
0
| public RetType forIntTypeOnly(IntType that) {
|
|
66 |
0
| return forIntegerTypeOnly(that);
|
|
67 |
| } |
|
68 |
| |
|
69 |
0
| public RetType forLongTypeOnly(LongType that) {
|
|
70 |
0
| return forIntegerTypeOnly(that);
|
|
71 |
| } |
|
72 |
| |
|
73 |
0
| public RetType forFloatingPointTypeOnly(FloatingPointType that) {
|
|
74 |
0
| return forNumericTypeOnly(that);
|
|
75 |
| } |
|
76 |
| |
|
77 |
0
| public RetType forFloatTypeOnly(FloatType that) {
|
|
78 |
0
| return forFloatingPointTypeOnly(that);
|
|
79 |
| } |
|
80 |
| |
|
81 |
0
| public RetType forDoubleTypeOnly(DoubleType that) {
|
|
82 |
0
| return forFloatingPointTypeOnly(that);
|
|
83 |
| } |
|
84 |
| |
|
85 |
0
| public RetType forReferenceTypeOnly(ReferenceType that) {
|
|
86 |
0
| return forValidTypeOnly(that);
|
|
87 |
| } |
|
88 |
| |
|
89 |
0
| public RetType forNullTypeOnly(NullType that) {
|
|
90 |
0
| return forReferenceTypeOnly(that);
|
|
91 |
| } |
|
92 |
| |
|
93 |
0
| public RetType forArrayTypeOnly(ArrayType that, RetType ofType_result) {
|
|
94 |
0
| return forReferenceTypeOnly(that);
|
|
95 |
| } |
|
96 |
| |
|
97 |
0
| public RetType forSimpleArrayTypeOnly(SimpleArrayType that, RetType ofType_result) {
|
|
98 |
0
| return forArrayTypeOnly(that, ofType_result);
|
|
99 |
| } |
|
100 |
| |
|
101 |
0
| public RetType forVarargArrayTypeOnly(VarargArrayType that, RetType ofType_result) {
|
|
102 |
0
| return forArrayTypeOnly(that, ofType_result);
|
|
103 |
| } |
|
104 |
| |
|
105 |
0
| public RetType forClassTypeOnly(ClassType that) {
|
|
106 |
0
| return forReferenceTypeOnly(that);
|
|
107 |
| } |
|
108 |
| |
|
109 |
0
| public RetType forSimpleClassTypeOnly(SimpleClassType that) {
|
|
110 |
0
| return forClassTypeOnly(that);
|
|
111 |
| } |
|
112 |
| |
|
113 |
0
| public RetType forRawClassTypeOnly(RawClassType that) {
|
|
114 |
0
| return forClassTypeOnly(that);
|
|
115 |
| } |
|
116 |
| |
|
117 |
0
| public RetType forParameterizedClassTypeOnly(ParameterizedClassType that, Iterable<RetType> typeArguments_result) {
|
|
118 |
0
| return forClassTypeOnly(that);
|
|
119 |
| } |
|
120 |
| |
|
121 |
0
| public RetType forBoundTypeOnly(BoundType that, Iterable<RetType> ofTypes_result) {
|
|
122 |
0
| return forValidTypeOnly(that);
|
|
123 |
| } |
|
124 |
| |
|
125 |
0
| public RetType forIntersectionTypeOnly(IntersectionType that, Iterable<RetType> ofTypes_result) {
|
|
126 |
0
| return forBoundTypeOnly(that, ofTypes_result);
|
|
127 |
| } |
|
128 |
| |
|
129 |
0
| public RetType forUnionTypeOnly(UnionType that, Iterable<RetType> ofTypes_result) {
|
|
130 |
0
| return forBoundTypeOnly(that, ofTypes_result);
|
|
131 |
| } |
|
132 |
| |
|
133 |
0
| public RetType forVariableTypeOnly(VariableType that) {
|
|
134 |
0
| return forValidTypeOnly(that);
|
|
135 |
| } |
|
136 |
| |
|
137 |
0
| public RetType forTopTypeOnly(TopType that) {
|
|
138 |
0
| return forValidTypeOnly(that);
|
|
139 |
| } |
|
140 |
| |
|
141 |
0
| public RetType forBottomTypeOnly(BottomType that) {
|
|
142 |
0
| return forValidTypeOnly(that);
|
|
143 |
| } |
|
144 |
| |
|
145 |
0
| public RetType forVoidTypeOnly(VoidType that) {
|
|
146 |
0
| return forTypeOnly(that);
|
|
147 |
| } |
|
148 |
| |
|
149 |
0
| public RetType forWildcardOnly(Wildcard that) {
|
|
150 |
0
| return forTypeOnly(that);
|
|
151 |
| } |
|
152 |
| |
|
153 |
| |
|
154 |
| |
|
155 |
0
| public RetType forBooleanType(BooleanType that) {
|
|
156 |
0
| return forBooleanTypeOnly(that);
|
|
157 |
| } |
|
158 |
| |
|
159 |
0
| public RetType forCharType(CharType that) {
|
|
160 |
0
| return forCharTypeOnly(that);
|
|
161 |
| } |
|
162 |
| |
|
163 |
0
| public RetType forByteType(ByteType that) {
|
|
164 |
0
| return forByteTypeOnly(that);
|
|
165 |
| } |
|
166 |
| |
|
167 |
0
| public RetType forShortType(ShortType that) {
|
|
168 |
0
| return forShortTypeOnly(that);
|
|
169 |
| } |
|
170 |
| |
|
171 |
0
| public RetType forIntType(IntType that) {
|
|
172 |
0
| return forIntTypeOnly(that);
|
|
173 |
| } |
|
174 |
| |
|
175 |
0
| public RetType forLongType(LongType that) {
|
|
176 |
0
| return forLongTypeOnly(that);
|
|
177 |
| } |
|
178 |
| |
|
179 |
0
| public RetType forFloatType(FloatType that) {
|
|
180 |
0
| return forFloatTypeOnly(that);
|
|
181 |
| } |
|
182 |
| |
|
183 |
0
| public RetType forDoubleType(DoubleType that) {
|
|
184 |
0
| return forDoubleTypeOnly(that);
|
|
185 |
| } |
|
186 |
| |
|
187 |
0
| public RetType forNullType(NullType that) {
|
|
188 |
0
| return forNullTypeOnly(that);
|
|
189 |
| } |
|
190 |
| |
|
191 |
0
| public RetType forSimpleArrayType(SimpleArrayType that) {
|
|
192 |
0
| RetType ofType_result = recur(that.ofType());
|
|
193 |
0
| return forSimpleArrayTypeOnly(that, ofType_result);
|
|
194 |
| } |
|
195 |
| |
|
196 |
0
| public RetType forVarargArrayType(VarargArrayType that) {
|
|
197 |
0
| RetType ofType_result = recur(that.ofType());
|
|
198 |
0
| return forVarargArrayTypeOnly(that, ofType_result);
|
|
199 |
| } |
|
200 |
| |
|
201 |
0
| public RetType forSimpleClassType(SimpleClassType that) {
|
|
202 |
0
| return forSimpleClassTypeOnly(that);
|
|
203 |
| } |
|
204 |
| |
|
205 |
0
| public RetType forRawClassType(RawClassType that) {
|
|
206 |
0
| return forRawClassTypeOnly(that);
|
|
207 |
| } |
|
208 |
| |
|
209 |
0
| public RetType forParameterizedClassType(ParameterizedClassType that) {
|
|
210 |
0
| Iterable<RetType> typeArguments_result = recurOnIterableOfWildcardExtendsType(that.typeArguments());
|
|
211 |
0
| return forParameterizedClassTypeOnly(that, typeArguments_result);
|
|
212 |
| } |
|
213 |
| |
|
214 |
0
| public RetType forIntersectionType(IntersectionType that) {
|
|
215 |
0
| Iterable<RetType> ofTypes_result = recurOnIterableOfWildcardExtendsType(that.ofTypes());
|
|
216 |
0
| return forIntersectionTypeOnly(that, ofTypes_result);
|
|
217 |
| } |
|
218 |
| |
|
219 |
0
| public RetType forUnionType(UnionType that) {
|
|
220 |
0
| Iterable<RetType> ofTypes_result = recurOnIterableOfWildcardExtendsType(that.ofTypes());
|
|
221 |
0
| return forUnionTypeOnly(that, ofTypes_result);
|
|
222 |
| } |
|
223 |
| |
|
224 |
0
| public RetType forVariableType(VariableType that) {
|
|
225 |
0
| return forVariableTypeOnly(that);
|
|
226 |
| } |
|
227 |
| |
|
228 |
0
| public RetType forTopType(TopType that) {
|
|
229 |
0
| return forTopTypeOnly(that);
|
|
230 |
| } |
|
231 |
| |
|
232 |
0
| public RetType forBottomType(BottomType that) {
|
|
233 |
0
| return forBottomTypeOnly(that);
|
|
234 |
| } |
|
235 |
| |
|
236 |
0
| public RetType forVoidType(VoidType that) {
|
|
237 |
0
| return forVoidTypeOnly(that);
|
|
238 |
| } |
|
239 |
| |
|
240 |
0
| public RetType forWildcard(Wildcard that) {
|
|
241 |
0
| return forWildcardOnly(that);
|
|
242 |
| } |
|
243 |
| |
|
244 |
| |
|
245 |
0
| public RetType recur(Type that) {
|
|
246 |
0
| return that.apply(this);
|
|
247 |
| } |
|
248 |
| |
|
249 |
0
| public Iterable<RetType> recurOnIterableOfWildcardExtendsType(Iterable<? extends Type> that) {
|
|
250 |
0
| java.util.ArrayList<RetType> accum = new java.util.ArrayList<RetType>();
|
|
251 |
0
| for (Type elt : that) {
|
|
252 |
0
| accum.add(recur(elt));
|
|
253 |
| } |
|
254 |
0
| return accum;
|
|
255 |
| } |
|
256 |
| } |