# HG changeset patch # User Christian Humer # Date 1409594898 -7200 # Node ID e9c1199271992932df90539fa98b42aab62d96d0 # Parent 112ab4a3de3aa51883207e80032a39945d540137 SL: added internal APIs to SL for the Graal runtime tests. diff -r 112ab4a3de3a -r e9c119927199 graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java --- a/graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java Mon Sep 01 20:08:18 2014 +0200 +++ b/graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java Mon Sep 01 20:08:18 2014 +0200 @@ -36,14 +36,16 @@ import org.junit.runners.*; import org.junit.runners.model.*; +import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.source.*; import com.oracle.truffle.sl.*; +import com.oracle.truffle.sl.builtins.*; import com.oracle.truffle.sl.runtime.*; import com.oracle.truffle.sl.test.SLTestRunner.TestCase; public final class SLTestRunner extends ParentRunner { - private static final int REPEATS = 10; + private static int repeats = 10; private static final String SOURCE_SUFFIX = ".sl"; private static final String INPUT_SUFFIX = ".input"; @@ -147,6 +149,16 @@ return outFile.toString(); } + public static void setRepeats(int repeats) { + SLTestRunner.repeats = repeats; + } + + private static final List> builtins = new ArrayList<>(); + + public static void installBuiltin(NodeFactory builtin) { + builtins.add(builtin); + } + @Override protected void runChild(TestCase testCase, RunNotifier notifier) { notifier.fireTestStarted(testCase.name); @@ -154,12 +166,15 @@ ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream printer = new PrintStream(out); try { - SLContext context = new SLContext(new BufferedReader(new StringReader(repeat(testCase.testInput, REPEATS))), printer); + SLContext context = new SLContext(new BufferedReader(new StringReader(repeat(testCase.testInput, repeats))), printer); + for (NodeFactory builtin : builtins) { + context.installBuiltin(builtin); + } final Source source = Source.fromText(readAllLines(testCase.path), testCase.sourceName); - SLMain.run(context, source, null, REPEATS); + SLMain.run(context, source, null, repeats); String actualOutput = new String(out.toByteArray()); - Assert.assertEquals(repeat(testCase.expectedOutput, REPEATS), actualOutput); + Assert.assertEquals(repeat(testCase.expectedOutput, repeats), actualOutput); } catch (Throwable ex) { notifier.fireTestFailure(new Failure(testCase.name, ex)); } finally { diff -r 112ab4a3de3a -r e9c119927199 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java Mon Sep 01 20:08:18 2014 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java Mon Sep 01 20:08:18 2014 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.truffle.sl.nodes; +import com.oracle.truffle.api.CompilerDirectives.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.sl.builtins.*; @@ -53,6 +54,8 @@ /** The Simple execution context for this tree **/ private final SLContext context; + @CompilationFinal private boolean isSplittable; + public SLRootNode(SLContext context, FrameDescriptor frameDescriptor, SLExpressionNode bodyNode, String name) { super(null, frameDescriptor); /* Deep copy the body before any specialization occurs during execution. */ @@ -71,9 +74,17 @@ return name; } + public void setSplittable(boolean isSplittable) { + this.isSplittable = isSplittable; + } + + public SLExpressionNode getBodyNode() { + return bodyNode; + } + @Override public boolean isSplittable() { - return true; + return isSplittable; } @Override