Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Message.java @ 22147:5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Mon, 14 Sep 2015 13:33:03 +0200 |
parents | e70b20f4bb00 |
children | b84a11723d64 |
rev | line source |
---|---|
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
1 /* |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
4 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
10 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
16 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
20 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
23 * questions. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
24 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api.interop; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
26 |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
27 import com.oracle.truffle.api.frame.VirtualFrame; |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.nodes.Node; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.interop.ForeignAccess.Factory; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
30 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
31 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
32 * Inter-operability is based on sending messages. Standard messages are defined as as constants |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
33 * like {@link #IS_NULL} or factory methods in this class, but one can always define their own, |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
34 * specialized messages. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
35 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
36 public abstract class Message { |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
37 /** |
22106
3b2ae36a942f
Improving documentation of READ and WRITE Message
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
38 * Message to read an object field. The |
3b2ae36a942f
Improving documentation of READ and WRITE Message
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
39 * {@link Factory#access(com.oracle.truffle.api.interop.Message) target} created for this |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
40 * message accepts (in addition to a |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
41 * {@link ForeignAccess#getReceiver(com.oracle.truffle.api.frame.Frame) receiver}) a single |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
42 * {@link ForeignAccess#getArguments(com.oracle.truffle.api.frame.Frame) argument} identifying a |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
43 * field to read - e.g. either {@link String} or an {@link Integer} - if access to an array at |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
44 * particular index is requested. The code that wants to send this message should use: |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
45 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
46 * <pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
47 * {@link ForeignAccess}.{@link ForeignAccess#execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object...) execute}( |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
48 * {@link Message#READ}.{@link Message#createNode()}, {@link VirtualFrame currentFrame}, receiver, nameOfTheField |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
49 * ); |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
50 * </pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
51 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
52 * Where <code>receiver</code> is the {@link TruffleObject foreign object} to access and |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
53 * <code>nameOfTheField</code> is the name (or index) of its field. |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
54 * <p> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
55 * To achieve good performance it is essential to cache/keep reference to the |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
56 * {@link Message#createNode() created node}. |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
57 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
58 public static final Message READ = Read.INSTANCE; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
59 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
60 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
61 * Converts {@link TruffleObject truffle value} to Java primitive type. Primitive types are |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
62 * subclasses of {@link Number}, {@link Boolean}, {@link Character} and {@link String}. Before |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
63 * sending the {@link #UNBOX} message, it is desirable to send the {@link #IS_BOXED} one and |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
64 * verify that the object can really be unboxed. To unbox an object, use: |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
65 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
66 * <pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
67 * {@link ForeignAccess}.{@link ForeignAccess#execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object...) execute}( |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
68 * {@link Message#UNBOX}.{@link Message#createNode()}, {@link VirtualFrame currentFrame}, objectToUnbox |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
69 * ); |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
70 * </pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
71 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
72 * The returned value should be subclass of {@link Number}, {@link Boolean}, {@link Character} |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
73 * or {@link String}. |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
74 * <p> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
75 * To achieve good performance it is essential to cache/keep reference to the |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
76 * {@link Message#createNode() created node}. |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
77 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
78 public static final Message UNBOX = Unbox.INSTANCE; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
79 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
80 /** |
22106
3b2ae36a942f
Improving documentation of READ and WRITE Message
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
81 * Message to write a field. The {@link Factory#access(com.oracle.truffle.api.interop.Message) |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
82 * target} created for this message accepts the object to modify as a |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
83 * {@link ForeignAccess#getReceiver(com.oracle.truffle.api.frame.Frame) receiver} and two |
22106
3b2ae36a942f
Improving documentation of READ and WRITE Message
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
84 * {@link ForeignAccess#getArguments(com.oracle.truffle.api.frame.Frame) arguments}. The first |
3b2ae36a942f
Improving documentation of READ and WRITE Message
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
85 * one identifies a field to read - e.g. either {@link String} or an {@link Integer} - if access |
3b2ae36a942f
Improving documentation of READ and WRITE Message
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
86 * to an array at particular index is requested. The second one is the value to assign to such |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
87 * field. Use following style to construct field modification message: |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
88 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
89 * <pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
90 * {@link ForeignAccess}.{@link ForeignAccess#execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object...) execute}( |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
91 * {@link Message#WRITE}.{@link Message#createNode()}, {@link VirtualFrame currentFrame}, receiver, nameOfTheField, newValue |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
92 * ); |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
93 * </pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
94 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
95 * Where <code>receiver</code> is the {@link TruffleObject foreign object} to access, |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
96 * <code>nameOfTheField</code> is the name (or index) of its field and <code>newValue</code> is |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
97 * the value to assign to the receiver's field. |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
98 * <p> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
99 * To achieve good performance it is essential to cache/keep reference to the |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
100 * {@link Message#createNode() created node}. |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
101 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
102 public static Message WRITE = Write.INSTANCE; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
103 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
104 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
105 * Creates an execute message. All messages created by this method are |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
106 * {@link Object#equals(java.lang.Object) equal} to each other regardless of the value of |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
107 * <code>argumentsLength</code>. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
108 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
109 * @param argumentsLength number of parameters to pass to the target |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
110 * @return execute message |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
111 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
112 public static Message createExecute(int argumentsLength) { |
22108
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
113 return Execute.create(Execute.EXECUTE, argumentsLength); |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
114 } |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
115 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
116 /** |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
117 * Message to check executability of a |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
118 * {@link ForeignAccess#getReceiver(com.oracle.truffle.api.frame.Frame) foreign object}. |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
119 * <p> |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
120 * Calling {@link Factory#access(com.oracle.truffle.api.interop.Message) the target} created for |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
121 * this message accepts {@link ForeignAccess#getArguments(com.oracle.truffle.api.frame.Frame) no |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
122 * arguments} and a single non-null |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
123 * {@link ForeignAccess#getReceiver(com.oracle.truffle.api.frame.Frame) receiver}. The call |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
124 * should yield value of {@link Boolean}. Either {@link Boolean#TRUE} if the receiver can be |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
125 * executed (e.g. accepts {@link #createExecute(int)} message, or {@link Boolean#FALSE} |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
126 * otherwise. This is the way to send the <code>IS_EXECUTABLE</code> message: |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
127 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
128 * <pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
129 * {@link Boolean} canBeExecuted = ({@link Boolean}) {@link ForeignAccess}.{@link ForeignAccess#execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object...) execute}( |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
130 * {@link Message#IS_EXECUTABLE}.{@link Message#createNode()}, {@link VirtualFrame currentFrame}, receiver |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
131 * ); |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
132 * </pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
133 * <p> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
134 * To achieve good performance it is essential to cache/keep reference to the |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
135 * {@link Message#createNode() created node}. |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
136 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
137 public static final Message IS_EXECUTABLE = IsExecutable.INSTANCE; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
138 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
139 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
140 * Creates an execute message. All messages created by this method are |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
141 * {@link Object#equals(java.lang.Object) equal} to each other regardless of the value of |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
142 * <code>argumentsLength</code>. The expected behavior of this message is to perform |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
143 * {@link #READ} first and on the result invoke {@link #createExecute(int)}. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
144 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
145 * @param argumentsLength number of parameters to pass to the target |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
146 * @return read & execute message |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
147 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
148 public static Message createInvoke(int argumentsLength) { |
22108
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
149 return Execute.create(Execute.INVOKE, argumentsLength); |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
150 } |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
151 |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
152 /** |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
153 * Creates an allocation message. All messages created by this method are |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
154 * {@link Object#equals(java.lang.Object) equal} to each other regardless of the value of |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
155 * <code>argumentsLength</code>. The expected behavior of this message is to allocate a new |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
156 * instance of the {@link ForeignAccess#getReceiver(com.oracle.truffle.api.frame.Frame) |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
157 * receiver} and then perform its constructor with appropriate number of arguments. |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
158 * |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
159 * @param argumentsLength number of parameters to pass to the target |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
160 * @return read & execute message |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
161 */ |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
162 public static Message createNew(int argumentsLength) { |
f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22106
diff
changeset
|
163 return Execute.create(Execute.NEW, argumentsLength); |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
164 } |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
165 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
166 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
167 * Check for <code>null</code> message. The Truffle languages are suggested to have their own |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
168 * object representing <code>null</code> like values in their languages. For purposes of |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
169 * inter-operability it is essential to canonicalize such values from time to time - sending |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
170 * this message is a way to recognize such <code>null</code> representing values: |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
171 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
172 * <pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
173 * {@link Boolean} isNull = ({@link Boolean}) {@link ForeignAccess}.{@link ForeignAccess#execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object...) execute}( |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
174 * {@link Message#IS_NULL}.{@link Message#createNode()}, {@link VirtualFrame currentFrame}, objectToCheckForNull |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
175 * ); |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
176 * </pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
177 * |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
178 * <p> |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
179 * Calling {@link Factory#access(com.oracle.truffle.api.interop.Message) the target} created for |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
180 * this message should yield value of {@link Boolean}. |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
181 * <p> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
182 * To achieve good performance it is essential to cache/keep reference to the |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
183 * {@link Message#createNode() created node}. |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
184 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
185 public static final Message IS_NULL = IsNull.INSTANCE; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
186 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
187 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
188 * Message to check for having a size. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
189 * <p> |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
190 * Calling {@link Factory#access(com.oracle.truffle.api.interop.Message) the target} created for |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
191 * this message should yield value of {@link Boolean}. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
192 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
193 public static final Message HAS_SIZE = HasSize.INSTANCE; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
194 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
195 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
196 * Getter of the size. If {@link #HAS_SIZE supported}, this message allows to obtain a size (of |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
197 * an array). |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
198 * <p> |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
199 * Calling {@link Factory#access(com.oracle.truffle.api.interop.Message) the target} created for |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
200 * this message should yield value of {@link Integer}. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
201 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
202 public static final Message GET_SIZE = GetSize.INSTANCE; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
203 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
204 /** |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
205 * Check for value being boxed. Can the {@link TruffleObject foreign object} be converted to one |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
206 * of the basic Java types? Many languages have a special representation for types like number, |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
207 * string, etc. To ensure inter-operability, these types should support unboxing - if they do, |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
208 * they should handle this message and return {@link Boolean#TRUE}. The way to check whether an |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
209 * object is boxed is: |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
210 * |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
211 * <pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
212 * {@link Boolean} isBoxed = ({@link Boolean}) {@link ForeignAccess}.{@link ForeignAccess#execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object...) execute}( |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
213 * {@link Message#IS_BOXED}.{@link Message#createNode()}, {@link VirtualFrame currentFrame}, objectToCheck |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
214 * ); |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
215 * </pre> |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
216 * |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
217 * Calling {@link Factory#accessMessage(com.oracle.truffle.api.interop.Message) the target} |
22147
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
218 * created for this message should yield value of {@link Boolean}. If the object responds with |
5857f5ee9486
More precise description of inter-operability messages and examples of their usage. Step #1 - e.g. the trivial messages.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22135
diff
changeset
|
219 * {@link Boolean#TRUE}, it is safe to continue by sending it {@link #UNBOX} message. |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
220 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
221 public static final Message IS_BOXED = IsBoxed.INSTANCE; |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
222 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
223 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
224 * Compares types of two messages. Messages are encouraged to implement this method. All |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
225 * standard ones ({@link #IS_NULL}, {@link #READ}, etc.) do so. Messages obtained via the same |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
226 * {@link #createExecute(int) method} are equal, messages obtained by different methods or |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
227 * fields are not. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
228 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
229 * @param message the object to compare to |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
230 * @return true, if the structure of the message is that same as of <code>this</code> one. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
231 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
232 @Override |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
233 public abstract boolean equals(Object message); |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
234 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
235 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
236 * When re-implementing {@link #equals(java.lang.Object)}, it is generally recommended to also |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
237 * implement <code>hashCode()</code>. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
238 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
239 * @return hash code |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
240 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
241 @Override |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
242 public abstract int hashCode(); |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
243 |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
244 /** |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
245 * Creates an AST node for this message. The node can be inserted into AST of your language and |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
246 * will handle communication with the foreign language. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
247 * |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
248 * @return node to be inserted into your AST and passed back to |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
249 * {@link ForeignAccess#execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object[])} |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
250 * method. |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
251 */ |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
252 public final Node createNode() { |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
253 return new ForeignObjectAccessHeadNode(this); |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
254 } |
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
255 |
22135
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
256 /** |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
257 * Converts the message into canonical string representation. The converted string can be |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
258 * stored, persisted, transfered and later passed to {@link #valueOf(java.lang.String)} to |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
259 * construct the message again. |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
260 * |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
261 * @param message the message to convert |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
262 * @return canonical string representation |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
263 */ |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
264 public static String toString(Message message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
265 if (Message.READ == message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
266 return "READ"; // NOI18N |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
267 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
268 if (Message.WRITE == message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
269 return "WRITE"; // NOI18N |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
270 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
271 if (Message.UNBOX == message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
272 return "UNBOX"; // NOI18N |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
273 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
274 if (Message.GET_SIZE == message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
275 return "GET_SIZE"; // NOI18N |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
276 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
277 if (Message.HAS_SIZE == message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
278 return "HAS_SIZE"; // NOI18N |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
279 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
280 if (Message.IS_NULL == message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
281 return "IS_NULL"; // NOI18N |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
282 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
283 if (Message.IS_BOXED == message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
284 return "IS_BOXED"; // NOI18N |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
285 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
286 if (Message.IS_EXECUTABLE == message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
287 return "IS_EXECUTABLE"; // NOI18N |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
288 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
289 if (message instanceof Execute) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
290 return ((Execute) message).name(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
291 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
292 return message.getClass().getName(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
293 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
294 |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
295 /** |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
296 * Converts string representation into real message. If the string was obtained by |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
297 * {@link #toString(com.oracle.truffle.api.interop.Message)} method, it is guaranteed to be |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
298 * successfully recognized (if the classpath of the system remains the same). |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
299 * |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
300 * @param message canonical string representation of a message |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
301 * @return the message |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
302 * @throws IllegalArgumentException if the string does not represent known message |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
303 */ |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
304 public static Message valueOf(String message) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
305 try { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
306 return (Message) Message.class.getField(message).get(null); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
307 } catch (Exception ex) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
308 try { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
309 String factory = "create" + message.charAt(0) + message.substring(1).toLowerCase(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
310 return (Message) Message.class.getMethod(factory, int.class).invoke(null, 0); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
311 } catch (Exception ex2) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
312 try { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
313 return (Message) Class.forName(message).newInstance(); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
314 } catch (Exception ex1) { |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
315 throw new IllegalArgumentException("Cannot find message for " + message, ex); |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
316 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
317 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
318 } |
e70b20f4bb00
Implementing API for Java/Truffle interop. Based around JavaInterop.asJavaObject and JavaInterop.asTruffleObject methods. Connected to TruffleVM via Symbol.as(Class) wrapper. Verified by extended TCK.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22108
diff
changeset
|
319 } |
21770
c76742cc2c6f
Polishing inter-operability APIs: Exposing only Message, TruffleObject and ForeignAccess-related classes.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
320 } |