use of org.graalvm.polyglot.proxy.Proxy in project graal by oracle.
the class PolyglotLanguageContext method toGuestValue.
static Object toGuestValue(Object originalLanguageContext, Object receiver) {
PolyglotLanguageContext languageContext = ((PolyglotLanguageContext) originalLanguageContext);
if (receiver instanceof Value) {
Value receiverValue = (Value) receiver;
PolyglotValue valueImpl = (PolyglotValue) languageContext.getAPIAccess().getImpl(receiverValue);
if (valueImpl.languageContext.context != languageContext.context) {
CompilerDirectives.transferToInterpreter();
throw PolyglotImpl.engineError(new IllegalArgumentException(String.format("Values cannot be passed from one context to another. " + "The current value originates from context 0x%s and the argument originates from context 0x%s.", Integer.toHexString(languageContext.context.api.hashCode()), Integer.toHexString(valueImpl.languageContext.context.api.hashCode()))));
}
return languageContext.getAPIAccess().getReceiver(receiverValue);
} else if (PolyglotImpl.isGuestPrimitive(receiver)) {
return receiver;
} else if (receiver instanceof Proxy) {
return PolyglotProxy.toProxyGuestObject(languageContext, (Proxy) receiver);
} else {
return JAVAINTEROP.toGuestObject(receiver, languageContext);
}
}
Aggregations