use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class TestMemberAccess method testArrayOutOfBoundsAccess.
@Test
public void testArrayOutOfBoundsAccess() throws InteropException {
Object[] array = new Object[1];
TruffleObject arrayObject = JavaInterop.asTruffleObject(array);
assertTrue(JavaInteropTest.isArray(arrayObject));
ForeignAccess.sendRead(readNode, arrayObject, 0);
try {
ForeignAccess.sendRead(readNode, arrayObject, 1);
fail();
} catch (UnknownIdentifierException e) {
}
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class VarArgsTest method testStringJoin1.
@Test
public void testStringJoin1() throws InteropException {
TruffleObject strClass = JavaInterop.asTruffleObject(String.class);
TruffleObject join = (TruffleObject) ForeignAccess.sendRead(Message.READ.createNode(), strClass, "join");
TruffleObject delimiter = JavaInterop.asTruffleObject(" ");
TruffleObject elements = JavaInterop.asTruffleObject(new String[] { "Hello", "World" });
Object result = ForeignAccess.sendExecute(Message.createExecute(2).createNode(), join, new Object[] { delimiter, elements });
Assert.assertEquals("Hello World", result);
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class VarArgsTest method testCharSequenceEllipsis.
@Test
public void testCharSequenceEllipsis() throws InteropException {
TruffleObject mainClass = JavaInterop.asTruffleObject(Join.class);
TruffleObject ellipsis = (TruffleObject) ForeignAccess.sendRead(Message.READ.createNode(), mainClass, "charSequenceEllipsis");
TruffleObject element1 = JavaInterop.asTruffleObject("Hello");
TruffleObject element2 = JavaInterop.asTruffleObject("World");
Object result = ForeignAccess.sendExecute(Message.createExecute(2).createNode(), ellipsis, new Object[] { element1, element2 });
Assert.assertEquals("Hello World", result);
TruffleObject elements = JavaInterop.asTruffleObject(new String[] { "Hello", "World" });
result = ForeignAccess.sendExecute(Message.createExecute(1).createNode(), ellipsis, elements);
Assert.assertEquals("Hello World", result);
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class VarArgsTest method testStringEllipsis.
@Test
public void testStringEllipsis() throws InteropException {
TruffleObject mainClass = JavaInterop.asTruffleObject(Join.class);
TruffleObject ellipsis = (TruffleObject) ForeignAccess.sendRead(Message.READ.createNode(), mainClass, "stringEllipsis");
TruffleObject element1 = JavaInterop.asTruffleObject("Hello");
TruffleObject element2 = JavaInterop.asTruffleObject("World");
Object result = ForeignAccess.sendExecute(Message.createExecute(2).createNode(), ellipsis, new Object[] { element1, element2 });
Assert.assertEquals("Hello World", result);
TruffleObject elements = JavaInterop.asTruffleObject(new String[] { "Hello", "World" });
result = ForeignAccess.sendExecute(Message.createExecute(1).createNode(), ellipsis, elements);
Assert.assertEquals("Hello World", result);
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class HostEntryRootNode method execute.
@Override
public final Object execute(VirtualFrame frame) {
Object[] arguments = frame.getArguments();
Object languageContext = arguments[0];
T receiver = getReceiverType().cast(arguments[1]);
Object result;
result = executeImpl(languageContext, receiver, arguments, 2);
assert languageContext == null || !(result instanceof TruffleObject);
return result;
}
Aggregations