use of org.graalvm.polyglot.proxy.ProxyHashMap in project graal by oracle.
the class HostProxy method readHashValue.
@ExportMessage
@TruffleBoundary
Object readHashValue(Object key, @CachedLibrary("this") InteropLibrary library, @Shared("cache") @Cached(value = "this.context.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws UnsupportedMessageException, UnknownKeyException {
if (proxy instanceof ProxyHashMap) {
if (!isHashValueExisting(key, library, cache)) {
throw UnknownKeyException.create(key);
}
Value keyValue = context.asValue(library, key);
Object result = guestToHostCall(library, cache.getHashValue, context, proxy, keyValue);
return context.toGuestValue(library, result);
} else {
throw UnsupportedMessageException.create();
}
}
use of org.graalvm.polyglot.proxy.ProxyHashMap in project graal by oracle.
the class HostProxy method removeHashEntry.
@ExportMessage
@TruffleBoundary
void removeHashEntry(Object key, @CachedLibrary("this") InteropLibrary library, @Shared("cache") @Cached(value = "this.context.getGuestToHostCache()", allowUncached = true) GuestToHostCodeCache cache) throws UnsupportedMessageException, UnknownKeyException {
if (proxy instanceof ProxyHashMap) {
if (!isHashValueExisting(key, library, cache)) {
throw UnknownKeyException.create(key);
}
Value keyValue = context.asValue(library, key);
guestToHostCall(library, cache.removeHashEntry, context, proxy, keyValue);
} else {
throw UnsupportedMessageException.create();
}
}
use of org.graalvm.polyglot.proxy.ProxyHashMap 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 org.graalvm.polyglot.proxy.ProxyHashMap 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();
}
}
Aggregations