Mercurial > hg > truffle
diff graal/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLREPLServer.java @ 21890:894f82515e38
Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs
- Add a version string to language registration: Language.getShortName() produces a string with both language and version
- Rename SLMain --> SLLanguage (little change current machinery)
- Remove DebugEngine dependence on ExecutionContext: Visualizer access migrated to TruffleLanguage
- ExecutionContext now has only one method left: getCompilerOptions()
- Rename SourceExecutionProvider to DebugSupportProvider, now supplied by implementing abstract TruffleLanguage.getDebugSupport()
- Revise DebugEngine and its helper classes to work with the new APIs
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 09 Jun 2015 15:20:30 -0700 |
parents | 3b8bbf51d320 |
children | a50fa3266a0a |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLREPLServer.java Fri Jun 05 18:05:13 2015 -0700 +++ b/graal/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLREPLServer.java Tue Jun 09 15:20:30 2015 -0700 @@ -24,20 +24,18 @@ */ package com.oracle.truffle.sl.tools.debug; -import java.io.*; import java.util.*; -import com.oracle.truffle.api.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.instrument.*; import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.api.source.*; +import com.oracle.truffle.api.vm.*; +import com.oracle.truffle.api.vm.TruffleVM.Language; import com.oracle.truffle.tools.debug.engine.*; import com.oracle.truffle.tools.debug.shell.*; import com.oracle.truffle.tools.debug.shell.client.*; import com.oracle.truffle.tools.debug.shell.server.*; -import com.oracle.truffle.sl.factory.*; -import com.oracle.truffle.sl.runtime.*; /** * Instantiation of the "server" side of the "REPL*" debugger for the Simple language. @@ -49,10 +47,11 @@ * @see SimpleREPLClient */ public final class SLREPLServer implements REPLServer { + public static void main(String[] args) { // Cheating for the prototype: start from SL, rather than from the client. final SLREPLServer server = new SLREPLServer(); - final SimpleREPLClient client = new SimpleREPLClient(server.slContext, server); + final SimpleREPLClient client = new SimpleREPLClient(server.language.getShortName(), server); // Cheating for the prototype: allow server access to client for recursive debugging server.setClient(client); @@ -63,7 +62,7 @@ } } - private final SLContext slContext; + private final Language language; private final DebugEngine slDebugEngine; private final String statusPrefix; private final Map<String, REPLHandler> handlerMap = new HashMap<>(); @@ -99,13 +98,14 @@ add(REPLHandler.TRUFFLE_HANDLER); add(REPLHandler.TRUFFLE_NODE_HANDLER); - // Set up an SL context - this.slContext = SLContextFactory.create(null, new PrintWriter(System.out)); + TruffleVM vm = TruffleVM.newVM().build(); + this.language = vm.getLanguages().get("application/x-sl"); + assert language != null; - final SLSourceExecutionProvider slSourceExecution = new SLSourceExecutionProvider(slContext); - final SLREPLDebugClient slDebugClient = new SLREPLDebugClient(this.slContext); - this.slDebugEngine = DebugEngine.create(slDebugClient, slSourceExecution); - this.statusPrefix = slContext.getLanguageShortName() + " REPL:"; + final SLREPLDebugClient slDebugClient = new SLREPLDebugClient(language); + this.slDebugEngine = DebugEngine.create(slDebugClient, language); + + this.statusPrefix = language.getShortName() + " REPL:"; } private void setClient(SimpleREPLClient replClient) { @@ -119,7 +119,7 @@ // SL doesn't load modules (like other languages), so we just return a success final REPLMessage reply = new REPLMessage(); reply.put(REPLMessage.STATUS, REPLMessage.SUCCEEDED); - reply.put(REPLMessage.DISPLAY_MSG, slContext.getLanguageShortName() + " started"); + reply.put(REPLMessage.DISPLAY_MSG, language.getShortName() + " started"); return reply; } @@ -163,8 +163,8 @@ } @Override - public SLContext getLanguageContext() { - return slContext; + public Language getLanguage() { + return language; } @Override @@ -186,10 +186,10 @@ */ private final class SLREPLDebugClient implements DebugClient { - private final SLContext slContext; + private final Language language; - SLREPLDebugClient(SLContext slContext) { - this.slContext = slContext; + SLREPLDebugClient(Language language) { + this.language = language; } public void haltedAt(Node node, MaterializedFrame mFrame, List<String> warnings) { @@ -225,8 +225,8 @@ } } - public ExecutionContext getExecutionContext() { - return slContext; + public Language getLanguage() { + return language; } }