Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java @ 21649:1c76a5662753
Merge with 645f170013a451083414ff695412c465e9d2ebf0
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Mon, 01 Jun 2015 17:47:28 -0700 |
parents | a880844225e4 |
children | 5fa7935c5de3 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java Sun May 31 17:23:14 2015 -0700 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java Mon Jun 01 17:47:28 2015 -0700 @@ -139,6 +139,11 @@ private static List<NodeFactory<? extends SLBuiltinNode>> builtins = Collections.emptyList(); private final SLContext context; + /* Small tools that can be demonstrated */ + NodeExecCounter nodeExecCounter = null; + NodeExecCounter statementExecCounter = null; + CoverageTracker coverageTracker = null; + public SLMain(Env env) { super(env); context = SLContextFactory.create(new BufferedReader(env().stdIn()), new PrintWriter(env().stdOut(), true)); @@ -157,7 +162,10 @@ /** * The main entry point. Use the mx command "mx sl" to run it with the correct class path setup. + * <p> + * Obsolete: being replaced with new TruffleLanguage API */ + @Deprecated public static void main(String[] args) throws IOException { TruffleVM vm = TruffleVM.newVM().build(); assert vm.getLanguages().containsKey("application/x-sl"); @@ -181,6 +189,9 @@ } } + /** + * Temporary method during API evolution, supports debugger integration. + */ public static void run(Source source) throws IOException { TruffleVM vm = TruffleVM.newVM().build(); assert vm.getLanguages().containsKey("application/x-sl"); @@ -204,28 +215,6 @@ // logOutput.println("Source = " + source.getCode()); } - if (statementCounts || coverage) { - Probe.registerASTProber(new SLStandardASTProber()); - } - - NodeExecCounter nodeExecCounter = null; - if (nodeExecCounts) { - nodeExecCounter = new NodeExecCounter(); - nodeExecCounter.install(); - } - - NodeExecCounter statementExecCounter = null; - if (statementCounts) { - statementExecCounter = new NodeExecCounter(StandardSyntaxTag.STATEMENT); - statementExecCounter.install(); - } - - CoverageTracker coverageTracker = null; - if (coverage) { - coverageTracker = new CoverageTracker(); - coverageTracker.install(); - } - /* Parse the SL source file. */ Object result = context.eval(source); if (result != null) { @@ -272,18 +261,6 @@ } finally { printScript("after execution", LAST.context, logOutput, printASTToLog, printSourceAttributionToLog, dumpASTToIGV); } - if (nodeExecCounter != null) { - nodeExecCounter.print(System.out); - nodeExecCounter.dispose(); - } - if (statementExecCounter != null) { - statementExecCounter.print(System.out); - statementExecCounter.dispose(); - } - if (coverageTracker != null) { - coverageTracker.print(System.out); - coverageTracker.dispose(); - } return totalRuntime; } @@ -382,7 +359,10 @@ @Override protected Object eval(Source code) throws IOException { + + setupToolDemos(); context.executeMain(code); + reportToolDemos(); return null; } @@ -406,4 +386,39 @@ return object instanceof SLFunction; } + private void setupToolDemos() { + if (statementCounts || coverage) { + Probe.registerASTProber(new SLStandardASTProber()); + } + if (nodeExecCounts) { + nodeExecCounter = new NodeExecCounter(); + nodeExecCounter.install(); + } + + if (statementCounts) { + statementExecCounter = new NodeExecCounter(StandardSyntaxTag.STATEMENT); + statementExecCounter.install(); + } + + if (coverage) { + coverageTracker = new CoverageTracker(); + coverageTracker.install(); + } + } + + private void reportToolDemos() { + if (nodeExecCounter != null) { + nodeExecCounter.print(System.out); + nodeExecCounter.dispose(); + } + if (statementExecCounter != null) { + statementExecCounter.print(System.out); + statementExecCounter.dispose(); + } + if (coverageTracker != null) { + coverageTracker.print(System.out); + coverageTracker.dispose(); + } + } + }