示例#1
0
 /**
  * Executes {@link Message#createNode() foreign node}.
  *
  * @deprecated replaced by specialized methods for sending individual messages (e.g. {@link
  *     #sendRead(Node, VirtualFrame, TruffleObject, Object)}). For sending any message use the
  *     rare {@link #send(Node, VirtualFrame, TruffleObject, Object...)} method.
  * @param foreignNode the createNode created by {@link Message#createNode()}
  * @param frame the call frame
  * @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 IllegalStateException if any error occurred while accessing the <code>receiver</code>
  *     object
  */
 @SuppressWarnings("deprecation")
 @Deprecated
 public static Object execute(
     Node foreignNode, VirtualFrame frame, TruffleObject receiver, Object... arguments) {
   ForeignObjectAccessHeadNode fn = (ForeignObjectAccessHeadNode) foreignNode;
   return fn.executeForeign(frame, receiver, arguments);
 }
示例#2
0
 /**
  * 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 frame the call frame
  * @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
  */
 public static Object send(
     Node foreignNode, VirtualFrame frame, TruffleObject receiver, Object... arguments)
     throws InteropException {
   ForeignObjectAccessHeadNode fn = (ForeignObjectAccessHeadNode) foreignNode;
   try {
     return fn.executeForeignImpl(frame, receiver, arguments);
   } catch (InteropException e) {
     throw e;
   }
 }
示例#3
0
 /**
  * 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 frame the call frame
  * @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>
  */
 public static Object sendGetSize(Node getSizeNode, VirtualFrame frame, TruffleObject receiver)
     throws UnsupportedMessageException {
   ForeignObjectAccessHeadNode fn = (ForeignObjectAccessHeadNode) getSizeNode;
   try {
     return fn.executeForeignImpl(frame, receiver);
   } catch (UnsupportedMessageException e) {
     throw e;
   } catch (InteropException e) {
     throw new AssertionError("Unexpected exception catched.", e);
   }
 }
示例#4
0
 /**
  * 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 frame the call frame
  * @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>
  */
 public static Object sendNew(
     Node newNode, VirtualFrame frame, TruffleObject receiver, Object... arguments)
     throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
   ForeignObjectAccessHeadNode fn = (ForeignObjectAccessHeadNode) newNode;
   try {
     return fn.executeForeignImpl(frame, receiver, arguments);
   } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
     throw e;
   } catch (InteropException e) {
     throw new AssertionError("Unexpected exception catched.", e);
   }
 }
示例#5
0
 /**
  * Sends a {@link Message#WRITE WRITE message} to the foreign receiver object by executing the
  * <code> writeNode </code>.
  *
  * @param writeNode the createNode created by {@link Message#createNode()}
  * @param frame the call frame
  * @param receiver foreign object to receive the message passed to {@link Message#createNode()}
  *     method
  * @param identifier name of the property to be written
  * @param value value to be written
  * @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>writeNode</code>
  * @throws UnknownIdentifierException if the <code>receiver</code> does not allow writing a
  *     property for the given <code>identifier</code>
  * @throws UnsupportedTypeException if <code>value</code> has an unsupported type
  */
 public static Object sendWrite(
     Node writeNode, VirtualFrame frame, TruffleObject receiver, Object identifier, Object value)
     throws UnknownIdentifierException, UnsupportedTypeException, UnsupportedMessageException {
   ForeignObjectAccessHeadNode fn = (ForeignObjectAccessHeadNode) writeNode;
   try {
     return fn.executeForeignImpl(frame, receiver, new Object[] {identifier, value});
   } catch (UnknownIdentifierException
       | UnsupportedTypeException
       | UnsupportedMessageException e) {
     throw e;
   } catch (InteropException e) {
     throw new AssertionError("Unexpected exception catched.", e);
   }
 }
示例#6
0
 /**
  * Sends an INVOKE {@link Message} to the foreign receiver object by executing the <code>
  *  invokeNode </code>.
  *
  * @param invokeNode the createNode created by {@link Message#createNode()}
  * @param frame the call frame
  * @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 UnknownIdentifierException if the <code>receiver</code> does not have a property for
  *     the given <code>identifier</code> that can be invoked
  * @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>invokeNode</code>
  */
 public static Object sendInvoke(
     Node invokeNode,
     VirtualFrame frame,
     TruffleObject receiver,
     String identifier,
     Object... arguments)
     throws UnsupportedTypeException, ArityException, UnknownIdentifierException,
         UnsupportedMessageException {
   ForeignObjectAccessHeadNode fn = (ForeignObjectAccessHeadNode) invokeNode;
   try {
     Object[] args = new Object[arguments.length + 1];
     System.arraycopy(arguments, 0, args, 1, arguments.length);
     args[0] = identifier;
     return fn.executeForeignImpl(frame, receiver, args);
   } catch (UnsupportedTypeException
       | ArityException
       | UnknownIdentifierException
       | UnsupportedMessageException e) {
     throw e;
   } catch (InteropException e) {
     throw new AssertionError("Unexpected exception catched.", e);
   }
 }