Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReachabilityTest.java @ 16756:5148aab962af
Truffle-DSL: updated tests for the new generation layout.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Aug 2014 15:53:05 +0200 |
parents | |
children | e6d15134ca86 |
comparison
equal
deleted
inserted
replaced
16755:bd28da642eea | 16756:5148aab962af |
---|---|
1 package com.oracle.truffle.api.dsl.test; | |
2 | |
3 import java.math.*; | |
4 | |
5 import com.oracle.truffle.api.dsl.*; | |
6 import com.oracle.truffle.api.dsl.test.TypeSystemTest.*; | |
7 | |
8 public class ReachabilityTest { | |
9 | |
10 static class Reachability1 extends ValueNode { | |
11 @Specialization | |
12 int do2() { | |
13 return 2; | |
14 } | |
15 | |
16 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
17 @Specialization | |
18 int do1() { | |
19 return 2; | |
20 } | |
21 } | |
22 | |
23 @NodeChildren({@NodeChild("a")}) | |
24 static class ReachabilityType1 extends ValueNode { | |
25 @Specialization | |
26 int do2(int a) { | |
27 return a; | |
28 } | |
29 | |
30 @ExpectError("Specialization is not reachable. It is shadowed by do2(int).") | |
31 @Specialization | |
32 int do1(int a) { | |
33 return a; | |
34 } | |
35 } | |
36 | |
37 @NodeChildren({@NodeChild("a")}) | |
38 static class ReachabilityType2 extends ValueNode { | |
39 @Specialization | |
40 BExtendsAbstract do2(BExtendsAbstract a) { | |
41 return a; | |
42 } | |
43 | |
44 @ExpectError("Specialization is not reachable. It is shadowed by do2(BExtendsAbstract).") | |
45 @Specialization | |
46 BExtendsAbstract do1(BExtendsAbstract a) { | |
47 return a; | |
48 } | |
49 } | |
50 | |
51 @NodeChildren({@NodeChild("a")}) | |
52 static class ReachabilityType3 extends ValueNode { | |
53 @Specialization | |
54 Abstract do2(Abstract a) { | |
55 return a; | |
56 } | |
57 | |
58 @ExpectError("Specialization is not reachable. It is shadowed by do2(Abstract).") | |
59 @Specialization | |
60 BExtendsAbstract do1(BExtendsAbstract a) { | |
61 return a; | |
62 } | |
63 } | |
64 | |
65 @NodeChildren({@NodeChild("a")}) | |
66 static class ReachabilityType4 extends ValueNode { | |
67 | |
68 @Specialization | |
69 BExtendsAbstract do2(BExtendsAbstract a) { | |
70 return a; | |
71 } | |
72 | |
73 @Specialization | |
74 Abstract do1(Abstract a) { | |
75 return a; | |
76 } | |
77 | |
78 } | |
79 | |
80 @NodeChildren({@NodeChild("a")}) | |
81 static class ReachabilityType5 extends ValueNode { | |
82 | |
83 @Specialization | |
84 double do2(double a) { | |
85 return a; | |
86 } | |
87 | |
88 @ExpectError("Specialization is not reachable. It is shadowed by do2(double).") | |
89 @Specialization | |
90 int do1(int a) { | |
91 return a; | |
92 } | |
93 | |
94 } | |
95 | |
96 @NodeChildren({@NodeChild("a")}) | |
97 static class ReachabilityType6 extends ValueNode { | |
98 | |
99 @Specialization | |
100 BigInteger do2(BigInteger a) { | |
101 return a; | |
102 } | |
103 | |
104 @ExpectError("Specialization is not reachable. It is shadowed by do2(BigInteger).") | |
105 @Specialization | |
106 int do1(int a) { | |
107 return a; | |
108 } | |
109 | |
110 } | |
111 | |
112 @NodeChildren({@NodeChild("a")}) | |
113 static class ReachabilityType7 extends ValueNode { | |
114 | |
115 @Specialization | |
116 int do2(int a) { | |
117 return a; | |
118 } | |
119 | |
120 @Specialization | |
121 BigInteger do1(BigInteger a) { | |
122 return a; | |
123 } | |
124 | |
125 } | |
126 | |
127 @NodeChildren({@NodeChild("a")}) | |
128 static class ReachabilityType8 extends ValueNode { | |
129 | |
130 @Specialization | |
131 int do2(int a) { | |
132 return a; | |
133 } | |
134 | |
135 @Specialization | |
136 Object do1(Object a) { | |
137 return a; | |
138 } | |
139 | |
140 } | |
141 | |
142 @NodeChildren({@NodeChild("a")}) | |
143 static class ReachabilityType9 extends ValueNode { | |
144 | |
145 @Specialization | |
146 Object do2(Object a) { | |
147 return a; | |
148 } | |
149 | |
150 @ExpectError("Specialization is not reachable. It is shadowed by do2(Object).") | |
151 @Specialization | |
152 int do1(int a) { | |
153 return a; | |
154 } | |
155 } | |
156 | |
157 static class ReachabilityGuard1 extends ValueNode { | |
158 | |
159 boolean foo() { | |
160 return false; | |
161 } | |
162 | |
163 @Specialization(guards = "foo") | |
164 int do2() { | |
165 return 1; | |
166 } | |
167 | |
168 @Specialization | |
169 int do1() { | |
170 return 2; | |
171 } | |
172 | |
173 } | |
174 | |
175 static class ReachabilityGuard2 extends ValueNode { | |
176 | |
177 boolean foo() { | |
178 return false; | |
179 } | |
180 | |
181 @Specialization | |
182 int do2() { | |
183 return 2; | |
184 } | |
185 | |
186 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
187 @Specialization(guards = "foo") | |
188 int do1() { | |
189 return 1; | |
190 } | |
191 | |
192 } | |
193 | |
194 static class ReachabilityGuard3 extends ValueNode { | |
195 | |
196 boolean foo() { | |
197 return false; | |
198 } | |
199 | |
200 @Specialization(guards = "foo") | |
201 int do2() { | |
202 return 1; | |
203 } | |
204 | |
205 @Specialization | |
206 int do1() { | |
207 return 2; | |
208 } | |
209 | |
210 } | |
211 | |
212 static class ReachabilityGuard4 extends ValueNode { | |
213 | |
214 boolean foo() { | |
215 return false; | |
216 } | |
217 | |
218 @Specialization(guards = "foo") | |
219 int do2() { | |
220 return 1; | |
221 } | |
222 | |
223 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
224 @Specialization(guards = "foo") | |
225 int do1() { | |
226 return 2; | |
227 } | |
228 | |
229 } | |
230 | |
231 @NodeAssumptions({"a1"}) | |
232 static class ReachabilityAssumption1 extends ValueNode { | |
233 | |
234 @Specialization(assumptions = "a1") | |
235 int do2() { | |
236 return 1; | |
237 } | |
238 | |
239 @Specialization | |
240 int do1() { | |
241 return 2; | |
242 } | |
243 | |
244 } | |
245 | |
246 @NodeAssumptions({"a1"}) | |
247 static class ReachabilityAssumption2 extends ValueNode { | |
248 | |
249 @Specialization(assumptions = "a1") | |
250 int do2() { | |
251 return 1; | |
252 } | |
253 | |
254 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
255 @Specialization(assumptions = "a1") | |
256 int do1() { | |
257 return 2; | |
258 } | |
259 | |
260 } | |
261 | |
262 @NodeAssumptions({"a1", "a2"}) | |
263 static class ReachabilityAssumption3 extends ValueNode { | |
264 | |
265 @Specialization(assumptions = {"a1", "a2"}) | |
266 int do2() { | |
267 return 1; | |
268 } | |
269 | |
270 @Specialization(assumptions = "a1") | |
271 int do1() { | |
272 return 2; | |
273 } | |
274 | |
275 } | |
276 | |
277 @NodeAssumptions({"a1", "a2"}) | |
278 static class ReachabilityAssumption4 extends ValueNode { | |
279 | |
280 @Specialization(assumptions = "a1") | |
281 int do2() { | |
282 return 1; | |
283 } | |
284 | |
285 @Specialization(assumptions = "a2") | |
286 int do1() { | |
287 return 2; | |
288 } | |
289 | |
290 } | |
291 | |
292 @NodeAssumptions({"a1", "a2"}) | |
293 static class ReachabilityAssumption5 extends ValueNode { | |
294 | |
295 @Specialization | |
296 int do2() { | |
297 return 1; | |
298 } | |
299 | |
300 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
301 @Specialization(assumptions = "a2") | |
302 int do1() { | |
303 return 2; | |
304 } | |
305 | |
306 } | |
307 | |
308 @NodeAssumptions({"a1", "a2"}) | |
309 static class ReachabilityAssumption6 extends ValueNode { | |
310 | |
311 @Specialization(assumptions = {"a1"}) | |
312 int do2() { | |
313 return 1; | |
314 } | |
315 | |
316 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
317 @Specialization(assumptions = {"a1", "a2"}) | |
318 int do1() { | |
319 return 2; | |
320 } | |
321 | |
322 } | |
323 | |
324 static class ReachabilityThrowable1 extends ValueNode { | |
325 | |
326 @Specialization(rewriteOn = RuntimeException.class) | |
327 int do2() throws RuntimeException { | |
328 return 1; | |
329 } | |
330 | |
331 @Specialization | |
332 int do1() { | |
333 return 2; | |
334 } | |
335 | |
336 } | |
337 | |
338 static class ReachabilityThrowable2 extends ValueNode { | |
339 | |
340 @Specialization | |
341 int do2() { | |
342 return 1; | |
343 } | |
344 | |
345 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
346 @Specialization(rewriteOn = RuntimeException.class) | |
347 int do1() throws RuntimeException { | |
348 return 2; | |
349 } | |
350 | |
351 } | |
352 | |
353 } |