Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java @ 22157:dc83cc1f94f2
Using fully qualified imports
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 16 Sep 2015 11:33:22 +0200 |
parents | c334865b9d42 |
children | 67f75f61c974 dcb70d90c11d 1c0f490984d5 |
rev | line source |
---|---|
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
1 /* |
21649
1c76a5662753
Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21557
diff
changeset
|
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
4 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
10 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
16 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
20 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
23 * questions. |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
24 */ |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api; |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
26 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
27 import com.oracle.truffle.api.debug.DebugSupportProvider; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
28 import com.oracle.truffle.api.impl.Accessor; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
29 import com.oracle.truffle.api.impl.FindContextNode; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
30 import com.oracle.truffle.api.instrument.ToolSupportProvider; |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
31 import com.oracle.truffle.api.nodes.Node; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
32 import com.oracle.truffle.api.source.Source; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
33 import java.io.IOException; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
34 import java.io.Reader; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
35 import java.io.Writer; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
36 import java.lang.annotation.ElementType; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
37 import java.lang.annotation.Retention; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
38 import java.lang.annotation.RetentionPolicy; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22133
diff
changeset
|
39 import java.lang.annotation.Target; |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
40 import java.util.Collections; |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
41 import java.util.Map; |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
42 import java.util.WeakHashMap; |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
43 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
44 /** |
22094
0058a9461865
Truffle/instrumentation: minor Javadoc fixes
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22081
diff
changeset
|
45 * An entry point for everyone who wants to implement a Truffle based language. By providing an |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
46 * implementation of this type and registering it using {@link Registration} annotation, your |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
47 * language becomes accessible to users of the {@link com.oracle.truffle.api.vm.TruffleVM Truffle |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
48 * virtual machine} - all they will need to do is to include your JAR into their application and all |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
49 * the Truffle goodies (multi-language support, multitenant hosting, debugging, etc.) will be made |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
50 * available to them. |
22094
0058a9461865
Truffle/instrumentation: minor Javadoc fixes
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22081
diff
changeset
|
51 * |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
52 * @param <C> internal state of the language associated with every thread that is executing program |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
53 * {@link #parse(com.oracle.truffle.api.source.Source, com.oracle.truffle.api.nodes.Node, java.lang.String...) |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
54 * parsed} by the language |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
55 */ |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
56 @SuppressWarnings("javadoc") |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
57 public abstract class TruffleLanguage<C> { |
21481
bb51b9a142b3
Enforcing public, one parameter constructor for each TruffleLanguage by annotation processor and required call to super.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21468
diff
changeset
|
58 /** |
bb51b9a142b3
Enforcing public, one parameter constructor for each TruffleLanguage by annotation processor and required call to super.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21468
diff
changeset
|
59 * Constructor to be called by subclasses. |
bb51b9a142b3
Enforcing public, one parameter constructor for each TruffleLanguage by annotation processor and required call to super.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21468
diff
changeset
|
60 */ |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
61 protected TruffleLanguage() { |
21481
bb51b9a142b3
Enforcing public, one parameter constructor for each TruffleLanguage by annotation processor and required call to super.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21468
diff
changeset
|
62 } |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
63 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
64 /** |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
65 * The annotation to use to register your language to the |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
66 * {@link com.oracle.truffle.api.vm.TruffleVM Truffle} system. By annotating your implementation |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
67 * of {@link TruffleLanguage} by this annotation you are just a |
21649
1c76a5662753
Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21557
diff
changeset
|
68 * <em>one JAR drop to the class path</em> away from your users. Once they include your JAR in |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
69 * their application, your language will be available to the |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
70 * {@link com.oracle.truffle.api.vm.TruffleVM Truffle virtual machine}. |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
71 */ |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
72 @Retention(RetentionPolicy.SOURCE) |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
73 @Target(ElementType.TYPE) |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
74 public @interface Registration { |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
75 /** |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
76 * Unique name of your language. This name will be exposed to users via the |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
77 * {@link com.oracle.truffle.api.vm.TruffleVM.Language#getName()} getter. |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
78 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
79 * @return identifier of your language |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
80 */ |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
81 String name(); |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
82 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
83 /** |
21889
45083be8a812
Truffle: add a version string to the information provided with Language registration
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21716
diff
changeset
|
84 * Unique string identifying the language version. This name will be exposed to users via |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
85 * the {@link com.oracle.truffle.api.vm.TruffleVM.Language#getVersion()} getter. |
21889
45083be8a812
Truffle: add a version string to the information provided with Language registration
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21716
diff
changeset
|
86 * |
45083be8a812
Truffle: add a version string to the information provided with Language registration
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21716
diff
changeset
|
87 * @return version of your language |
45083be8a812
Truffle: add a version string to the information provided with Language registration
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21716
diff
changeset
|
88 */ |
45083be8a812
Truffle: add a version string to the information provided with Language registration
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21716
diff
changeset
|
89 String version(); |
45083be8a812
Truffle: add a version string to the information provided with Language registration
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21716
diff
changeset
|
90 |
45083be8a812
Truffle: add a version string to the information provided with Language registration
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21716
diff
changeset
|
91 /** |
21649
1c76a5662753
Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21557
diff
changeset
|
92 * List of MIME types associated with your language. Users will use them (directly or |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
93 * indirectly) when |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
94 * {@link com.oracle.truffle.api.vm.TruffleVM#eval(com.oracle.truffle.api.source.Source) |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
95 * executing} their code snippets or their {@link Source files}. |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
96 * |
21649
1c76a5662753
Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21557
diff
changeset
|
97 * @return array of MIME types assigned to your language files |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
98 */ |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
99 String[] mimeType(); |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
100 } |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
101 |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
102 /** |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
103 * Creates internal representation of the executing context suitable for given environment. Each |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
104 * time the {@link TruffleLanguage language} is used by a new |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
105 * {@link com.oracle.truffle.api.vm.TruffleVM} or in a new thread, the system calls this method |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
106 * to let the {@link TruffleLanguage language} prepare for <em>execution</em>. The returned |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
107 * execution context is completely language specific; it is however expected it will contain |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
108 * reference to here-in provided <code>env</code> and adjust itself according to parameters |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
109 * provided by the <code>env</code> object. |
22094
0058a9461865
Truffle/instrumentation: minor Javadoc fixes
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22081
diff
changeset
|
110 * |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
111 * @param env the environment the language is supposed to operate in |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
112 * @return internal data of the language in given environment |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
113 */ |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
114 protected abstract C createContext(Env env); |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
115 |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
116 /** |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
117 * Parses the provided source and generates appropriate AST. The parsing should execute no user |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
118 * code, it should only create the {@link Node} tree to represent the source. The parsing may be |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
119 * performed in a context (specified as another {@link Node}) or without context. The |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
120 * {@code argumentNames} may contain symbolic names for actual parameters of the call to the |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
121 * returned value. The result should be a call target with method |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
122 * {@link CallTarget#call(java.lang.Object...)} that accepts as many arguments as were provided |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
123 * via the {@code argumentNames} array. |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
124 * |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
125 * @param code source code to parse |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
126 * @param context a {@link Node} defining context for the parsing |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
127 * @param argumentNames symbolic names for parameters of |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
128 * {@link CallTarget#call(java.lang.Object...)} |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
129 * @return a call target to invoke which also keeps in memory the {@link Node} tree representing |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
130 * just parsed <code>code</code> |
22081
ff531952a91c
Making sure IOException from TruffleLanguage.parse method is correctly propagated to TruffleVM.eval caller.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22070
diff
changeset
|
131 * @throws IOException thrown when I/O or parsing goes wrong. Here-in thrown exception is |
ff531952a91c
Making sure IOException from TruffleLanguage.parse method is correctly propagated to TruffleVM.eval caller.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22070
diff
changeset
|
132 * propagate to the user who called one of <code>eval</code> methods of |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
133 * {@link com.oracle.truffle.api.vm.TruffleVM} |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
134 */ |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
135 protected abstract CallTarget parse(Source code, Node context, String... argumentNames) throws IOException; |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
136 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
137 /** |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
138 * Called when some other language is seeking for a global symbol. This method is supposed to do |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
139 * lazy binding, e.g. there is no need to export symbols in advance, it is fine to wait until |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
140 * somebody asks for it (by calling this method). |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
141 * <p> |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
142 * The exported object can either be <code>TruffleObject</code> (e.g. a native object from the |
21890
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
143 * other language) to support interoperability between languages, {@link String} or one of Java |
21716
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
144 * primitive wrappers ( {@link Integer}, {@link Double}, {@link Short}, {@link Boolean}, etc.). |
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
145 * <p> |
21890
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
146 * The way a symbol becomes <em>exported</em> is language dependent. In general it is preferred |
21716
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
147 * to make the export explicit - e.g. call some function or method to register an object under |
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
148 * specific name. Some languages may however decide to support implicit export of symbols (for |
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
149 * example from global scope, if they have one). However explicit exports should always be |
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
150 * preferred. Implicitly exported object of some name should only be used when there is no |
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
151 * explicit export under such <code>globalName</code>. To ensure so the infrastructure first |
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
152 * asks all known languages for <code>onlyExplicit</code> symbols and only when none is found, |
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
153 * it does one more round with <code>onlyExplicit</code> set to <code>false</code>. |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
154 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
155 * @param globalName the name of the global symbol to find |
21716
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
156 * @param onlyExplicit should the language seek for implicitly exported object or only consider |
2f9e4d984d16
Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21649
diff
changeset
|
157 * the explicitly exported ones? |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
158 * @return an exported object or <code>null</code>, if the symbol does not represent anything |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
159 * meaningful in this language |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
160 */ |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
161 protected abstract Object findExportedSymbol(C context, String globalName, boolean onlyExplicit); |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
162 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
163 /** |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
164 * Returns global object for the language. |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
165 * <p> |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
166 * The object is expected to be <code>TruffleObject</code> (e.g. a native object from the other |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
167 * language) but technically it can be one of Java primitive wrappers ({@link Integer}, |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
168 * {@link Double}, {@link Short}, etc.). |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
169 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
170 * @return the global object or <code>null</code> if the language does not support such concept |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
171 */ |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
172 protected abstract Object getLanguageGlobal(C context); |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
173 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
174 /** |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
175 * Checks whether the object is provided by this language. |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
176 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
177 * @param object the object to check |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
178 * @return <code>true</code> if this language can deal with such object in native way |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
179 */ |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
180 protected abstract boolean isObjectOfLanguage(Object object); |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
181 |
21890
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
182 protected abstract ToolSupportProvider getToolSupport(); |
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
183 |
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
184 protected abstract DebugSupportProvider getDebugSupport(); |
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
185 |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
186 /** |
22070
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
187 * Allows a language implementor to create a node that can effectively lookup up the context |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
188 * associated with current execution. The context is created by |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
189 * {@link #createContext(com.oracle.truffle.api.TruffleLanguage.Env)} method. |
22094
0058a9461865
Truffle/instrumentation: minor Javadoc fixes
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22081
diff
changeset
|
190 * |
22070
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
191 * @return node to be inserted into program to effectively find out current execution context |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
192 * for this language |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
193 */ |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
194 @SuppressWarnings({"rawtypes", "unchecked"}) |
22068
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
195 protected final Node createFindContextNode() { |
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
196 final Class<? extends TruffleLanguage<?>> c = (Class<? extends TruffleLanguage<?>>) getClass(); |
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
197 return new FindContextNode(c); |
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
198 } |
22070
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
199 |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
200 /** |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
201 * Uses the {@link #createFindContextNode()} node to obtain the current context. |
22094
0058a9461865
Truffle/instrumentation: minor Javadoc fixes
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22081
diff
changeset
|
202 * |
22070
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
203 * @param n the node created by this language's {@link #createFindContextNode()} |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
204 * @return the context created by |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
205 * {@link #createContext(com.oracle.truffle.api.TruffleLanguage.Env)} method at the |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
206 * beginning of the language execution |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
207 * @throws ClassCastException if the node has not been created by <code>this</code>. |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
208 * {@link #createFindContextNode()} method. |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
209 */ |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
210 @SuppressWarnings({"rawtypes", "unchecked"}) |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
211 protected final C findContext(Node n) { |
22068
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
212 FindContextNode fcn = (FindContextNode) n; |
22070
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
213 if (fcn.getLanguageClass() != getClass()) { |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
214 throw new ClassCastException(); |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
215 } |
a7ca9e9a1d51
Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22068
diff
changeset
|
216 return (C) fcn.executeFindContext(); |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
217 } |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
218 |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
219 private static final class LangCtx<C> { |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
220 final TruffleLanguage<C> lang; |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
221 final C ctx; |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
222 |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
223 public LangCtx(TruffleLanguage<C> lang, Env env) { |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
224 this.lang = lang; |
22133
c334865b9d42
Make sure TruffleLanguage.createEnv is only called when Accessor.CURRENT_VM is known
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22128
diff
changeset
|
225 // following call verifies that Accessor.CURRENT_VM is provided |
c334865b9d42
Make sure TruffleLanguage.createEnv is only called when Accessor.CURRENT_VM is known
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22128
diff
changeset
|
226 assert API.findLanguage(null, null) == null; |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
227 this.ctx = lang.createContext(env); |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
228 } |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
229 |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
230 Object findExportedSymbol(String globalName, boolean onlyExplicit) { |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
231 return lang.findExportedSymbol(ctx, globalName, onlyExplicit); |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
232 } |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
233 |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
234 Object getLanguageGlobal() { |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
235 return lang.getLanguageGlobal(ctx); |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
236 } |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
237 } |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
238 |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
239 /** |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
240 * Represents execution environment of the {@link TruffleLanguage}. Each active |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
241 * {@link TruffleLanguage} receives instance of the environment before any code is executed upon |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
242 * it. The environment has knowledge of all active languages and can exchange symbols between |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
243 * them. |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
244 */ |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
245 public static final class Env { |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
246 private final Object vm; |
22109
b5eaddcdf86a
Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22104
diff
changeset
|
247 private final TruffleLanguage<?> lang; |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
248 private final LangCtx<?> langCtx; |
21490
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
249 private final Reader in; |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
250 private final Writer err; |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
251 private final Writer out; |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
252 |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
253 Env(Object vm, TruffleLanguage<?> lang, Writer out, Writer err, Reader in) { |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
254 this.vm = vm; |
21490
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
255 this.in = in; |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
256 this.err = err; |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
257 this.out = out; |
22109
b5eaddcdf86a
Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22104
diff
changeset
|
258 this.lang = lang; |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
259 this.langCtx = new LangCtx<>(lang, this); |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
260 } |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
261 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
262 /** |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
263 * Asks the environment to go through other registered languages and find whether they |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
264 * export global symbol of specified name. The expected return type is either |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
265 * <code>TruffleObject</code>, or one of wrappers of Java primitive types ({@link Integer}, |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
266 * {@link Double}). |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
267 * |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
268 * @param globalName the name of the symbol to search for |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
269 * @return object representing the symbol or <code>null</code> |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
270 */ |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
271 public Object importSymbol(String globalName) { |
22109
b5eaddcdf86a
Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22104
diff
changeset
|
272 return API.importSymbol(vm, lang, globalName); |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
273 } |
21490
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
274 |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
275 /** |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
276 * Input associated with {@link com.oracle.truffle.api.vm.TruffleVM} this language is being |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
277 * executed in. |
21490
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
278 * |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
279 * @return reader, never <code>null</code> |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
280 */ |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
281 public Reader stdIn() { |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
282 return in; |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
283 } |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
284 |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
285 /** |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
286 * Standard output writer for {@link com.oracle.truffle.api.vm.TruffleVM} this language is |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
287 * being executed in. |
21490
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
288 * |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
289 * @return writer, never <code>null</code> |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
290 */ |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
291 public Writer stdOut() { |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
292 return out; |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
293 } |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
294 |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
295 /** |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
296 * Standard error writer for {@link com.oracle.truffle.api.vm.TruffleVM} this language is |
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
297 * being executed in. |
21490
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
298 * |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
299 * @return writer, never <code>null</code> |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
300 */ |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
301 public Writer stdErr() { |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
302 return err; |
3286fb5fea4a
Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21481
diff
changeset
|
303 } |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
304 } |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
305 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
306 private static final AccessAPI API = new AccessAPI(); |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
307 |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
308 @SuppressWarnings("rawtypes") |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
309 private static final class AccessAPI extends Accessor { |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
310 @Override |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
311 protected Env attachEnv(Object vm, TruffleLanguage<?> language, Writer stdOut, Writer stdErr, Reader stdIn) { |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
312 Env env = new Env(vm, language, stdOut, stdErr, stdIn); |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
313 return env; |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
314 } |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
315 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
316 @Override |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
317 protected Object importSymbol(Object vm, TruffleLanguage<?> queryingLang, String globalName) { |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
318 return super.importSymbol(vm, queryingLang, globalName); |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
319 } |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
320 |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
321 private static final Map<Source, CallTarget> COMPILED = Collections.synchronizedMap(new WeakHashMap<Source, CallTarget>()); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
322 |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
323 @Override |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
324 protected Object eval(TruffleLanguage<?> language, Source source) throws IOException { |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
325 CallTarget target = COMPILED.get(source); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
326 if (target == null) { |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
327 target = language.parse(source, null); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
328 if (target == null) { |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
329 throw new IOException("Parsing has not produced a CallTarget for " + source); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
330 } |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
331 COMPILED.put(source, target); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
332 } |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
333 try { |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
334 return target.call(); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
335 } catch (Exception ex) { |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
336 throw new IOException(ex); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
337 } |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
338 } |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
339 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
340 @Override |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
341 protected Object findExportedSymbol(TruffleLanguage.Env env, String globalName, boolean onlyExplicit) { |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
342 return env.langCtx.findExportedSymbol(globalName, onlyExplicit); |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
343 } |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
344 |
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
345 @Override |
22128
f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22110
diff
changeset
|
346 protected Env findLanguage(Object vm, Class<? extends TruffleLanguage> languageClass) { |
22046
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
347 return super.findLanguage(vm, languageClass); |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
348 } |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
349 |
e7c2d36daf72
TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
350 @Override |
22110
c2cb9f1c8688
Replacing the langClass.newInstance() hack in Debugger with proper way to obtain the language instance
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22109
diff
changeset
|
351 protected TruffleLanguage<?> findLanguage(Env env) { |
c2cb9f1c8688
Replacing the langClass.newInstance() hack in Debugger with proper way to obtain the language instance
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22109
diff
changeset
|
352 return env.lang; |
c2cb9f1c8688
Replacing the langClass.newInstance() hack in Debugger with proper way to obtain the language instance
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22109
diff
changeset
|
353 } |
c2cb9f1c8688
Replacing the langClass.newInstance() hack in Debugger with proper way to obtain the language instance
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22109
diff
changeset
|
354 |
c2cb9f1c8688
Replacing the langClass.newInstance() hack in Debugger with proper way to obtain the language instance
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22109
diff
changeset
|
355 @Override |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
356 protected Object languageGlobal(TruffleLanguage.Env env) { |
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
357 return env.langCtx.getLanguageGlobal(); |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
358 } |
21890
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
359 |
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
360 @Override |
22068
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
361 protected Object findContext(Env env) { |
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
362 return env.langCtx.ctx; |
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
363 } |
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
364 |
fec8f8a61f6c
Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22066
diff
changeset
|
365 @Override |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
366 protected ToolSupportProvider getToolSupport(TruffleLanguage<?> l) { |
21890
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
367 return l.getToolSupport(); |
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
368 } |
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
369 |
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
370 @Override |
22066
78c3d3d8d86e
Clearly separating the TruffleLanguage definition from context used during its execution. TruffleLanguage now has to have public static field INSTANCE and override createContext method.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22049
diff
changeset
|
371 protected DebugSupportProvider getDebugSupport(TruffleLanguage<?> l) { |
21890
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
372 return l.getDebugSupport(); |
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
373 } |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
374 } |
21890
894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21889
diff
changeset
|
375 |
21468
99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff
changeset
|
376 } |