Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java @ 14991:64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 06 Apr 2014 17:46:24 +0200 |
parents | a08b8694f556 |
children |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java Sat Apr 05 19:35:30 2014 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java Sun Apr 06 17:46:24 2014 +0200 @@ -30,21 +30,20 @@ /** * <h3>Passing Arguments</h3> - * + * * <p> - * A guest language can pass its own custom arguments when invoking a Truffle method by creating a - * subclass of {@link Arguments}. When invoking a call target with - * {@link CallTarget#call(Arguments)}, the arguments can be passed. A Truffle node can access the - * arguments passed into the Truffle method by using {@link VirtualFrame#getArguments}. + * When invoking a call target with {@link CallTarget#call(Object[])}, arguments can be passed. A + * Truffle node can access the arguments passed into the Truffle method by using + * {@link VirtualFrame#getArguments}. * </p> - * + * * <p> * The arguments class should only contain fields that are declared as final. This allows the * Truffle runtime to improve optimizations around guest language method calls. Also, the arguments - * object must never be stored into a field. It should be created immediately before invoking - * {@link CallTarget#call(Arguments)} and no longer be accessed afterwards. + * object array must never be stored into a field. It should be created immediately before invoking + * {@link CallTarget#call(Object[])} and no longer be accessed afterwards. * </p> - * + * * <p> * The next part of the Truffle API introduction is at {@link com.oracle.truffle.api.test.FrameTest} * . @@ -57,19 +56,10 @@ TruffleRuntime runtime = Truffle.getRuntime(); TestRootNode rootNode = new TestRootNode(new TestArgumentNode[]{new TestArgumentNode(0), new TestArgumentNode(1)}); CallTarget target = runtime.createCallTarget(rootNode); - Object result = target.call(new TestArguments(20, 22)); + Object result = target.call(new Object[]{20, 22}); Assert.assertEquals(42, result); } - private static class TestArguments extends Arguments { - - final int[] values; - - TestArguments(int... values) { - this.values = values; - } - } - private static class TestRootNode extends RootNode { @Children private final TestArgumentNode[] children; @@ -99,7 +89,7 @@ } int execute(VirtualFrame frame) { - return frame.getArguments(TestArguments.class).values[index]; + return (Integer) frame.getArguments()[index]; } } }