Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardsTest.java @ 11507:d6a5ab791b0d
Truffle-DSL: fixed a bug in grouping of abstract guards.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 02 Sep 2013 15:22:25 +0200 |
parents | efe58aa92f86 |
children | 5a0c694ef735 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardsTest.java Fri Aug 30 17:45:53 2013 +0200 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardsTest.java Mon Sep 02 15:22:25 2013 +0200 @@ -34,11 +34,15 @@ import com.oracle.truffle.api.dsl.test.GuardsTestFactory.GuardWithBoxedPrimitiveFactory; import com.oracle.truffle.api.dsl.test.GuardsTestFactory.GuardWithObjectFactory; import com.oracle.truffle.api.dsl.test.GuardsTestFactory.InvocationGuardFactory; +import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestAbstractGuard1Factory; import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve1Factory; import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve2Factory; import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve3Factory; import com.oracle.truffle.api.dsl.test.NodeContainerTest.Str; import com.oracle.truffle.api.dsl.test.NodeContainerTest.StrBase; +import com.oracle.truffle.api.dsl.test.TypeSystemTest.Abstract; +import com.oracle.truffle.api.dsl.test.TypeSystemTest.BExtendsAbstract; +import com.oracle.truffle.api.dsl.test.TypeSystemTest.CExtendsAbstract; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; @@ -271,4 +275,43 @@ } } + @NodeChild("expression") + public abstract static class TestGuardResolve4 extends ValueNode { + + boolean guard(StrBase primitive) { + return false; + } + + @Specialization(guards = "guard") + int doSpecialized(Str value0) { + return 42; + } + } + + @Test + public void testAbstractGuard1() { + TestRootNode<?> root = createRoot(TestAbstractGuard1Factory.getInstance()); + + assertEquals(BExtendsAbstract.INSTANCE, executeWith(root, BExtendsAbstract.INSTANCE)); + assertEquals(CExtendsAbstract.INSTANCE, executeWith(root, CExtendsAbstract.INSTANCE)); + } + + @NodeChild("expression") + public abstract static class TestAbstractGuard1 extends ValueNode { + + boolean guard(Abstract value0) { + return true; + } + + @Specialization(order = 1, guards = "guard") + BExtendsAbstract doSpecialized1(BExtendsAbstract value0) { + return value0; + } + + @Specialization(order = 2, guards = "guard") + CExtendsAbstract doSpecialized2(CExtendsAbstract value0) { + return value0; + } + } + }