Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java @ 19289:62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 03 Feb 2015 15:07:07 +0100 |
parents | c5db657d93c1 |
children | 476374f3fe9a |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java Mon Dec 29 18:32:03 2014 +0100 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java Tue Feb 03 15:07:07 2015 +0100 @@ -84,6 +84,22 @@ return Truffle.getRuntime().createCallTarget(node); } + static RootCallTarget createCallTarget(NodeFactory<? extends ValueNode> factory, Object... constants) { + return Truffle.getRuntime().createCallTarget(createRoot(factory, constants)); + } + + static boolean assertionsEnabled() { + boolean assertOn = false; + // *assigns* true if assertions are on. + assert (assertOn = true) == true; + return assertOn; + } + + @SuppressWarnings("unchecked") + static <T extends ValueNode> T getNode(CallTarget target) { + return ((TestRootNode<T>) ((RootCallTarget) target).getRootNode()).getNode(); + } + static <E> Object executeWith(TestRootNode<? extends ValueNode> node, Object... values) { return createCallTarget(node).call(values); }