Mercurial > hg > truffle
diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java @ 12391:7aa2a8c69ba3
TruffleDSL: improved code generation layout for implicit casts.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 03 Oct 2013 16:31:09 +0200 |
parents | 2fb276f5e3e9 |
children | 4e26955b6da2 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java Wed Oct 02 15:57:17 2013 +0200 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java Thu Oct 03 16:31:09 2013 +0200 @@ -54,13 +54,13 @@ public abstract Object executeEvaluated(VirtualFrame frame, Object value2); - @Specialization(order = 1) - public String op1(String value) throws RuntimeException { + @Specialization + public String op1(String value) { return value; } - @Specialization(order = 2) - public boolean op1(boolean value) throws RuntimeException { + @Specialization + public boolean op1(boolean value) { return value; } @@ -77,6 +77,38 @@ Assert.assertEquals(true, root.getNode().executeEvaluated(null, true)); } +// @TypeSystemReference(ImplicitCast0Types.class) +// @NodeChild(value = "operand", type = ImplicitCast0Node.class) +// abstract static class ImplicitCast1Node extends ValueNode { +// +// @Specialization +// public String op0(String value) { +// return value; +// } +// +// @Specialization(order = 1, rewriteOn = RuntimeException.class) +// public boolean op1(@SuppressWarnings("unused") boolean value) throws RuntimeException { +// throw new RuntimeException(); +// } +// +// @Specialization(order = 2) +// public boolean op2(boolean value) { +// return value; +// } +// +// } +// +// @Test +// public void testImplicitCast1() { +// ImplicitCast0Node node = ImplicitCast0NodeFactory.create(null); +// TestRootNode<ImplicitCast0Node> root = new TestRootNode<>(node); +// Assert.assertEquals("2", root.getNode().executeEvaluated(null, "2")); +// Assert.assertEquals(true, root.getNode().executeEvaluated(null, 1)); +// Assert.assertEquals("1", root.getNode().executeEvaluated(null, "1")); +// Assert.assertEquals(true, root.getNode().executeEvaluated(null, 1)); +// Assert.assertEquals(true, root.getNode().executeEvaluated(null, true)); +// } + // TODO assert implicit casts only in one direction // test example that covers the most cases