annotate truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/InitializationTest.java @ 22109:b5eaddcdf86a

Calling Env.importSymbol from TruffleLanguage.createContext should be possible
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 26 Aug 2015 14:13:43 +0200
parents truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java@9c8c0937da41
children c2cb9f1c8688
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
1 /*
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
4 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
8 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
13 * accompanied this code).
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
14 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
18 *
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
21 * questions.
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
22 */
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
23 package com.oracle.truffle.api.test.vm;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
24
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
25 import static org.junit.Assert.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
26
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
27 import org.junit.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
28
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
29 import com.oracle.truffle.api.*;
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
30 import com.oracle.truffle.api.TruffleLanguage.Env;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
31 import com.oracle.truffle.api.debug.Breakpoint;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
32 import com.oracle.truffle.api.debug.DebugSupportException;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
33 import com.oracle.truffle.api.debug.DebugSupportProvider;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
34 import com.oracle.truffle.api.debug.Debugger;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
35 import com.oracle.truffle.api.debug.ExecutionEvent;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
36 import com.oracle.truffle.api.frame.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
37 import com.oracle.truffle.api.instrument.*;
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
38 import com.oracle.truffle.api.nodes.*;
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
39 import com.oracle.truffle.api.source.Source;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
40 import com.oracle.truffle.api.vm.EventConsumer;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
41 import com.oracle.truffle.api.vm.TruffleVM;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
42 import java.io.IOException;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
43
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
44 /**
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
45 * Bug report validating test.
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
46 * <p>
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
47 * It has been reported that calling {@link Env#importSymbol(java.lang.String)} in
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
48 * {@link TruffleLanguage TruffleLanguage.createContext(env)} yields a {@link NullPointerException}.
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
49 * <p>
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
50 */
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
51 public class InitializationTest {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
52 @Test
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
53 public void accessProbeForAbstractLanguage() throws IOException {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
54 final Debugger[] arr = {null};
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
55 TruffleVM vm = TruffleVM.newVM().onEvent(new EventConsumer<ExecutionEvent>(ExecutionEvent.class) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
56 @Override
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
57 protected void on(ExecutionEvent event) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
58 arr[0] = event.getDebugger();
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
59 }
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
60 }).build();
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
61
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
62 Source source = Source.fromText("any text", "any text").withMimeType("application/x-abstrlang");
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
63
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
64 vm.eval(source);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
65
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
66 assertNotNull("Debugger found", arr[0]);
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
67
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
68 Debugger d = arr[0];
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
69 Breakpoint b = d.setLineBreakpoint(0, source.createLineLocation(1), true);
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
70 b.setCondition("true");
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
71
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
72 vm.eval(source);
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
73 }
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
74
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
75 private static final class MMRootNode extends RootNode {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
76 @Child ANode node;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
77
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
78 MMRootNode() {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
79 super(AbstractLanguage.class, null, null);
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
80 node = new ANode(42);
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
81 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
82
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
83 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
84 public Object execute(VirtualFrame frame) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
85 return node.constant();
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
86 }
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
87 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
88
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
89 private static final class ANode extends Node {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
90 private final int constant;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
91
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
92 public ANode(int constant) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
93 this.constant = constant;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
94 }
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
95
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
96 Object constant() {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
97 return constant;
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
98 }
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
99
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
100 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
101
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
102 private abstract static class AbstractLanguage extends TruffleLanguage<Object> {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
103 }
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
104
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
105 @TruffleLanguage.Registration(mimeType = "application/x-abstrlang", name = "AbstrLang", version = "0.1")
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
106 public static final class TestLanguage extends AbstractLanguage implements DebugSupportProvider {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
107 public static final TestLanguage INSTANCE = new TestLanguage();
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
108
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
109 @Override
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
110 protected Object createContext(Env env) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
111 assertNull("Not defined symbol", env.importSymbol("unknown"));
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
112 return env;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
113 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
114
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
115 @Override
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
116 protected CallTarget parse(Source code, Node context, String... argumentNames) throws IOException {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
117 return Truffle.getRuntime().createCallTarget(new MMRootNode());
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
118 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
119
20885
e7ece52e1ff3 Truffle/Instrumentation: remove two helper classes not adding enough value.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20106
diff changeset
120 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
121 protected Object findExportedSymbol(Object context, String globalName, boolean onlyExplicit) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
122 return null;
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
123 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
124
20885
e7ece52e1ff3 Truffle/Instrumentation: remove two helper classes not adding enough value.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20106
diff changeset
125 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
126 protected Object getLanguageGlobal(Object context) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
127 throw new UnsupportedOperationException();
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
128 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
129
20885
e7ece52e1ff3 Truffle/Instrumentation: remove two helper classes not adding enough value.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20106
diff changeset
130 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
131 protected boolean isObjectOfLanguage(Object object) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
132 throw new UnsupportedOperationException();
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
133 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
134
20885
e7ece52e1ff3 Truffle/Instrumentation: remove two helper classes not adding enough value.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20106
diff changeset
135 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
136 protected ToolSupportProvider getToolSupport() {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
137 throw new UnsupportedOperationException();
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
138 }
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
139
20885
e7ece52e1ff3 Truffle/Instrumentation: remove two helper classes not adding enough value.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 20106
diff changeset
140 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
141 protected DebugSupportProvider getDebugSupport() {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
142 return this;
19818
907128d02b31 Truffle/Instrumentation: For clients of Instrumentation, replace the TruffleEventListener interface with two: InstrumentListener, and ASTInstrumentListener. The former is simple, completely Truffle-safe (can't affect Truffle execution), and designed for simple tools. The latter is similar to the previous interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 19518
diff changeset
143 }
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
144
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
145 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
146 public Object evalInContext(Source source, Node node, MaterializedFrame mFrame) throws DebugSupportException {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
147 throw new UnsupportedOperationException();
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
148 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
149
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
150 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
151 public AdvancedInstrumentRootFactory createAdvancedInstrumentRootFactory(String expr, AdvancedInstrumentResultListener resultListener) throws DebugSupportException {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
152 throw new UnsupportedOperationException();
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
153 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
154
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
155 @Override
22109
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
156 public Visualizer getVisualizer() {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
157 throw new UnsupportedOperationException();
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
158 }
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
159
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
160 @Override
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
161 public void enableASTProbing(ASTProber astProber) {
b5eaddcdf86a Calling Env.importSymbol from TruffleLanguage.createContext should be possible
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
162 throw new UnsupportedOperationException();
18989
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
163 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
164 }
acd822f17ef5 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff changeset
165 }