use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class HostLanguage method findMetaObject.
@Override
protected Object findMetaObject(HostContext context, Object value) {
if (value instanceof TruffleObject) {
TruffleObject to = (TruffleObject) value;
if (VMAccessor.JAVAINTEROP.isHostObject(to)) {
Object javaObject = VMAccessor.JAVAINTEROP.asHostObject(to);
Class<?> javaType;
if (javaObject == null) {
javaType = Void.class;
} else {
javaType = javaObject.getClass();
}
return javaClassToGuestObject(javaType, context.internalContext);
} else if (PolyglotProxy.isProxyGuestObject(to)) {
Proxy proxy = PolyglotProxy.toProxyHostObject(to);
return javaClassToGuestObject(proxy.getClass(), context.internalContext);
} else if (VMAccessor.JAVAINTEROP.isHostFunction(value)) {
return "Bound Method";
} else {
return "Foreign Object";
}
} else {
return javaClassToGuestObject(value.getClass(), context.internalContext);
}
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class LoadNFILibraryTest method loadDefault.
@Test
public void loadDefault() {
TruffleObject library = eval("default");
Assert.assertNotNull(library);
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class LoadNFILibraryTest method loadLazy.
@Test
public void loadLazy() {
TruffleObject library = eval("load(RTLD_LAZY) '%s'", nativeTestLib);
Assert.assertNotNull(library);
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class LoadNFILibraryTest method loadUnknownFlag.
@Test
public void loadUnknownFlag() {
TruffleObject library = eval("load(_UNKNOWN_FLAG) '%s'", nativeTestLib);
Assert.assertNotNull(library);
}
use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.
the class LoadNFILibraryTest method eval.
private static TruffleObject eval(String format, Object... args) {
Source source = Source.newBuilder(String.format(format, args)).name("LoadLibraryTest").mimeType("application/x-native").build();
CallTarget target = runWithPolyglot.getTruffleTestEnv().parse(source);
return (TruffleObject) target.call();
}
Aggregations