/** * Sends a {@link Message} to the foreign receiver object by executing the * {@link Message#createNode() foreign node}. * * @param foreignNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @param arguments parameters for the receiver * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws InteropException if any error occurred while accessing the <code>receiver</code> * object * @since 0.24 */ public static Object send(Node foreignNode, TruffleObject receiver, Object... arguments) throws InteropException { try { return ((InteropAccessNode) foreignNode).execute(receiver, arguments); } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw e; } }
/** * Sends a {@link Message} to the foreign receiver object by executing the * {@link Message#createNode() foreign node}. * * @param foreignNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @param arguments parameters for the receiver * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws InteropException if any error occurred while accessing the <code>receiver</code> * object * @since 0.24 */ public static Object send(Node foreignNode, TruffleObject receiver, Object... arguments) throws InteropException { try { return ((InteropAccessNode) foreignNode).execute(receiver, arguments); } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw e; } }
/** * Sends an {@link Message#UNBOX UNBOX message} to the foreign receiver object by executing the * <code> unboxNode </code>. * * @param unboxNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>unboxNode</code> * @since 0.24 */ public static Object sendUnbox(Node unboxNode, TruffleObject receiver) throws UnsupportedMessageException { try { return ((InteropAccessNode) unboxNode).execute(receiver); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends an {@link Message#AS_POINTER AS_POINTER message} to the foreign receiver object by * executing the <code> asPointerNode </code>. * * @param asPointerNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return a raw 64bit pointer value * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>asPointerNode</code> * @since 0.26 */ public static long sendAsPointer(Node asPointerNode, TruffleObject receiver) throws UnsupportedMessageException { try { return (long) ((InteropAccessNode) asPointerNode).execute(receiver); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends a {@link Message#GET_SIZE GET_SIZE message} to the foreign receiver object by executing * the <code> getSizeNode </code>. * * @param getSizeNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>getSizeNode</code> * @since 0.24 */ public static Object sendGetSize(Node getSizeNode, TruffleObject receiver) throws UnsupportedMessageException { try { return ((InteropAccessNode) getSizeNode).execute(receiver); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends an {@link Message#UNBOX UNBOX message} to the foreign receiver object by executing the * <code> unboxNode </code>. * * @param unboxNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>unboxNode</code> * @since 0.24 */ public static Object sendUnbox(Node unboxNode, TruffleObject receiver) throws UnsupportedMessageException { try { return ((InteropAccessNode) unboxNode).execute(receiver); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends a {@link Message#GET_SIZE GET_SIZE message} to the foreign receiver object by executing * the <code> getSizeNode </code>. * * @param getSizeNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>getSizeNode</code> * @since 0.24 */ public static Object sendGetSize(Node getSizeNode, TruffleObject receiver) throws UnsupportedMessageException { try { return ((InteropAccessNode) getSizeNode).execute(receiver); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends an {@link Message#TO_NATIVE TO_NATIVE message} to the foreign receiver object by * executing the <code> toNativeNode </code>. * * @param toNativeNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return return value * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>toNativeNode</code> * @since 0.26 */ public static Object sendToNative(Node toNativeNode, TruffleObject receiver) throws UnsupportedMessageException { try { return ((InteropAccessNode) toNativeNode).execute(receiver); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends an {@link Message#TO_NATIVE TO_NATIVE message} to the foreign receiver object by * executing the <code> toNativeNode </code>. * * @param toNativeNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return return value * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>toNativeNode</code> * @since 0.26 */ public static Object sendToNative(Node toNativeNode, TruffleObject receiver) throws UnsupportedMessageException { try { return ((InteropAccessNode) toNativeNode).execute(receiver); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends an {@link Message#AS_POINTER AS_POINTER message} to the foreign receiver object by * executing the <code> asPointerNode </code>. * * @param asPointerNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return a raw 64bit pointer value * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>asPointerNode</code> * @since 0.26 */ public static long sendAsPointer(Node asPointerNode, TruffleObject receiver) throws UnsupportedMessageException { try { return (long) ((InteropAccessNode) asPointerNode).execute(receiver); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
throws UnknownIdentifierException, UnsupportedTypeException, UnsupportedMessageException { try { return ((InteropAccessNode) writeNode).execute(receiver, identifier, value); } catch (UnknownIdentifierException | UnsupportedTypeException | UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter();
/** * Sends an NEW {@link Message} to the foreign receiver object by executing the * <code> newNode </code>. * * @param newNode the createNode created by {@link Message#createNode()} * @param receiver foreign function object to receive the message passed to * {@link Message#createNode()} method * @param arguments arguments passed to the foreign function * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedTypeException if one of element of the <code>arguments</code> has an * unsupported type * @throws ArityException if the <code>arguments</code> array does not contain the right number * of arguments for the foreign function * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>newNode</code> * @since 0.24 */ public static Object sendNew(Node newNode, TruffleObject receiver, Object... arguments) throws UnsupportedTypeException, ArityException, UnsupportedMessageException { try { return ((InteropAccessNode) newNode).execute(receiver, arguments); } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
throws UnknownIdentifierException, UnsupportedTypeException, UnsupportedMessageException { try { return ((InteropAccessNode) writeNode).execute(receiver, identifier, value); } catch (UnknownIdentifierException | UnsupportedTypeException | UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter();
/** * Sends a {@link Message#REMOVE REMOVE message} to the foreign receiver object by executing the * <code> removeNode </code>. * * @param removeNode the node created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @param identifier name of the property to be removed * @return <code>true</code> if the property was successfully removed, <code>false</code> * otherwise * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>readNode</code> * @throws UnknownIdentifierException if the <code>receiver</code> does not allow removing a * property for the given <code>identifier</code> * @since 0.32 */ public static boolean sendRemove(Node removeNode, TruffleObject receiver, Object identifier) throws UnknownIdentifierException, UnsupportedMessageException { try { return (boolean) ((InteropAccessNode) removeNode).execute(receiver, identifier); } catch (UnsupportedMessageException | UnknownIdentifierException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends an EXECUTE {@link Message} to the foreign receiver object by executing the * <code> executeNode </code>. * * @param executeNode the createNode created by {@link Message#createNode()} * @param receiver foreign function object to receive the message passed to * {@link Message#createNode()} method * @param arguments arguments passed to the foreign function * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedTypeException if one of element of the <code>arguments</code> has an * unsupported type * @throws ArityException if the <code>arguments</code> array does not contain the right number * of arguments for the foreign function * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>executeNode</code> * @since 0.24 */ public static Object sendExecute(Node executeNode, TruffleObject receiver, Object... arguments) throws UnsupportedTypeException, ArityException, UnsupportedMessageException { try { return ((InteropAccessNode) executeNode).execute(receiver, arguments); } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends a {@link Message#REMOVE REMOVE message} to the foreign receiver object by executing the * <code> removeNode </code>. * * @param removeNode the node created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @param identifier name of the property to be removed * @return <code>true</code> if the property was successfully removed, <code>false</code> * otherwise * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>readNode</code> * @throws UnknownIdentifierException if the <code>receiver</code> does not allow removing a * property for the given <code>identifier</code> * @since 0.32 */ public static boolean sendRemove(Node removeNode, TruffleObject receiver, Object identifier) throws UnknownIdentifierException, UnsupportedMessageException { try { return (boolean) ((InteropAccessNode) removeNode).execute(receiver, identifier); } catch (UnsupportedMessageException | UnknownIdentifierException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends an NEW {@link Message} to the foreign receiver object by executing the * <code> newNode </code>. * * @param newNode the createNode created by {@link Message#createNode()} * @param receiver foreign function object to receive the message passed to * {@link Message#createNode()} method * @param arguments arguments passed to the foreign function * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @throws UnsupportedTypeException if one of element of the <code>arguments</code> has an * unsupported type * @throws ArityException if the <code>arguments</code> array does not contain the right number * of arguments for the foreign function * @throws UnsupportedMessageException if the <code>receiver</code> does not support the * {@link Message#createNode() message represented} by <code>newNode</code> * @since 0.24 */ public static Object sendNew(Node newNode, TruffleObject receiver, Object... arguments) throws UnsupportedTypeException, ArityException, UnsupportedMessageException { try { return ((InteropAccessNode) newNode).execute(receiver, arguments); } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); throw e; } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
return ((InteropAccessNode) readNode).execute(receiver, identifier); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter();
/** * Sends an {@link Message#HAS_KEYS HAS_KEYS message} to the foreign receiver object by * executing the <code>hasKeysNode</code>. If the object does not support the message, a * {@link Message#KEYS} message is sent to test the presence of keys. * * @param hasKeysNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @since 0.30 */ public static boolean sendHasKeys(Node hasKeysNode, TruffleObject receiver) { try { return (boolean) ((InteropAccessNode) hasKeysNode).execute(receiver); } catch (UnsupportedMessageException ex) { CompilerDirectives.transferToInterpreter(); try { sendKeys(Message.KEYS.createNode(), receiver, true); return true; } catch (UnsupportedMessageException uex) { return false; } } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }
/** * Sends an {@link Message#HAS_KEYS HAS_KEYS message} to the foreign receiver object by * executing the <code>hasKeysNode</code>. If the object does not support the message, a * {@link Message#KEYS} message is sent to test the presence of keys. * * @param hasKeysNode the createNode created by {@link Message#createNode()} * @param receiver foreign object to receive the message passed to {@link Message#createNode()} * method * @return return value, if any * @throws ClassCastException if the createNode has not been created by * {@link Message#createNode()} method. * @since 0.30 */ public static boolean sendHasKeys(Node hasKeysNode, TruffleObject receiver) { try { return (boolean) ((InteropAccessNode) hasKeysNode).execute(receiver); } catch (UnsupportedMessageException ex) { CompilerDirectives.transferToInterpreter(); try { sendKeys(Message.KEYS.createNode(), receiver, true); return true; } catch (UnsupportedMessageException uex) { return false; } } catch (InteropException e) { CompilerDirectives.transferToInterpreter(); throw new AssertionError("Unexpected exception caught.", e); } }