annotate truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java @ 22081:ff531952a91c

Making sure IOException from TruffleLanguage.parse method is correctly propagated to TruffleVM.eval caller.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Fri, 14 Aug 2015 13:57:12 +0200
parents a7ca9e9a1d51
children 1e78795e7e6a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
1 /*
21948
f0fe6f0cbccc Chris pointed out the copyright should reflect the year of file's creation.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21890
diff changeset
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
4 *
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
8 *
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
13 * accompanied this code).
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
14 *
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
18 *
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
21 * questions.
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
22 */
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
23 package com.oracle.truffle.api.test.vm;
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
24
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
25 import static org.junit.Assert.*;
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
26
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
27 import java.io.*;
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
28 import java.util.*;
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
29
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
30 import org.junit.*;
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
31
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
32 import com.oracle.truffle.api.*;
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: 22046
diff changeset
33 import com.oracle.truffle.api.TruffleLanguage.Env;
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
34 import com.oracle.truffle.api.debug.*;
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
35 import com.oracle.truffle.api.instrument.*;
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: 22012
diff changeset
36 import com.oracle.truffle.api.nodes.Node;
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: 22012
diff changeset
37 import com.oracle.truffle.api.nodes.RootNode;
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
38 import com.oracle.truffle.api.source.*;
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
39 import com.oracle.truffle.api.vm.*;
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
40
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
41 public class ImplicitExplicitExportTest {
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
42 private TruffleVM vm;
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
43
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
44 @Before
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
45 public void initializeVM() {
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
46 vm = TruffleVM.newVM().build();
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
47 assertTrue("Found " + L1 + " language", vm.getLanguages().containsKey(L1));
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
48 assertTrue("Found " + L2 + " language", vm.getLanguages().containsKey(L2));
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
49 assertTrue("Found " + L3 + " language", vm.getLanguages().containsKey(L3));
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
50 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
51
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
52 @Test
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
53 public void explicitExportFound() throws IOException {
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
54 // @formatter:off
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
55 vm.eval(L1,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
56 "explicit.ahoj=42"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
57 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
58 Object ret = vm.eval(L3,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
59 "return=ahoj"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
60 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
61 // @formatter:on
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
62 assertEquals("42", ret);
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
63 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
64
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
65 @Test
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
66 public void implicitExportFound() throws IOException {
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
67 // @formatter:off
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
68 vm.eval(L1,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
69 "implicit.ahoj=42"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
70 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
71 Object ret = vm.eval(L3,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
72 "return=ahoj"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
73 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
74 // @formatter:on
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
75 assertEquals("42", ret);
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
76 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
77
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
78 @Test
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
79 public void explicitExportPreferred2() throws IOException {
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
80 // @formatter:off
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
81 vm.eval(L1,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
82 "implicit.ahoj=42"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
83 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
84 vm.eval(L2,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
85 "explicit.ahoj=43"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
86 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
87 Object ret = vm.eval(L3,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
88 "return=ahoj"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
89 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
90 // @formatter:on
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
91 assertEquals("Explicit import from L2 is used", "43", ret);
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
92 assertEquals("Global symbol is also 43", "43", vm.findGlobalSymbol("ahoj").invoke(null));
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
93 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
94
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
95 @Test
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
96 public void explicitExportPreferred1() throws IOException {
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
97 // @formatter:off
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
98 vm.eval(L1,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
99 "explicit.ahoj=43"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
100 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
101 vm.eval(L2,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
102 "implicit.ahoj=42"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
103 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
104 Object ret = vm.eval(L3,
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
105 "return=ahoj"
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
106 );
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
107 // @formatter:on
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
108 assertEquals("Explicit import from L2 is used", "43", ret);
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
109 assertEquals("Global symbol is also 43", "43", vm.findGlobalSymbol("ahoj").invoke(null));
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
110 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
111
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: 22046
diff changeset
112 private static final class 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: 22046
diff changeset
113 final Map<String, String> explicit = new HashMap<>();
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: 22046
diff changeset
114 final Map<String, String> implicit = new HashMap<>();
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: 22046
diff changeset
115 final 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: 22046
diff changeset
116
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: 22046
diff changeset
117 public Ctx(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: 22046
diff changeset
118 this.env = env;
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
119 }
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: 22046
diff changeset
120 }
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
121
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: 22046
diff changeset
122 private abstract static class AbstractExportImportLanguage extends TruffleLanguage<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: 22046
diff changeset
123
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: 22046
diff changeset
124 @Override
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: 22046
diff changeset
125 protected Ctx createContext(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: 22046
diff changeset
126 return new Ctx(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: 22046
diff changeset
127 }
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
128
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
129 @Override
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: 22012
diff changeset
130 protected CallTarget parse(Source code, Node context, String... argumentNames) throws IOException {
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 if (code.getCode().startsWith("parse=")) {
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 throw new IOException(code.getCode().substring(6));
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
133 }
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: 22046
diff changeset
134 return new ValueCallTarget(code, this);
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
135 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
136
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
137 @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: 22046
diff changeset
138 protected Object findExportedSymbol(Ctx context, 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: 22046
diff changeset
139 if (context.explicit.containsKey(globalName)) {
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: 22046
diff changeset
140 return context.explicit.get(globalName);
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
141 }
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: 22046
diff changeset
142 if (!onlyExplicit && context.implicit.containsKey(globalName)) {
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: 22046
diff changeset
143 return context.implicit.get(globalName);
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
144 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
145 return null;
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
146 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
147
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
148 @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: 22046
diff changeset
149 protected Object getLanguageGlobal(Ctx context) {
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
150 return null;
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
151 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
152
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
153 @Override
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
154 protected boolean isObjectOfLanguage(Object object) {
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
155 return false;
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
156 }
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
157
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
158 @Override
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
159 protected 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
160 return null;
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
161 }
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
162
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
163 @Override
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
164 protected 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
165 return null;
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
166 }
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: 22012
diff changeset
167
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: 22012
diff changeset
168 private Object importExport(Source code) {
22068
fec8f8a61f6c Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
169 final Node node = createFindContextNode();
22070
a7ca9e9a1d51 Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22068
diff changeset
170 Ctx ctx = findContext(node);
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: 22012
diff changeset
171 Properties p = new Properties();
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: 22012
diff changeset
172 try (Reader r = code.getReader()) {
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: 22012
diff changeset
173 p.load(r);
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: 22012
diff changeset
174 } catch (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: 22012
diff changeset
175 throw new IllegalStateException(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: 22012
diff changeset
176 }
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: 22012
diff changeset
177 Enumeration<Object> en = p.keys();
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: 22012
diff changeset
178 while (en.hasMoreElements()) {
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: 22012
diff changeset
179 Object n = en.nextElement();
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: 22012
diff changeset
180 if (n instanceof String) {
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: 22012
diff changeset
181 String k = (String) n;
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: 22012
diff changeset
182 if (k.startsWith("explicit.")) {
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: 22046
diff changeset
183 ctx.explicit.put(k.substring(9), p.getProperty(k));
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: 22012
diff changeset
184 }
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: 22012
diff changeset
185 if (k.startsWith("implicit.")) {
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: 22046
diff changeset
186 ctx.implicit.put(k.substring(9), p.getProperty(k));
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: 22012
diff changeset
187 }
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: 22012
diff changeset
188 if (k.equals("return")) {
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: 22046
diff changeset
189 return ctx.env.importSymbol(p.getProperty(k));
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: 22012
diff changeset
190 }
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: 22012
diff changeset
191 }
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: 22012
diff changeset
192 }
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: 22012
diff changeset
193 return 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: 22012
diff changeset
194 }
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: 22012
diff changeset
195 }
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: 22012
diff changeset
196
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: 22012
diff changeset
197 private static final class ValueCallTarget implements RootCallTarget {
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: 22012
diff changeset
198 private final Source code;
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: 22046
diff changeset
199 private final AbstractExportImportLanguage 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: 22012
diff changeset
200
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: 22046
diff changeset
201 private ValueCallTarget(Source code, AbstractExportImportLanguage 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: 22012
diff changeset
202 this.code = code;
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: 22012
diff changeset
203 this.language = language;
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: 22012
diff changeset
204 }
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: 22012
diff changeset
205
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: 22012
diff changeset
206 @Override
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: 22012
diff changeset
207 public RootNode getRootNode() {
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: 22012
diff changeset
208 throw new UnsupportedOperationException();
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: 22012
diff changeset
209 }
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: 22012
diff changeset
210
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: 22012
diff changeset
211 @Override
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: 22012
diff changeset
212 public Object call(Object... arguments) {
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: 22046
diff changeset
213 return language.importExport(code);
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: 22012
diff changeset
214 }
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
215 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
216
22012
09531c471176 Making sure the accessor can really find the TruffleLanguage instance by its class
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
217 static final String L1 = "application/x-test-import-export-1";
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
218 private static final String L2 = "application/x-test-import-export-2";
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
219 private static final String L3 = "application/x-test-import-export-3";
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
220
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
221 @TruffleLanguage.Registration(mimeType = L1, name = "ImportExport1", version = "0")
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
222 public static final class ExportImportLanguage1 extends AbstractExportImportLanguage {
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: 22046
diff changeset
223 public static final AbstractExportImportLanguage INSTANCE = new ExportImportLanguage1();
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: 22046
diff changeset
224
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: 22046
diff changeset
225 public ExportImportLanguage1() {
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
226 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
227 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
228
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
229 @TruffleLanguage.Registration(mimeType = L2, name = "ImportExport2", version = "0")
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
230 public static final class ExportImportLanguage2 extends AbstractExportImportLanguage {
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: 22046
diff changeset
231 public static final AbstractExportImportLanguage INSTANCE = new ExportImportLanguage2();
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: 22046
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: 22046
diff changeset
233 public ExportImportLanguage2() {
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
234 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
235 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
236
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
237 @TruffleLanguage.Registration(mimeType = L3, name = "ImportExport3", version = "0")
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
238 public static final class ExportImportLanguage3 extends AbstractExportImportLanguage {
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: 22046
diff changeset
239 public static final AbstractExportImportLanguage INSTANCE = new ExportImportLanguage3();
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: 22046
diff changeset
240
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: 22046
diff changeset
241 private ExportImportLanguage3() {
21716
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
242 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
243 }
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
244
2f9e4d984d16 Give languages a chance to do implicit exports. Prefer explicit exports over implicit ones.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
245 }