Mercurial > hg > truffle
diff 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 |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java Wed Sep 16 12:27:08 2015 +0200 +++ b/truffle/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLLanguage.java Wed Sep 16 15:36:22 2015 -0700 @@ -40,11 +40,19 @@ */ package com.oracle.truffle.sl; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.math.BigInteger; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; + import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleLanguage; -import com.oracle.truffle.api.debug.DebugSupportException; import com.oracle.truffle.api.debug.DebugSupportProvider; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; @@ -52,7 +60,6 @@ import com.oracle.truffle.api.instrument.ASTProber; import com.oracle.truffle.api.instrument.AdvancedInstrumentResultListener; import com.oracle.truffle.api.instrument.AdvancedInstrumentRootFactory; -import com.oracle.truffle.api.instrument.Probe; import com.oracle.truffle.api.instrument.ToolSupportProvider; import com.oracle.truffle.api.instrument.Visualizer; import com.oracle.truffle.api.nodes.GraphPrintVisitor; @@ -102,14 +109,6 @@ import com.oracle.truffle.sl.runtime.SLFunction; import com.oracle.truffle.sl.runtime.SLFunctionRegistry; import com.oracle.truffle.sl.runtime.SLNull; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.math.BigInteger; -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; /** * SL is a simple language to demonstrate and showcase features of Truffle. The implementation is as @@ -186,7 +185,7 @@ */ /* - * + * * <p> <b>Tools:</b><br> The use of some of Truffle's support for developer tools (based on the * Truffle Instrumentation Framework) are demonstrated in this file, for example: <ul> <li>a * {@linkplain NodeExecCounter counter for node executions}, tabulated by node type; and</li> <li>a @@ -198,8 +197,7 @@ public final class SLLanguage extends TruffleLanguage<SLContext> { private static List<NodeFactory<? extends SLBuiltinNode>> builtins = Collections.emptyList(); private static Visualizer visualizer = new SLDefaultVisualizer(); - private static ASTProber registeredASTProber; // non-null if prober already registered - private DebugSupportProvider debugSupport; + private ASTProber astProber = new SLStandardASTProber(); private SLLanguage() { } @@ -254,6 +252,7 @@ /** * Temporary method during API evolution, supports debugger integration. */ + @Deprecated public static void run(Source source) throws IOException { TruffleVM vm = TruffleVM.newVM().build(); assert vm.getLanguages().containsKey("application/x-sl"); @@ -476,28 +475,56 @@ } @Override - protected ToolSupportProvider getToolSupport() { - return getDebugSupport(); + protected Visualizer getVisualizer() { + if (visualizer == null) { + visualizer = new SLDefaultVisualizer(); + } + return visualizer; + } + + @Override + protected ASTProber getDefaultASTProber() { + return astProber; + } + + @SuppressWarnings("deprecation") + @Override + protected void enableASTProbing(ASTProber prober) { + throw new UnsupportedOperationException(); } @Override + protected Object evalInContext(Source source, Node node, MaterializedFrame mFrame) throws IOException { + throw new IllegalStateException("evalInContext not supported in this language"); + } + + @Override + protected AdvancedInstrumentRootFactory createAdvancedInstrumentRootFactory(String expr, AdvancedInstrumentResultListener resultListener) throws IOException { + throw new IllegalStateException("createAdvancedInstrumentRootFactory not supported in this language"); + } + + @SuppressWarnings("deprecation") + @Override + protected ToolSupportProvider getToolSupport() { + return null; + } + + @SuppressWarnings("deprecation") + @Override protected DebugSupportProvider getDebugSupport() { - if (debugSupport == null) { - debugSupport = new SLDebugProvider(); - } - return debugSupport; + return null; + } + + public Node createFindContextNode0() { + return createFindContextNode(); + } + + public SLContext findContext0(Node contextNode) { + return findContext(contextNode); } // TODO (mlvdv) remove the static hack when we no longer have the static demo variables private static void setupToolDemos() { - // if (statementCounts || coverage) { - // if (registeredASTProber == null) { - // final ASTProber newProber = new SLStandardASTProber(); - // // This should be registered on the TruffleVM - // Probe.registerASTProber(newProber); - // registeredASTProber = newProber; - // } - // } // if (nodeExecCounts) { // nodeExecCounter = new NodeExecCounter(); // nodeExecCounter.install(); @@ -529,46 +556,4 @@ // } } - public Node createFindContextNode0() { - return createFindContextNode(); - } - - public SLContext findContext0(Node contextNode) { - return findContext(contextNode); - } - - private final class SLDebugProvider implements DebugSupportProvider { - - public SLDebugProvider() { - if (registeredASTProber == null) { - registeredASTProber = new SLStandardASTProber(); - // This should be registered on the TruffleVM - Probe.registerASTProber(registeredASTProber); - } - } - - public Visualizer getVisualizer() { - if (visualizer == null) { - visualizer = new SLDefaultVisualizer(); - } - return visualizer; - } - - public void enableASTProbing(ASTProber prober) { - if (prober != null) { - // This should be registered on the TruffleVM - Probe.registerASTProber(prober); - } - } - - public Object evalInContext(Source source, Node node, MaterializedFrame mFrame) throws DebugSupportException { - throw new DebugSupportException("evalInContext not supported in this language"); - } - - public AdvancedInstrumentRootFactory createAdvancedInstrumentRootFactory(String expr, AdvancedInstrumentResultListener resultListener) throws DebugSupportException { - throw new DebugSupportException("createAdvancedInstrumentRootFactory not supported in this language"); - } - - } - }