use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class HostProxy method getIterator.
@ExportMessage
@TruffleBoundary
Object getIterator(@CachedLibrary("this") InteropLibrary library, @Shared("cache") @Cached(value = "this.context.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws UnsupportedMessageException {
if (proxy instanceof ProxyIterable) {
Object result = guestToHostCall(library, cache.getIterator, context, proxy);
Object guestValue = context.toGuestValue(library, result);
InteropLibrary interop = InteropLibrary.getFactory().getUncached();
if (!interop.isIterator(guestValue)) {
throw illegalProxy(context, "getIterator() returned an invalid value %s but must return an iterator.", context.asValue(library, guestValue).toString());
}
return guestValue;
} else {
throw UnsupportedMessageException.create();
}
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class HostProxy method writeArrayElement.
@ExportMessage
@TruffleBoundary
void writeArrayElement(long index, Object value, @CachedLibrary("this") InteropLibrary library, @Shared("cache") @Cached(value = "this.context.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws UnsupportedMessageException {
if (proxy instanceof ProxyArray) {
Value castValue = context.asValue(library, value);
guestToHostCall(library, cache.arraySet, context, proxy, index, castValue);
} else {
throw UnsupportedMessageException.create();
}
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class HostProxy method getHashEntriesIterator.
@ExportMessage
@TruffleBoundary
Object getHashEntriesIterator(@CachedLibrary("this") InteropLibrary library, @Shared("cache") @Cached(value = "this.context.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws UnsupportedMessageException {
if (proxy instanceof ProxyHashMap) {
Object result = guestToHostCall(library, cache.getHashEntriesIterator, context, proxy);
Object guestValue = context.toGuestValue(library, result);
InteropLibrary interop = InteropLibrary.getFactory().getUncached();
if (!interop.isIterator(guestValue)) {
throw illegalProxy(context, "getHashEntriesIterator() returned an invalid value %s but must return an iterator.", context.asValue(library, guestValue).toString());
}
return guestValue;
} else {
throw UnsupportedMessageException.create();
}
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class HostProxy method writeHashEntry.
@ExportMessage
@TruffleBoundary
void writeHashEntry(Object key, Object value, @CachedLibrary("this") InteropLibrary library, @Shared("cache") @Cached(value = "this.context.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws UnsupportedMessageException {
if (proxy instanceof ProxyHashMap) {
Value keyValue = this.context.asValue(library, key);
Value valueValue = this.context.asValue(library, value);
guestToHostCall(library, cache.putHashEntry, this.context, proxy, keyValue, valueValue);
} else {
throw UnsupportedMessageException.create();
}
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class WasmFunctionInstance method execute.
@ExportMessage
Object execute(Object[] arguments, @CachedLibrary("this") InteropLibrary self, @Cached WasmIndirectCallNode callNode) {
TruffleContext c = getTruffleContext();
Object prev = c.enter(self);
try {
return callNode.execute(target, arguments);
} finally {
c.leave(self, prev);
}
}
Aggregations