Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardsTest.java @ 13528:5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 07 Jan 2014 18:52:32 +0100 |
parents | d6a5ab791b0d |
children |
comparison
equal
deleted
inserted
replaced
13527:25ecb47a6d0e | 13528:5a0c694ef735 |
---|---|
36 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.InvocationGuardFactory; | 36 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.InvocationGuardFactory; |
37 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestAbstractGuard1Factory; | 37 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestAbstractGuard1Factory; |
38 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve1Factory; | 38 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve1Factory; |
39 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve2Factory; | 39 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve2Factory; |
40 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve3Factory; | 40 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve3Factory; |
41 import com.oracle.truffle.api.dsl.test.NodeContainerTest.Str; | |
42 import com.oracle.truffle.api.dsl.test.NodeContainerTest.StrBase; | |
43 import com.oracle.truffle.api.dsl.test.TypeSystemTest.Abstract; | 41 import com.oracle.truffle.api.dsl.test.TypeSystemTest.Abstract; |
44 import com.oracle.truffle.api.dsl.test.TypeSystemTest.BExtendsAbstract; | 42 import com.oracle.truffle.api.dsl.test.TypeSystemTest.BExtendsAbstract; |
45 import com.oracle.truffle.api.dsl.test.TypeSystemTest.CExtendsAbstract; | 43 import com.oracle.truffle.api.dsl.test.TypeSystemTest.CExtendsAbstract; |
46 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; | 44 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; |
47 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; | 45 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
122 | 120 |
123 @Test | 121 @Test |
124 public void testGuardWithBaseClass() { | 122 public void testGuardWithBaseClass() { |
125 TestRootNode<?> root = createRoot(GuardWithBaseClassFactory.getInstance()); | 123 TestRootNode<?> root = createRoot(GuardWithBaseClassFactory.getInstance()); |
126 | 124 |
127 assertEquals(42, executeWith(root, new Str("42"))); | 125 assertEquals(42, executeWith(root, new BExtendsAbstract())); |
128 } | 126 } |
129 | 127 |
130 @NodeChild("expression") | 128 @NodeChild("expression") |
131 public abstract static class GuardWithBaseClass extends ValueNode { | 129 public abstract static class GuardWithBaseClass extends ValueNode { |
132 | 130 |
133 boolean baseGuard(StrBase base) { | 131 boolean baseGuard(Abstract base) { |
134 return true; | 132 return true; |
135 } | 133 } |
136 | 134 |
137 @Specialization(guards = "baseGuard") | 135 @Specialization(guards = "baseGuard") |
138 int doSpecialized(Str value0) { | 136 int doSpecialized(BExtendsAbstract value0) { |
139 return 42; | 137 return 42; |
140 } | 138 } |
141 } | 139 } |
142 | 140 |
143 @Test | 141 @Test |
225 } | 223 } |
226 | 224 |
227 @Test | 225 @Test |
228 public void testGuardResolve2() { | 226 public void testGuardResolve2() { |
229 TestRootNode<?> root = createRoot(TestGuardResolve2Factory.getInstance()); | 227 TestRootNode<?> root = createRoot(TestGuardResolve2Factory.getInstance()); |
230 assertEquals(42, executeWith(root, new Str(""))); | 228 assertEquals(42, executeWith(root, new BExtendsAbstract())); |
231 } | 229 } |
232 | 230 |
233 @NodeChild("expression") | 231 @NodeChild("expression") |
234 public abstract static class TestGuardResolve2 extends ValueNode { | 232 public abstract static class TestGuardResolve2 extends ValueNode { |
235 | 233 |
236 boolean guard(Object primitive) { | 234 boolean guard(Object primitive) { |
237 return false; | 235 return false; |
238 } | 236 } |
239 | 237 |
240 boolean guard(StrBase primitive) { | 238 boolean guard(Abstract primitive) { |
241 return true; | 239 return true; |
242 } | 240 } |
243 | 241 |
244 @Specialization(guards = "guard") | 242 @Specialization(guards = "guard") |
245 int doSpecialized(Str value0) { | 243 int doSpecialized(BExtendsAbstract value0) { |
246 return 42; | 244 return 42; |
247 } | 245 } |
248 } | 246 } |
249 | 247 |
250 @Test | 248 @Test |
251 public void testGuardResolve3() { | 249 public void testGuardResolve3() { |
252 TestRootNode<?> root = createRoot(TestGuardResolve3Factory.getInstance()); | 250 TestRootNode<?> root = createRoot(TestGuardResolve3Factory.getInstance()); |
253 | 251 |
254 assertEquals(42, executeWith(root, new Str(""))); | 252 assertEquals(42, executeWith(root, new BExtendsAbstract())); |
255 } | 253 } |
256 | 254 |
257 @NodeChild("expression") | 255 @NodeChild("expression") |
258 public abstract static class TestGuardResolve3 extends ValueNode { | 256 public abstract static class TestGuardResolve3 extends ValueNode { |
259 | 257 |
260 boolean guard(Object primitive) { | 258 boolean guard(Object primitive) { |
261 return false; | 259 return false; |
262 } | 260 } |
263 | 261 |
264 boolean guard(StrBase primitive) { | 262 boolean guard(Abstract primitive) { |
265 return false; | 263 return false; |
266 } | 264 } |
267 | 265 |
268 boolean guard(Str primitive) { | 266 boolean guard(BExtendsAbstract primitive) { |
269 return true; | 267 return true; |
270 } | 268 } |
271 | 269 |
272 @Specialization(guards = "guard") | 270 @Specialization(guards = "guard") |
273 int doSpecialized(Str value0) { | 271 int doSpecialized(BExtendsAbstract value0) { |
274 return 42; | 272 return 42; |
275 } | 273 } |
276 } | 274 } |
277 | 275 |
278 @NodeChild("expression") | 276 @NodeChild("expression") |
279 public abstract static class TestGuardResolve4 extends ValueNode { | 277 public abstract static class TestGuardResolve4 extends ValueNode { |
280 | 278 |
281 boolean guard(StrBase primitive) { | 279 boolean guard(Abstract primitive) { |
282 return false; | 280 return false; |
283 } | 281 } |
284 | 282 |
285 @Specialization(guards = "guard") | 283 @Specialization(guards = "guard") |
286 int doSpecialized(Str value0) { | 284 int doSpecialized(BExtendsAbstract value0) { |
287 return 42; | 285 return 42; |
288 } | 286 } |
289 } | 287 } |
290 | 288 |
291 @Test | 289 @Test |