Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReachabilityTest.java @ 21951:9c8c0937da41
Moving all sources into truffle subdirectory
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 17 Jun 2015 10:58:08 +0200 |
parents | graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ReachabilityTest.java@b1530a6cce8c |
children | dc83cc1f94f2 |
comparison
equal
deleted
inserted
replaced
21950:2a5011c7e641 | 21951:9c8c0937da41 |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.api.dsl.test; | |
24 | |
25 import java.math.*; | |
26 | |
27 import com.oracle.truffle.api.dsl.*; | |
28 import com.oracle.truffle.api.dsl.test.TypeSystemTest.Abstract; | |
29 import com.oracle.truffle.api.dsl.test.TypeSystemTest.BExtendsAbstract; | |
30 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; | |
31 | |
32 public class ReachabilityTest { | |
33 | |
34 static class Reachability1 extends ValueNode { | |
35 @Specialization | |
36 int do2() { | |
37 return 2; | |
38 } | |
39 | |
40 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
41 @Specialization | |
42 int do1() { | |
43 return 2; | |
44 } | |
45 } | |
46 | |
47 @NodeChildren({@NodeChild("a")}) | |
48 static class ReachabilityType1 extends ValueNode { | |
49 @Specialization | |
50 int do2(int a) { | |
51 return a; | |
52 } | |
53 | |
54 @ExpectError("Specialization is not reachable. It is shadowed by do2(int).") | |
55 @Specialization | |
56 int do1(int a) { | |
57 return a; | |
58 } | |
59 } | |
60 | |
61 @NodeChildren({@NodeChild("a")}) | |
62 static class ReachabilityType2 extends ValueNode { | |
63 @Specialization | |
64 BExtendsAbstract do2(BExtendsAbstract a) { | |
65 return a; | |
66 } | |
67 | |
68 @ExpectError("Specialization is not reachable. It is shadowed by do2(BExtendsAbstract).") | |
69 @Specialization | |
70 BExtendsAbstract do1(BExtendsAbstract a) { | |
71 return a; | |
72 } | |
73 } | |
74 | |
75 @NodeChildren({@NodeChild("a")}) | |
76 static class ReachabilityType3 extends ValueNode { | |
77 @Specialization | |
78 Abstract do2(Abstract a) { | |
79 return a; | |
80 } | |
81 | |
82 @ExpectError("Specialization is not reachable. It is shadowed by do2(Abstract).") | |
83 @Specialization | |
84 BExtendsAbstract do1(BExtendsAbstract a) { | |
85 return a; | |
86 } | |
87 } | |
88 | |
89 @NodeChildren({@NodeChild("a")}) | |
90 static class ReachabilityType4 extends ValueNode { | |
91 | |
92 @Specialization | |
93 BExtendsAbstract do2(BExtendsAbstract a) { | |
94 return a; | |
95 } | |
96 | |
97 @Specialization | |
98 Abstract do1(Abstract a) { | |
99 return a; | |
100 } | |
101 | |
102 } | |
103 | |
104 @NodeChildren({@NodeChild("a")}) | |
105 static class ReachabilityType5 extends ValueNode { | |
106 | |
107 @Specialization | |
108 double do2(double a) { | |
109 return a; | |
110 } | |
111 | |
112 @ExpectError("Specialization is not reachable. It is shadowed by do2(double).") | |
113 @Specialization | |
114 int do1(int a) { | |
115 return a; | |
116 } | |
117 | |
118 } | |
119 | |
120 @NodeChildren({@NodeChild("a")}) | |
121 static class ReachabilityType6 extends ValueNode { | |
122 | |
123 @Specialization | |
124 BigInteger do2(BigInteger a) { | |
125 return a; | |
126 } | |
127 | |
128 @ExpectError("Specialization is not reachable. It is shadowed by do2(BigInteger).") | |
129 @Specialization | |
130 int do1(int a) { | |
131 return a; | |
132 } | |
133 | |
134 } | |
135 | |
136 @NodeChildren({@NodeChild("a")}) | |
137 static class ReachabilityType7 extends ValueNode { | |
138 | |
139 @Specialization | |
140 int do2(int a) { | |
141 return a; | |
142 } | |
143 | |
144 @Specialization | |
145 BigInteger do1(BigInteger a) { | |
146 return a; | |
147 } | |
148 | |
149 } | |
150 | |
151 @NodeChildren({@NodeChild("a")}) | |
152 static class ReachabilityType8 extends ValueNode { | |
153 | |
154 @Specialization | |
155 int do2(int a) { | |
156 return a; | |
157 } | |
158 | |
159 @Specialization | |
160 Object do1(Object a) { | |
161 return a; | |
162 } | |
163 | |
164 } | |
165 | |
166 @NodeChildren({@NodeChild("a")}) | |
167 static class ReachabilityType9 extends ValueNode { | |
168 | |
169 @Specialization | |
170 Object do2(Object a) { | |
171 return a; | |
172 } | |
173 | |
174 @ExpectError("Specialization is not reachable. It is shadowed by do2(Object).") | |
175 @Specialization | |
176 int do1(int a) { | |
177 return a; | |
178 } | |
179 } | |
180 | |
181 static class ReachabilityGuard1 extends ValueNode { | |
182 | |
183 boolean foo() { | |
184 return false; | |
185 } | |
186 | |
187 @Specialization(guards = "foo()") | |
188 int do2() { | |
189 return 1; | |
190 } | |
191 | |
192 @Specialization | |
193 int do1() { | |
194 return 2; | |
195 } | |
196 | |
197 } | |
198 | |
199 static class ReachabilityGuard2 extends ValueNode { | |
200 | |
201 boolean foo() { | |
202 return false; | |
203 } | |
204 | |
205 @Specialization | |
206 int do2() { | |
207 return 2; | |
208 } | |
209 | |
210 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
211 @Specialization(guards = "foo()") | |
212 int do1() { | |
213 return 1; | |
214 } | |
215 | |
216 } | |
217 | |
218 static class ReachabilityGuard3 extends ValueNode { | |
219 | |
220 boolean foo() { | |
221 return false; | |
222 } | |
223 | |
224 @Specialization(guards = "foo()") | |
225 int do2() { | |
226 return 1; | |
227 } | |
228 | |
229 @Specialization | |
230 int do1() { | |
231 return 2; | |
232 } | |
233 | |
234 } | |
235 | |
236 static class ReachabilityGuard4 extends ValueNode { | |
237 | |
238 boolean foo() { | |
239 return false; | |
240 } | |
241 | |
242 @Specialization(guards = "foo()") | |
243 int do2() { | |
244 return 1; | |
245 } | |
246 | |
247 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
248 @Specialization(guards = "foo()") | |
249 int do1() { | |
250 return 2; | |
251 } | |
252 | |
253 } | |
254 | |
255 static class ReachabilityThrowable1 extends ValueNode { | |
256 | |
257 @Specialization(rewriteOn = RuntimeException.class) | |
258 int do2() throws RuntimeException { | |
259 return 1; | |
260 } | |
261 | |
262 @Specialization | |
263 int do1() { | |
264 return 2; | |
265 } | |
266 | |
267 } | |
268 | |
269 static class ReachabilityThrowable2 extends ValueNode { | |
270 | |
271 @Specialization | |
272 int do2() { | |
273 return 1; | |
274 } | |
275 | |
276 @ExpectError("Specialization is not reachable. It is shadowed by do2().") | |
277 @Specialization(rewriteOn = RuntimeException.class) | |
278 int do1() throws RuntimeException { | |
279 return 2; | |
280 } | |
281 | |
282 } | |
283 | |
284 } |