Search in sources :

Example 26 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class JavaInteropTest method notUnboxable.

@Test
public void notUnboxable() {
    Node unboxNode = Message.UNBOX.createNode();
    assertThrowsExceptionWithCause(() -> ForeignAccess.sendUnbox(unboxNode, JavaInterop.asTruffleObject(null)), UnsupportedMessageException.class);
    assertThrowsExceptionWithCause(() -> ForeignAccess.sendUnbox(unboxNode, JavaInterop.asTruffleObject(new Object())), UnsupportedMessageException.class);
    assertThrowsExceptionWithCause(() -> ForeignAccess.sendUnbox(unboxNode, JavaInterop.asTruffleObject(Object.class)), UnsupportedMessageException.class);
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test) ValueHostInteropTest(com.oracle.truffle.api.test.polyglot.ValueHostInteropTest)

Example 27 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class JavaInteropTest method message.

static Object message(final Message m, TruffleObject receiver, Object... arr) {
    Node n = m.createNode();
    CallTarget callTarget = Truffle.getRuntime().createCallTarget(new TemporaryRoot(n, receiver));
    return callTarget.call(arr);
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node)

Example 28 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class OverloadedTest method testOverloadingTruffleObjectArg.

@Test
public void testOverloadingTruffleObjectArg() throws InteropException {
    Node n = Message.createInvoke(1).createNode();
    ForeignAccess.sendInvoke(n, obj, "x", new UnboxableToInt(21));
    assertEquals(42, data.x);
    ForeignAccess.sendInvoke(n, obj, "x", JavaInterop.asTruffleObject(10));
    assertEquals(20, data.x);
}
Also used : Node(com.oracle.truffle.api.nodes.Node) Test(org.junit.Test)

Example 29 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class OverloadedTest method testWidening.

@Test
public void testWidening() throws InteropException {
    Node n = Message.createInvoke(1).createNode();
    Num num = new Num();
    TruffleObject numobj = JavaInterop.asTruffleObject(num);
    ForeignAccess.sendInvoke(n, numobj, "d", (byte) 42);
    assertEquals("int", num.parameter);
    ForeignAccess.sendInvoke(n, numobj, "d", (short) 42);
    assertEquals("int", num.parameter);
    ForeignAccess.sendInvoke(n, numobj, "d", 42);
    assertEquals("int", num.parameter);
    ForeignAccess.sendInvoke(n, numobj, "d", 42.1f);
    assertEquals("double", num.parameter);
    ForeignAccess.sendInvoke(n, numobj, "d", 42.1d);
    assertEquals("double", num.parameter);
    ForeignAccess.sendInvoke(n, numobj, "d", 0x8000_0000L);
    assertEquals("double", num.parameter);
    ForeignAccess.sendInvoke(n, numobj, "d", 42L);
    assertEquals("int", num.parameter);
    ForeignAccess.sendInvoke(n, numobj, "f", 42L);
    assertEquals("int", num.parameter);
}
Also used : Node(com.oracle.truffle.api.nodes.Node) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 30 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class SLInstrumentTest method checkBlock.

private static void checkBlock(Scope ls) {
    assertEquals("block", ls.getName());
    // Test that ls.getNode() does not return the current root node, it ought to be a block node
    Node node = ls.getNode();
    assertNotNull(node);
    assertFalse(node.getClass().getName(), node instanceof RootNode);
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) RootNode(com.oracle.truffle.api.nodes.RootNode) ProbeNode(com.oracle.truffle.api.instrumentation.ProbeNode) Node(com.oracle.truffle.api.nodes.Node)

Aggregations

Node (com.oracle.truffle.api.nodes.Node)101 RootNode (com.oracle.truffle.api.nodes.RootNode)65 Test (org.junit.Test)46 InstrumentableNode (com.oracle.truffle.api.instrumentation.InstrumentableNode)21 ProbeNode (com.oracle.truffle.api.instrumentation.ProbeNode)21 Source (com.oracle.truffle.api.source.Source)16 NodeVisitor (com.oracle.truffle.api.nodes.NodeVisitor)11 CallTarget (com.oracle.truffle.api.CallTarget)9 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)9 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)8 WrapperNode (com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode)7 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)6 SourceSection (com.oracle.truffle.api.source.SourceSection)6 TestHelper.createNode (com.oracle.truffle.api.dsl.test.TestHelper.createNode)5 ValueNode (com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode)5 SLEvalRootNode (com.oracle.truffle.sl.nodes.SLEvalRootNode)5 SLStatementNode (com.oracle.truffle.sl.nodes.SLStatementNode)5 SLBlockNode (com.oracle.truffle.sl.nodes.controlflow.SLBlockNode)5 LinkedHashMap (java.util.LinkedHashMap)5 TruffleInstrument (com.oracle.truffle.api.instrumentation.TruffleInstrument)4