Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java @ 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.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Tue, 26 May 2015 19:11:36 +0200 |
parents | bb51b9a142b3 |
children | 31fc2fce38f3 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java Tue May 26 19:11:36 2015 +0200 @@ -29,6 +29,8 @@ import com.oracle.truffle.api.vm.TruffleVM; import com.oracle.truffle.api.vm.TruffleVM.Language; import java.io.IOException; +import java.io.Reader; +import java.io.Writer; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -135,13 +137,19 @@ public static final class Env { private final TruffleVM vm; private final TruffleLanguage lang; + private final Reader in; + private final Writer err; + private final Writer out; - Env(TruffleVM vm, Constructor<?> langConstructor) { + Env(TruffleVM vm, Constructor<?> langConstructor, Writer out, Writer err, Reader in) { this.vm = vm; + this.in = in; + this.err = err; + this.out = out; try { this.lang = (TruffleLanguage) langConstructor.newInstance(this); } catch (Exception ex) { - throw new IllegalStateException("Cannot construct language " + langConstructor.getClass().getName(), ex); + throw new IllegalStateException("Cannot construct language " + langConstructor.getDeclaringClass().getName(), ex); } } @@ -157,15 +165,41 @@ public Object importSymbol(String globalName) { return API.importSymbol(vm, lang, globalName); } + + /** + * Input associated with this {@link TruffleVM}. + * + * @return reader, never <code>null</code> + */ + public Reader stdIn() { + return in; + } + + /** + * Standard output writer for this {@link TruffleVM}. + * + * @return writer, never <code>null</code> + */ + public Writer stdOut() { + return out; + } + + /** + * Standard error writer for this {@link TruffleVM}. + * + * @return writer, never <code>null</code> + */ + public Writer stdErr() { + return err; + } } private static final AccessAPI API = new AccessAPI(); private static final class AccessAPI extends Accessor { - @Override - protected TruffleLanguage attachEnv(TruffleVM vm, Constructor<?> langClazz) { - Env env = new Env(vm, langClazz); + protected TruffleLanguage attachEnv(TruffleVM vm, Constructor<?> langClazz, Writer stdOut, Writer stdErr, Reader stdIn) { + Env env = new Env(vm, langClazz, stdOut, stdErr, stdIn); return env.lang; }