annotate truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java @ 22219:1c0f490984d5

Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Wed, 16 Sep 2015 15:36:22 -0700
parents dc83cc1f94f2 d3bdaa91bc82
children 20380d1d41f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
1 /*
18990
d1c1cd2530d7 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18962
diff changeset
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
4 *
21997
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
5 * The Universal Permissive License (UPL), Version 1.0
22065
503529c65456 Remove trailing whitespace from UPL license
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22049
diff changeset
6 *
21997
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
7 * Subject to the condition set forth below, permission is hereby granted to any
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
8 * person obtaining a copy of this software, associated documentation and/or
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
9 * data (collectively the "Software"), free of charge and under any and all
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
10 * copyright rights in the Software, and any and all patent rights owned or
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
11 * freely licensable by each licensor hereunder covering either (i) the
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
12 * unmodified Software as contributed to or provided by such licensor, or (ii)
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
13 * the Larger Works (as defined below), to deal in both
22065
503529c65456 Remove trailing whitespace from UPL license
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22049
diff changeset
14 *
21997
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
15 * (a) the Software, and
22065
503529c65456 Remove trailing whitespace from UPL license
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22049
diff changeset
16 *
21997
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
17 * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
18 * one is included with the Software each a "Larger Work" to which the Software
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
19 * is contributed by such licensors),
22065
503529c65456 Remove trailing whitespace from UPL license
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22049
diff changeset
20 *
21997
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
21 * without restriction, including without limitation the rights to copy, create
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
22 * derivative works of, display, perform, and distribute the Software and make,
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
23 * use, sell, offer for sale, import, export, have made, and have sold the
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
24 * Software and the Larger Work(s), and to sublicense the foregoing rights on
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
25 * either these or other terms.
22065
503529c65456 Remove trailing whitespace from UPL license
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22049
diff changeset
26 *
21997
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
27 * This license is subject to the following condition:
22065
503529c65456 Remove trailing whitespace from UPL license
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22049
diff changeset
28 *
21997
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
29 * The above copyright notice and either this complete permission notice or at a
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
30 * minimum a reference to the UPL must be included in all copies or substantial
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
31 * portions of the Software.
22065
503529c65456 Remove trailing whitespace from UPL license
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22049
diff changeset
32 *
21997
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
33 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
34 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
35 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
36 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
37 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
38 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
c07e64ecb528 Update SL copyright headers to use UPL
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21987
diff changeset
39 * SOFTWARE.
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
40 */
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
41 package com.oracle.truffle.sl;
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
42
22126
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
43 import java.io.BufferedReader;
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
44 import java.io.IOException;
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
45 import java.io.InputStreamReader;
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
46 import java.io.PrintWriter;
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
47 import java.math.BigInteger;
22104
cf19259edf87 TruffleVM.eval and Source.withMimeType
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22070
diff changeset
48 import java.nio.file.Path;
22126
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
49 import java.util.Collections;
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
50 import java.util.List;
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
51
22215
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
52 import com.oracle.truffle.api.CallTarget;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
53 import com.oracle.truffle.api.RootCallTarget;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
54 import com.oracle.truffle.api.Truffle;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
55 import com.oracle.truffle.api.TruffleLanguage;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
56 import com.oracle.truffle.api.debug.DebugSupportProvider;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
57 import com.oracle.truffle.api.dsl.NodeFactory;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
58 import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
59 import com.oracle.truffle.api.frame.MaterializedFrame;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
60 import com.oracle.truffle.api.instrument.ASTProber;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
61 import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
62 import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
63 import com.oracle.truffle.api.instrument.ToolSupportProvider;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
64 import com.oracle.truffle.api.instrument.Visualizer;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
65 import com.oracle.truffle.api.nodes.GraphPrintVisitor;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
66 import com.oracle.truffle.api.nodes.Node;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
67 import com.oracle.truffle.api.nodes.NodeInfo;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
68 import com.oracle.truffle.api.nodes.NodeUtil;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
69 import com.oracle.truffle.api.source.Source;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
70 import com.oracle.truffle.api.source.SourceSection;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
71 import com.oracle.truffle.api.vm.TruffleVM;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
72 import com.oracle.truffle.api.vm.TruffleVM.Symbol;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
73 import com.oracle.truffle.sl.builtins.SLBuiltinNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
74 import com.oracle.truffle.sl.builtins.SLDefineFunctionBuiltin;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
75 import com.oracle.truffle.sl.builtins.SLNanoTimeBuiltin;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
76 import com.oracle.truffle.sl.builtins.SLPrintlnBuiltin;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
77 import com.oracle.truffle.sl.builtins.SLReadlnBuiltin;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
78 import com.oracle.truffle.sl.nodes.SLRootNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
79 import com.oracle.truffle.sl.nodes.SLTypes;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
80 import com.oracle.truffle.sl.nodes.call.SLDispatchNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
81 import com.oracle.truffle.sl.nodes.call.SLInvokeNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
82 import com.oracle.truffle.sl.nodes.call.SLUndefinedFunctionException;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
83 import com.oracle.truffle.sl.nodes.controlflow.SLBlockNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
84 import com.oracle.truffle.sl.nodes.controlflow.SLBreakNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
85 import com.oracle.truffle.sl.nodes.controlflow.SLContinueNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
86 import com.oracle.truffle.sl.nodes.controlflow.SLIfNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
87 import com.oracle.truffle.sl.nodes.controlflow.SLReturnNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
88 import com.oracle.truffle.sl.nodes.controlflow.SLWhileNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
89 import com.oracle.truffle.sl.nodes.expression.SLAddNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
90 import com.oracle.truffle.sl.nodes.expression.SLBigIntegerLiteralNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
91 import com.oracle.truffle.sl.nodes.expression.SLDivNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
92 import com.oracle.truffle.sl.nodes.expression.SLEqualNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
93 import com.oracle.truffle.sl.nodes.expression.SLFunctionLiteralNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
94 import com.oracle.truffle.sl.nodes.expression.SLLessOrEqualNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
95 import com.oracle.truffle.sl.nodes.expression.SLLessThanNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
96 import com.oracle.truffle.sl.nodes.expression.SLLogicalAndNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
97 import com.oracle.truffle.sl.nodes.expression.SLLogicalOrNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
98 import com.oracle.truffle.sl.nodes.expression.SLMulNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
99 import com.oracle.truffle.sl.nodes.expression.SLStringLiteralNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
100 import com.oracle.truffle.sl.nodes.expression.SLSubNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
101 import com.oracle.truffle.sl.nodes.instrument.SLDefaultVisualizer;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
102 import com.oracle.truffle.sl.nodes.instrument.SLStandardASTProber;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
103 import com.oracle.truffle.sl.nodes.local.SLReadLocalVariableNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
104 import com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNode;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
105 import com.oracle.truffle.sl.parser.Parser;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
106 import com.oracle.truffle.sl.parser.SLNodeFactory;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
107 import com.oracle.truffle.sl.parser.Scanner;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
108 import com.oracle.truffle.sl.runtime.SLContext;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
109 import com.oracle.truffle.sl.runtime.SLFunction;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
110 import com.oracle.truffle.sl.runtime.SLFunctionRegistry;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
111 import com.oracle.truffle.sl.runtime.SLNull;
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
112
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
113 /**
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
114 * SL is a simple language to demonstrate and showcase features of Truffle. The implementation is as
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
115 * simple and clean as possible in order to help understanding the ideas and concepts of Truffle.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
116 * The language has first class functions, but no object model.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
117 * <p>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
118 * SL is dynamically typed, i.e., there are no type names specified by the programmer. SL is
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
119 * strongly typed, i.e., there is no automatic conversion between types. If an operation is not
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
120 * available for the types encountered at run time, a type error is reported and execution is
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
121 * stopped. For example, {@code 4 - "2"} results in a type error because subtraction is only defined
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
122 * for numbers.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13943
diff changeset
123 *
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
124 * <p>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
125 * <b>Types:</b>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
126 * <ul>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
127 * <li>Number: arbitrary precision integer numbers. The implementation uses the Java primitive type
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
128 * {@code long} to represent numbers that fit into the 64 bit range, and {@link BigInteger} for
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
129 * numbers that exceed the range. Using a primitive type such as {@code long} is crucial for
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
130 * performance.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
131 * <li>Boolean: implemented as the Java primitive type {@code boolean}.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
132 * <li>String: implemented as the Java standard type {@link String}.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
133 * <li>Function: implementation type {@link SLFunction}.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
134 * <li>Null (with only one value {@code null}): implemented as the singleton
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
135 * {@link SLNull#SINGLETON}.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
136 * </ul>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
137 * The class {@link SLTypes} lists these types for the Truffle DSL, i.e., for type-specialized
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
138 * operations that are specified using Truffle DSL annotations.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13943
diff changeset
139 *
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
140 * <p>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
141 * <b>Language concepts:</b>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
142 * <ul>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
143 * <li>Literals for {@link SLBigIntegerLiteralNode numbers} , {@link SLStringLiteralNode strings},
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
144 * and {@link SLFunctionLiteralNode functions}.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
145 * <li>Basic arithmetic, logical, and comparison operations: {@link SLAddNode +}, {@link SLSubNode
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
146 * -}, {@link SLMulNode *}, {@link SLDivNode /}, {@link SLLogicalAndNode logical and},
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13943
diff changeset
147 * {@link SLLogicalOrNode logical or}, {@link SLEqualNode ==}, !=, {@link SLLessThanNode &lt;},
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13943
diff changeset
148 * {@link SLLessOrEqualNode &le;}, &gt;, &ge;.
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
149 * <li>Local variables: local variables must be defined (via a {@link SLWriteLocalVariableNode
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
150 * write}) before they can be used (by a {@link SLReadLocalVariableNode read}). Local variables are
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
151 * not visible outside of the block where they were first defined.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
152 * <li>Basic control flow statements: {@link SLBlockNode blocks}, {@link SLIfNode if},
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
153 * {@link SLWhileNode while} with {@link SLBreakNode break} and {@link SLContinueNode continue},
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
154 * {@link SLReturnNode return}.
13943
89ac75425681 SL: small cleanups
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13882
diff changeset
155 * <li>Function calls: {@link SLInvokeNode invocations} are efficiently implemented with
20956
2170de9acab0 SL: use DSL for call dispatches.
Christian Humer <christian.humer@gmail.com>
parents: 18990
diff changeset
156 * {@link SLDispatchNode polymorphic inline caches}.
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
157 * </ul>
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13943
diff changeset
158 *
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
159 * <p>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
160 * <b>Syntax and parsing:</b><br>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
161 * The syntax is described as an attributed grammar. The {@link Parser} and {@link Scanner} are
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
162 * automatically generated by the parser generator Coco/R (available from <a
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
163 * href="http://ssw.jku.at/coco/">http://ssw.jku.at/coco/</a>). The grammar contains semantic
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
164 * actions that build the AST for a method. To keep these semantic actions short, they are mostly
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
165 * calls to the {@link SLNodeFactory} that performs the actual node creation. All functions found in
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
166 * the SL source are added to the {@link SLFunctionRegistry}, which is accessible from the
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
167 * {@link SLContext}.
14906
f3a5036cc13c javadoc fixes
Bernhard Urban <bernhard.urban@jku.at>
parents: 13943
diff changeset
168 *
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
169 * <p>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
170 * <b>Builtin functions:</b><br>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
171 * Library functions that are available to every SL source without prior definition are called
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
172 * builtin functions. They are added to the {@link SLFunctionRegistry} when the {@link SLContext} is
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
173 * created. There current builtin functions are
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
174 * <ul>
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
175 * <li>{@link SLReadlnBuiltin readln}: Read a String from the {@link SLContext#getInput() standard
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
176 * input}.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
177 * <li>{@link SLPrintlnBuiltin println}: Write a value to the {@link SLContext#getOutput() standard
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
178 * output}.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
179 * <li>{@link SLNanoTimeBuiltin nanoTime}: Returns the value of a high-resolution time, in
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
180 * nanoseconds.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
181 * <li>{@link SLDefineFunctionBuiltin defineFunction}: Parses the functions provided as a String
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
182 * argument and adds them to the function registry. Functions that are already defined are replaced
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
183 * with the new version.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
184 * </ul>
22126
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
185 */
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
186
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
187 /*
22214
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
188 *
22126
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
189 * <p> <b>Tools:</b><br> The use of some of Truffle's support for developer tools (based on the
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
190 * Truffle Instrumentation Framework) are demonstrated in this file, for example: <ul> <li>a
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
191 * {@linkplain NodeExecCounter counter for node executions}, tabulated by node type; and</li> <li>a
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
192 * simple {@linkplain CoverageTracker code coverage engine}.</li> </ul> In each case, the tool is
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
193 * enabled if a corresponding local boolean variable in this file is set to {@code true}. Results
7d4e42092f39 Removing unused fields. Plus applying formatter which is able to make any comment undreadable.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22125
diff changeset
194 * are printed at the end of the execution using each tool's <em>default printer</em>.
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
195 */
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
196 @TruffleLanguage.Registration(name = "SL", version = "0.5", mimeType = "application/x-sl")
22067
e206ebd965f2 checkstyle lint
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22066
diff changeset
197 public final class SLLanguage extends TruffleLanguage<SLContext> {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
198 private static List<NodeFactory<? extends SLBuiltinNode>> builtins = Collections.emptyList();
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
199 private static Visualizer visualizer = new SLDefaultVisualizer();
22215
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
200 private ASTProber astProber = new SLStandardASTProber();
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
201
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: 22065
diff changeset
202 private SLLanguage() {
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: 22065
diff changeset
203 }
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: 22065
diff changeset
204
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: 22065
diff changeset
205 public static final SLLanguage INSTANCE = new SLLanguage();
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: 22065
diff changeset
206
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: 22065
diff changeset
207 @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: 22065
diff changeset
208 protected SLContext 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: 22065
diff changeset
209 SLContext context = new SLContext(this, new BufferedReader(env.stdIn()), new PrintWriter(env.stdOut(), true));
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
210 for (NodeFactory<? extends SLBuiltinNode> builtin : builtins) {
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: 22003
diff changeset
211 context.installBuiltin(builtin, true);
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
212 }
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: 22065
diff changeset
213 return context;
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
214 }
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
215
21686
5fa7935c5de3 Truffle/Instrumentation: fix the small tool demonstration in SL
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21649
diff changeset
216 /* Small tools that can be installed for demonstration */
22125
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
217 // private static NodeExecCounter nodeExecCounter = null;
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
218 // private static NodeExecCounter statementExecCounter = null;
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
219 // private static CoverageTracker coverageTracker = null;
21686
5fa7935c5de3 Truffle/Instrumentation: fix the small tool demonstration in SL
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21649
diff changeset
220
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
221 /**
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
222 * The main entry point. Use the mx command "mx sl" to run it with the correct class path setup.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
223 */
13836
64c77f0577bb More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13821
diff changeset
224 public static void main(String[] args) throws IOException {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
225 TruffleVM vm = TruffleVM.newVM().build();
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
226 assert vm.getLanguages().containsKey("application/x-sl");
13836
64c77f0577bb More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13821
diff changeset
227
21686
5fa7935c5de3 Truffle/Instrumentation: fix the small tool demonstration in SL
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21649
diff changeset
228 setupToolDemos();
5fa7935c5de3 Truffle/Instrumentation: fix the small tool demonstration in SL
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21649
diff changeset
229
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
230 int repeats = 1;
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
231 if (args.length >= 2) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
232 repeats = Integer.parseInt(args[1]);
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
233 }
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8959
diff changeset
234
22104
cf19259edf87 TruffleVM.eval and Source.withMimeType
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22070
diff changeset
235 Source source;
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
236 if (args.length == 0) {
22104
cf19259edf87 TruffleVM.eval and Source.withMimeType
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22070
diff changeset
237 source = Source.fromReader(new InputStreamReader(System.in), "<stdin>").withMimeType("application/x-sl");
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
238 } else {
22104
cf19259edf87 TruffleVM.eval and Source.withMimeType
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22070
diff changeset
239 source = Source.fromFileName(args[0]);
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
240 }
22104
cf19259edf87 TruffleVM.eval and Source.withMimeType
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22070
diff changeset
241 vm.eval(source);
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
242 Symbol main = vm.findGlobalSymbol("main");
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
243 if (main == null) {
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
244 throw new SLException("No function main() defined in SL source file.");
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
245 }
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
246 while (repeats-- > 0) {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
247 main.invoke(null);
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
248 }
21686
5fa7935c5de3 Truffle/Instrumentation: fix the small tool demonstration in SL
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21649
diff changeset
249 reportToolDemos();
13455
69d2e4baa215 Truffle: new infrastructure related to instrumentation, and in particular debugging: support for managing Source objects; framework for generalized "instrumentation proxy nodes" (to be inserted into ASTs with no runtime cost when inactive), and "probes" (which can be attached to proxy nodes to receive event notification); a rudimentary interface and abstract implementation for a "debug manager" (mostly a placeholder at this point); and the beginning of a language-agnostic ExecutionContext interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 12752
diff changeset
250 }
69d2e4baa215 Truffle: new infrastructure related to instrumentation, and in particular debugging: support for managing Source objects; framework for generalized "instrumentation proxy nodes" (to be inserted into ASTs with no runtime cost when inactive), and "probes" (which can be attached to proxy nodes to receive event notification); a rudimentary interface and abstract implementation for a "debug manager" (mostly a placeholder at this point); and the beginning of a language-agnostic ExecutionContext interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 12752
diff changeset
251
21649
1c76a5662753 Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21578
diff changeset
252 /**
1c76a5662753 Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21578
diff changeset
253 * Temporary method during API evolution, supports debugger integration.
1c76a5662753 Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21578
diff changeset
254 */
22214
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
255 @Deprecated
21573
ffdd2ec86f42 Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
256 public static void run(Source source) throws IOException {
ffdd2ec86f42 Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
257 TruffleVM vm = TruffleVM.newVM().build();
ffdd2ec86f42 Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
258 assert vm.getLanguages().containsKey("application/x-sl");
22104
cf19259edf87 TruffleVM.eval and Source.withMimeType
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22070
diff changeset
259 vm.eval(source);
21573
ffdd2ec86f42 Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
260 Symbol main = vm.findGlobalSymbol("main");
ffdd2ec86f42 Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
261 if (main == null) {
ffdd2ec86f42 Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
262 throw new SLException("No function main() defined in SL source file.");
ffdd2ec86f42 Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
263 }
ffdd2ec86f42 Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21570
diff changeset
264 main.invoke(null);
13455
69d2e4baa215 Truffle: new infrastructure related to instrumentation, and in particular debugging: support for managing Source objects; framework for generalized "instrumentation proxy nodes" (to be inserted into ASTs with no runtime cost when inactive), and "probes" (which can be attached to proxy nodes to receive event notification); a rudimentary interface and abstract implementation for a "debug manager" (mostly a placeholder at this point); and the beginning of a language-agnostic ExecutionContext interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 12752
diff changeset
265 }
69d2e4baa215 Truffle: new infrastructure related to instrumentation, and in particular debugging: support for managing Source objects; framework for generalized "instrumentation proxy nodes" (to be inserted into ASTs with no runtime cost when inactive), and "probes" (which can be attached to proxy nodes to receive event notification); a rudimentary interface and abstract implementation for a "debug manager" (mostly a placeholder at this point); and the beginning of a language-agnostic ExecutionContext interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 12752
diff changeset
266
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
267 /**
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
268 * Parse and run the specified SL source. Factored out in a separate method so that it can also
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
269 * be used by the unit test harness.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
270 */
22104
cf19259edf87 TruffleVM.eval and Source.withMimeType
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22070
diff changeset
271 public static long run(TruffleVM context, Path path, PrintWriter logOutput, PrintWriter out, int repeats, List<NodeFactory<? extends SLBuiltinNode>> currentBuiltins) throws IOException {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
272 builtins = currentBuiltins;
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
273
13761
7c418666c6c9 Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13455
diff changeset
274 if (logOutput != null) {
7c418666c6c9 Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13455
diff changeset
275 logOutput.println("== running on " + Truffle.getRuntime().getName());
16512
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
276 // logOutput.println("Source = " + source.getCode());
13455
69d2e4baa215 Truffle: new infrastructure related to instrumentation, and in particular debugging: support for managing Source objects; framework for generalized "instrumentation proxy nodes" (to be inserted into ASTs with no runtime cost when inactive), and "probes" (which can be attached to proxy nodes to receive event notification); a rudimentary interface and abstract implementation for a "debug manager" (mostly a placeholder at this point); and the beginning of a language-agnostic ExecutionContext interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 12752
diff changeset
277 }
69d2e4baa215 Truffle: new infrastructure related to instrumentation, and in particular debugging: support for managing Source objects; framework for generalized "instrumentation proxy nodes" (to be inserted into ASTs with no runtime cost when inactive), and "probes" (which can be attached to proxy nodes to receive event notification); a rudimentary interface and abstract implementation for a "debug manager" (mostly a placeholder at this point); and the beginning of a language-agnostic ExecutionContext interface.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 12752
diff changeset
278
22104
cf19259edf87 TruffleVM.eval and Source.withMimeType
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22070
diff changeset
279 Source src = Source.fromFileName(path.toString());
18485
e3c95cbbb50c Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16880
diff changeset
280 /* Parse the SL source file. */
22121
d045a505c2b3 Asynchronous TruffleVM can be created by providing own Executor when configuring the TruffleVM.Builder
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22105
diff changeset
281 Object result = context.eval(src.withMimeType("application/x-sl")).get();
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
282 if (result != null) {
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
283 out.println(result);
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
284 }
15891
09ac9ac9c4fc Truffle: SourceManager renamed to SourceFactory
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 14991
diff changeset
285
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
286 /* Lookup our main entry point, which is per definition always named "main". */
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
287 Symbol main = context.findGlobalSymbol("main");
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
288 if (main == null) {
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
289 throw new SLException("No function main() defined in SL source file.");
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
290 }
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
291
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
292 /* Change to true if you want to see the AST on the console. */
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
293 boolean printASTToLog = false;
16512
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
294 /* Change to true if you want to see source attribution for the AST to the console */
16687
7c8ddb4233cd SL/SourceAttribution: restore some attribution fixes that were lost in a tussle with hg; turn off tracing code in SL tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16675
diff changeset
295 boolean printSourceAttributionToLog = false;
13862
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
296 /* Change to dump the AST to IGV over the network. */
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
297 boolean dumpASTToIGV = false;
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
298
22047
227ed03852de Findbugs complains about the LAST static variable assignment. Remove, as it is not used anyway.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22046
diff changeset
299 printScript("before execution", null, logOutput, printASTToLog, printSourceAttributionToLog, dumpASTToIGV);
18962
cfb85e1f4ca5 Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18762
diff changeset
300 long totalRuntime = 0;
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
301 try {
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
302 for (int i = 0; i < repeats; i++) {
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
303 long start = System.nanoTime();
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
304 /* Call the main entry point, without any arguments. */
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
305 try {
22121
d045a505c2b3 Asynchronous TruffleVM can be created by providing own Executor when configuring the TruffleVM.Builder
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22105
diff changeset
306 result = main.invoke(null).get();
21689
ed234a3178af Behavior of null-like values is now part of the TCK
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21686
diff changeset
307 if (result != null) {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
308 out.println(result);
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
309 }
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
310 } catch (UnsupportedSpecializationException ex) {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
311 out.println(formatTypeError(ex));
21493
99e3f4c5c853 SL: handle undefined functions gracefully.
Christian Humer <christian.humer@gmail.com>
parents: 21490
diff changeset
312 } catch (SLUndefinedFunctionException ex) {
99e3f4c5c853 SL: handle undefined functions gracefully.
Christian Humer <christian.humer@gmail.com>
parents: 21490
diff changeset
313 out.println(String.format("Undefined function: %s", ex.getFunctionName()));
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
314 }
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
315 long end = System.nanoTime();
18962
cfb85e1f4ca5 Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18762
diff changeset
316 totalRuntime += end - start;
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
317
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
318 if (logOutput != null && repeats > 1) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
319 logOutput.println("== iteration " + (i + 1) + ": " + ((end - start) / 1000000) + " ms");
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
320 }
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
321 }
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
322
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
323 } finally {
22047
227ed03852de Findbugs complains about the LAST static variable assignment. Remove, as it is not used anyway.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22046
diff changeset
324 printScript("after execution", null, logOutput, printASTToLog, printSourceAttributionToLog, dumpASTToIGV);
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
325 }
18962
cfb85e1f4ca5 Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18762
diff changeset
326 return totalRuntime;
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
327 }
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8959
diff changeset
328
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
329 /**
13882
afd6fa5e8229 SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13862
diff changeset
330 * When dumpASTToIGV is true: dumps the AST of all functions to the IGV visualizer, via a socket
afd6fa5e8229 SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13862
diff changeset
331 * connection. IGV can be started with the mx command "mx igv".
afd6fa5e8229 SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13862
diff changeset
332 * <p>
afd6fa5e8229 SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13862
diff changeset
333 * When printASTToLog is true: prints the ASTs to the console.
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
334 */
21469
286aef83a9a7 Replacing PrintStream with PrintWriter in the simple language
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21468
diff changeset
335 private static void printScript(String groupName, SLContext context, PrintWriter logOutput, boolean printASTToLog, boolean printSourceAttributionToLog, boolean dumpASTToIGV) {
13862
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
336 if (dumpASTToIGV) {
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
337 GraphPrintVisitor graphPrinter = new GraphPrintVisitor();
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
338 graphPrinter.beginGroup(groupName);
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
339 for (SLFunction function : context.getFunctionRegistry().getFunctions()) {
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
340 RootCallTarget callTarget = function.getCallTarget();
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
341 if (callTarget != null) {
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
342 graphPrinter.beginGraph(function.toString()).visit(callTarget.getRootNode());
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
343 }
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
344 }
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
345 graphPrinter.printToNetwork(true);
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
346 }
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
347 if (printASTToLog && logOutput != null) {
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
348 for (SLFunction function : context.getFunctionRegistry().getFunctions()) {
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
349 RootCallTarget callTarget = function.getCallTarget();
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
350 if (callTarget != null) {
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
351 logOutput.println("=== " + function);
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
352 NodeUtil.printTree(logOutput, callTarget.getRootNode());
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
353 }
13761
7c418666c6c9 Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13455
diff changeset
354 }
7c418666c6c9 Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13455
diff changeset
355 }
16512
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
356 if (printSourceAttributionToLog && logOutput != null) {
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
357 for (SLFunction function : context.getFunctionRegistry().getFunctions()) {
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
358 RootCallTarget callTarget = function.getCallTarget();
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
359 if (callTarget != null) {
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
360 logOutput.println("=== " + function);
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
361 NodeUtil.printSourceAttributionTree(logOutput, callTarget.getRootNode());
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
362 }
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
363 }
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
364 }
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
365 }
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
366
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
367 /**
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
368 * Provides a user-readable message for run-time type errors. SL is strongly typed, i.e., there
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
369 * are no automatic type conversions of values. Therefore, Truffle does the type checking for
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
370 * us: if no matching node specialization for the actual values is found, then we have a type
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
371 * error. Specialized nodes use the {@link UnsupportedSpecializationException} to report that no
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
372 * specialization was found. We therefore just have to convert the information encapsulated in
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
373 * this exception in a user-readable form.
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
374 */
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
375 private static String formatTypeError(UnsupportedSpecializationException ex) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
376 StringBuilder result = new StringBuilder();
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
377 result.append("Type error");
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
378 if (ex.getNode() != null && ex.getNode().getSourceSection() != null) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
379 SourceSection ss = ex.getNode().getSourceSection();
21987
b2d1c8ff592a Less classes in the source API package. Merging interfaces and their only implementation into final classes. Hiding NullSourceSection behind factory method. Using JDK's standard CharsetDecoder instead of proprietary BytesDecoder.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21986
diff changeset
380 if (ss != null && ss.getSource() != null) {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
381 result.append(" at ").append(ss.getSource().getShortName()).append(" line ").append(ss.getStartLine()).append(" col ").append(ss.getStartColumn());
16512
abe7128ca473 SL: upgrade source attribution
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 16067
diff changeset
382 }
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
383 }
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
384 result.append(": operation");
18762
0ef23ff7d5a1 SL: make lookup of NodeInfo annotation more rebust.
Christian Humer <christian.humer@gmail.com>
parents: 18485
diff changeset
385 if (ex.getNode() != null) {
0ef23ff7d5a1 SL: make lookup of NodeInfo annotation more rebust.
Christian Humer <christian.humer@gmail.com>
parents: 18485
diff changeset
386 NodeInfo nodeInfo = SLContext.lookupNodeInfo(ex.getNode().getClass());
0ef23ff7d5a1 SL: make lookup of NodeInfo annotation more rebust.
Christian Humer <christian.humer@gmail.com>
parents: 18485
diff changeset
387 if (nodeInfo != null) {
0ef23ff7d5a1 SL: make lookup of NodeInfo annotation more rebust.
Christian Humer <christian.humer@gmail.com>
parents: 18485
diff changeset
388 result.append(" \"").append(nodeInfo.shortName()).append("\"");
0ef23ff7d5a1 SL: make lookup of NodeInfo annotation more rebust.
Christian Humer <christian.humer@gmail.com>
parents: 18485
diff changeset
389 }
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
390 }
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
391 result.append(" not defined for");
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
392
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
393 String sep = " ";
13862
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
394 for (int i = 0; i < ex.getSuppliedValues().length; i++) {
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
395 Object value = ex.getSuppliedValues()[i];
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
396 Node node = ex.getSuppliedNodes()[i];
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
397 if (node != null) {
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
398 result.append(sep);
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
399 sep = ", ";
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
400
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
401 if (value instanceof Long || value instanceof BigInteger) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
402 result.append("Number ").append(value);
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
403 } else if (value instanceof Boolean) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
404 result.append("Boolean ").append(value);
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
405 } else if (value instanceof String) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
406 result.append("String \"").append(value).append("\"");
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
407 } else if (value instanceof SLFunction) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
408 result.append("Function ").append(value);
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
409 } else if (value == SLNull.SINGLETON) {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
410 result.append("NULL");
13862
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
411 } else if (value == null) {
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
412 // value is not evaluated because of short circuit evaluation
f9b934e1e172 SL: Make SL use the new UnsupportedSpecializationException#getSuppliedNodes() for error messages; Disabled dumping by default to IGV.
Christian Humer <christian.humer@gmail.com>
parents: 13836
diff changeset
413 result.append("ANY");
13821
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
414 } else {
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
415 result.append(value);
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
416 }
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
417 }
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
418 }
b16ec83edc73 Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13761
diff changeset
419 return result.toString();
12752
71991b7a0f14 SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8959
diff changeset
420 }
18990
d1c1cd2530d7 Truffle/Instrumentation: clean up and repair some old unit tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18962
diff changeset
421
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
422 @Override
22049
6dd4ab4d76d3 ecj lints
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22048
diff changeset
423 protected CallTarget parse(Source code, Node node, String... argumentNames) throws IOException {
22046
e7c2d36daf72 TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
424 final SLContext c = new SLContext(this);
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: 22003
diff changeset
425 final Exception[] failed = {null};
21690
e59895e16377 TCK now checks behavior when parsing unparseable code
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21493
diff changeset
426 try {
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: 22003
diff changeset
427 c.evalSource(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: 22003
diff changeset
428 failed[0] = null;
21690
e59895e16377 TCK now checks behavior when parsing unparseable code
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21493
diff changeset
429 } catch (Exception e) {
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: 22003
diff changeset
430 failed[0] = e;
21690
e59895e16377 TCK now checks behavior when parsing unparseable code
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21493
diff changeset
431 }
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: 22003
diff changeset
432 return new CallTarget() {
e7c2d36daf72 TruffleLanguage.parse method to convert a source to CallTarget. Basic caching to make sure the code is shared among tenants in one JVM.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22003
diff changeset
433 @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: 22003
diff changeset
434 public Object call(Object... arguments) {
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: 22003
diff changeset
435 if (failed[0] instanceof RuntimeException) {
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: 22003
diff changeset
436 throw (RuntimeException) failed[0];
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: 22003
diff changeset
437 }
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: 22003
diff changeset
438 if (failed[0] != 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: 22003
diff changeset
439 throw new IllegalStateException(failed[0]);
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: 22003
diff changeset
440 }
22068
fec8f8a61f6c Introducing FindContextNode
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22067
diff changeset
441 Node n = createFindContextNode();
22070
a7ca9e9a1d51 Removing VirtualFrame parameter. Documenting.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22068
diff changeset
442 SLContext fillIn = findContext(n);
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: 22003
diff changeset
443 final SLFunctionRegistry functionRegistry = fillIn.getFunctionRegistry();
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: 22003
diff changeset
444 for (SLFunction f : c.getFunctionRegistry().getFunctions()) {
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: 22003
diff changeset
445 RootCallTarget callTarget = f.getCallTarget();
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: 22003
diff changeset
446 if (callTarget == 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: 22003
diff changeset
447 continue;
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: 22003
diff changeset
448 }
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: 22003
diff changeset
449 functionRegistry.lookup(f.getName());
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: 22003
diff changeset
450 functionRegistry.register(f.getName(), (SLRootNode) f.getCallTarget().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: 22003
diff changeset
451 }
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: 22003
diff changeset
452 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: 22003
diff changeset
453 }
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: 22003
diff changeset
454 };
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
455 }
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
456
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
457 @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: 22065
diff changeset
458 protected Object findExportedSymbol(SLContext context, String globalName, boolean onlyExplicit) {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
459 for (SLFunction f : context.getFunctionRegistry().getFunctions()) {
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
460 if (globalName.equals(f.getName())) {
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
461 return f;
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
462 }
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
463 }
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
464 return null;
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
465 }
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
466
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
467 @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: 22065
diff changeset
468 protected Object getLanguageGlobal(SLContext context) {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
469 return context;
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
470 }
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
471
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
472 @Override
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
473 protected boolean isObjectOfLanguage(Object object) {
21490
3286fb5fea4a Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21481
diff changeset
474 return object instanceof SLFunction;
21468
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
475 }
99942eac9c6d Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 20956
diff changeset
476
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
477 @Override
22214
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
478 protected Visualizer getVisualizer() {
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
479 if (visualizer == null) {
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
480 visualizer = new SLDefaultVisualizer();
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
481 }
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
482 return visualizer;
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
483 }
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
484
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
485 @Override
22215
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
486 protected ASTProber getDefaultASTProber() {
d3bdaa91bc82 Truffle/Instrumentation: method signature on TruffleLanguage for getting each language's "default" ASTProber
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22214
diff changeset
487 return astProber;
22214
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
488 }
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
489
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
490 @SuppressWarnings("deprecation")
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
491 @Override
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
492 protected void enableASTProbing(ASTProber prober) {
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
493 throw new UnsupportedOperationException();
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
494 }
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
495
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
496 @Override
22214
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
497 protected Object evalInContext(Source source, Node node, MaterializedFrame mFrame) throws IOException {
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
498 throw new IllegalStateException("evalInContext not supported in this language");
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
499 }
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
500
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
501 @Override
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
502 protected AdvancedInstrumentRootFactory createAdvancedInstrumentRootFactory(String expr, AdvancedInstrumentResultListener resultListener) throws IOException {
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
503 throw new IllegalStateException("createAdvancedInstrumentRootFactory not supported in this language");
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
504 }
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
505
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
506 @SuppressWarnings("deprecation")
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
507 @Override
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
508 protected ToolSupportProvider getToolSupport() {
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
509 return null;
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
510 }
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
511
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
512 @SuppressWarnings("deprecation")
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
513 @Override
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
514 protected DebugSupportProvider getDebugSupport() {
22214
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
515 return null;
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
516 }
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
517
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
518 public Node createFindContextNode0() {
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
519 return createFindContextNode();
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
520 }
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
521
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
522 public SLContext findContext0(Node contextNode) {
3aad794eec0e Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22126
diff changeset
523 return findContext(contextNode);
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
524 }
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
525
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
526 // TODO (mlvdv) remove the static hack when we no longer have the static demo variables
21686
5fa7935c5de3 Truffle/Instrumentation: fix the small tool demonstration in SL
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21649
diff changeset
527 private static void setupToolDemos() {
22125
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
528 // if (nodeExecCounts) {
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
529 // nodeExecCounter = new NodeExecCounter();
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
530 // nodeExecCounter.install();
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
531 // }
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
532 //
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
533 // if (statementCounts) {
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
534 // statementExecCounter = new NodeExecCounter(StandardSyntaxTag.STATEMENT);
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
535 // statementExecCounter.install();
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
536 // }
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
537 //
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
538 // if (coverage) {
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
539 // coverageTracker = new CoverageTracker();
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
540 // coverageTracker.install();
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
541 // }
21649
1c76a5662753 Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21578
diff changeset
542 }
1c76a5662753 Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21578
diff changeset
543
21686
5fa7935c5de3 Truffle/Instrumentation: fix the small tool demonstration in SL
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21649
diff changeset
544 private static void reportToolDemos() {
22125
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
545 // if (nodeExecCounter != null) {
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
546 // nodeExecCounter.print(System.out);
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
547 // nodeExecCounter.dispose();
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
548 // }
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
549 // if (statementExecCounter != null) {
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
550 // statementExecCounter.print(System.out);
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
551 // statementExecCounter.dispose();
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
552 // }
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
553 // if (coverageTracker != null) {
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
554 // coverageTracker.print(System.out);
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
555 // coverageTracker.dispose();
8d2bdc802002 Fixing the formating the way E. formater likes it
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22124
diff changeset
556 // }
21649
1c76a5662753 Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21578
diff changeset
557 }
1c76a5662753 Merge with 645f170013a451083414ff695412c465e9d2ebf0
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 21578
diff changeset
558
7292
213c1297a814 Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
559 }