@Override public CallTarget accessMessage(Message tree) { throw UnsupportedMessageException.raise(tree); } });
/** * Raises an {@link UnsupportedMessageException}, hidden as a {@link RuntimeException}, which * allows throwing it without an explicit throws declaration. The {@link ForeignAccess} methods * (e.g. <code> ForeignAccess.sendRead </code>) catch the exceptions and re-throw them as * checked exceptions. * * @param message message that is not supported * * @return the exception * @since 0.11 */ public static RuntimeException raise(Message message) { CompilerDirectives.transferToInterpreter(); return silenceException(RuntimeException.class, new UnsupportedMessageException(message)); }
@Override public Object execute(VirtualFrame frame) { throw UnsupportedMessageException.raise(message); } });
/** * Raises an {@link UnsupportedMessageException}, hidden as a {@link RuntimeException}, which * allows throwing it without an explicit throws declaration. The {@link ForeignAccess} methods * (e.g. <code> ForeignAccess.sendRead </code>) catch the exceptions and re-throw them as * checked exceptions. * * @param message message that is not supported * * @return the exception * @since 0.11 */ public static RuntimeException raise(Message message) { CompilerDirectives.transferToInterpreter(); return silenceException(RuntimeException.class, new UnsupportedMessageException(message)); }
@Override public CallTarget accessMessage(Message tree) { throw UnsupportedMessageException.raise(tree); } });
protected CallTarget createMessageTarget(ForeignAccess fa) { CallTarget ct = null; if (fa != null) { ct = fa.access(message); } if (ct == null) { throw UnsupportedMessageException.raise(message); } return ct; }
public Object access(JavaObject receiver) { Object obj = receiver.obj; if (obj != null) { if (obj.getClass().isArray()) { return Array.getLength(obj); } else if (obj instanceof List<?>) { return ((List<?>) obj).size(); } } CompilerDirectives.transferToInterpreter(); throw UnsupportedMessageException.raise(Message.GET_SIZE); }
public Object access(HostObject receiver) { Object obj = receiver.obj; if (obj != null) { if (obj.getClass().isArray()) { return Array.getLength(obj); } else if (obj instanceof List<?>) { return ((List<?>) obj).size(); } } CompilerDirectives.transferToInterpreter(); throw UnsupportedMessageException.raise(Message.GET_SIZE); }
@Override public Object get(Object key) { try { return ForeignAccess.sendRead(nodes.read, object, key); } catch (UnknownIdentifierException ex) { return null; // key not present in the map } catch (UnsupportedMessageException ex) { throw ex.raise(); } }
protected static final String expectIdentifier(Object[] arguments, int offset, Message message) { Object key = arguments[offset]; if (!(key instanceof String)) { CompilerDirectives.transferToInterpreter(); throw UnsupportedMessageException.raise(message); } return (String) key; }
protected static final String expectIdentifier(Object[] arguments, int offset, Message message) { Object key = arguments[offset]; if (!(key instanceof String)) { CompilerDirectives.transferToInterpreter(); throw UnsupportedMessageException.raise(message); } return (String) key; }
public Object access(JavaObject object) { if (JavaInterop.isPrimitive(object.obj)) { return object.obj; } else { return UnsupportedMessageException.raise(Message.UNBOX); } }
protected static final String expectIdentifier(Object[] arguments, int offset, Message message) { Object key = arguments[offset]; if (!(key instanceof String)) { CompilerDirectives.transferToInterpreter(); throw UnsupportedMessageException.raise(message); } return (String) key; }
@Override public Object get(Object key) { try { return ForeignAccess.sendRead(nodes.read, object, key); } catch (UnknownIdentifierException ex) { return null; // key not present in the map } catch (UnsupportedMessageException ex) { throw ex.raise(); } }
public Object access(HostObject object) { if (object.isPrimitive()) { return object.obj; } else { return UnsupportedMessageException.raise(Message.UNBOX); } }
protected static final String expectIdentifier(Object[] arguments, int offset, Message message) { Object key = arguments[offset]; if (!(key instanceof String)) { CompilerDirectives.transferToInterpreter(); throw UnsupportedMessageException.raise(message); } return (String) key; }
@Override @TruffleBoundary Object executeProxy(PolyglotLanguageContext context, Proxy proxy, Object[] arguments) { if (proxy instanceof org.graalvm.polyglot.proxy.ProxyPrimitive) { Object primitive = ((org.graalvm.polyglot.proxy.ProxyPrimitive) proxy).asPrimitive(); if (primitive instanceof String || primitive instanceof Boolean || // primitive instanceof Character || primitive instanceof Byte || primitive instanceof Short || primitive instanceof Integer || primitive instanceof Long || primitive instanceof Float || primitive instanceof Double) { return primitive; } else { throw new IllegalStateException(String.format("Invalid return value for %s. Only Java primitive values or String is allowed as return value fo asPrimitive().", org.graalvm.polyglot.proxy.ProxyPrimitive.class.getSimpleName())); } } else { throw UnsupportedMessageException.raise(Message.UNBOX); } } }
@Override @TruffleBoundary Object executeProxy(PolyglotLanguageContext context, Proxy proxy, Object[] arguments) { if (proxy instanceof org.graalvm.polyglot.proxy.ProxyPrimitive) { Object primitive = ((org.graalvm.polyglot.proxy.ProxyPrimitive) proxy).asPrimitive(); if (primitive instanceof String || primitive instanceof Boolean || // primitive instanceof Character || primitive instanceof Byte || primitive instanceof Short || primitive instanceof Integer || primitive instanceof Long || primitive instanceof Float || primitive instanceof Double) { return primitive; } else { throw new IllegalStateException(String.format("Invalid return value for %s. Only Java primitive values or String is allowed as return value fo asPrimitive().", org.graalvm.polyglot.proxy.ProxyPrimitive.class.getSimpleName())); } } else { throw UnsupportedMessageException.raise(Message.UNBOX); } } }
@SuppressWarnings("unused") @TruffleBoundary @Specialization(guards = {"!receiver.isArray()", "!isList(receiver)"}) protected static Object notArray(JavaObject receiver, Number index) { throw UnsupportedMessageException.raise(Message.READ); }
@Override @TruffleBoundary Object executeProxy(PolyglotLanguageContext context, Proxy proxy, Object[] arguments) { if (proxy instanceof ProxyNativeObject) { return ((ProxyNativeObject) proxy).asPointer(); } else { throw UnsupportedMessageException.raise(Message.AS_POINTER); } } }