Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleLanguage.java @ 22165:67f75f61c974
Certain languages (like FastR) prefer access to raw byte streams. Offering it. One always has an option to wrap Input and Output Streams into character based Readers and Writers
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Mon, 21 Sep 2015 12:36:30 +0200 |
parents | dc83cc1f94f2 |
children | 0bcfe8c6088f 1421041175a7 526de3af756d |
comparison
equal
deleted
inserted
replaced
22164:567d324c306c | 22165:67f75f61c974 |
---|---|
29 import com.oracle.truffle.api.impl.FindContextNode; | 29 import com.oracle.truffle.api.impl.FindContextNode; |
30 import com.oracle.truffle.api.instrument.ToolSupportProvider; | 30 import com.oracle.truffle.api.instrument.ToolSupportProvider; |
31 import com.oracle.truffle.api.nodes.Node; | 31 import com.oracle.truffle.api.nodes.Node; |
32 import com.oracle.truffle.api.source.Source; | 32 import com.oracle.truffle.api.source.Source; |
33 import java.io.IOException; | 33 import java.io.IOException; |
34 import java.io.InputStream; | |
35 import java.io.InputStreamReader; | |
36 import java.io.OutputStream; | |
37 import java.io.OutputStreamWriter; | |
34 import java.io.Reader; | 38 import java.io.Reader; |
35 import java.io.Writer; | 39 import java.io.Writer; |
36 import java.lang.annotation.ElementType; | 40 import java.lang.annotation.ElementType; |
37 import java.lang.annotation.Retention; | 41 import java.lang.annotation.Retention; |
38 import java.lang.annotation.RetentionPolicy; | 42 import java.lang.annotation.RetentionPolicy; |
244 */ | 248 */ |
245 public static final class Env { | 249 public static final class Env { |
246 private final Object vm; | 250 private final Object vm; |
247 private final TruffleLanguage<?> lang; | 251 private final TruffleLanguage<?> lang; |
248 private final LangCtx<?> langCtx; | 252 private final LangCtx<?> langCtx; |
249 private final Reader in; | 253 private final InputStream in; |
250 private final Writer err; | 254 private final OutputStream err; |
251 private final Writer out; | 255 private final OutputStream out; |
252 | 256 |
253 Env(Object vm, TruffleLanguage<?> lang, Writer out, Writer err, Reader in) { | 257 Env(Object vm, TruffleLanguage<?> lang, OutputStream out, OutputStream err, InputStream in) { |
254 this.vm = vm; | 258 this.vm = vm; |
255 this.in = in; | 259 this.in = in; |
256 this.err = err; | 260 this.err = err; |
257 this.out = out; | 261 this.out = out; |
258 this.lang = lang; | 262 this.lang = lang; |
276 * Input associated with {@link com.oracle.truffle.api.vm.TruffleVM} this language is being | 280 * Input associated with {@link com.oracle.truffle.api.vm.TruffleVM} this language is being |
277 * executed in. | 281 * executed in. |
278 * | 282 * |
279 * @return reader, never <code>null</code> | 283 * @return reader, never <code>null</code> |
280 */ | 284 */ |
285 public InputStream in() { | |
286 return in; | |
287 } | |
288 | |
289 @Deprecated | |
281 public Reader stdIn() { | 290 public Reader stdIn() { |
282 return in; | 291 return new InputStreamReader(in); |
283 } | 292 } |
284 | 293 |
285 /** | 294 /** |
286 * Standard output writer for {@link com.oracle.truffle.api.vm.TruffleVM} this language is | 295 * Standard output writer for {@link com.oracle.truffle.api.vm.TruffleVM} this language is |
287 * being executed in. | 296 * being executed in. |
288 * | 297 * |
289 * @return writer, never <code>null</code> | 298 * @return writer, never <code>null</code> |
290 */ | 299 */ |
300 public OutputStream out() { | |
301 return out; | |
302 } | |
303 | |
304 @Deprecated | |
291 public Writer stdOut() { | 305 public Writer stdOut() { |
292 return out; | 306 return new OutputStreamWriter(out); |
293 } | 307 } |
294 | 308 |
295 /** | 309 /** |
296 * Standard error writer for {@link com.oracle.truffle.api.vm.TruffleVM} this language is | 310 * Standard error writer for {@link com.oracle.truffle.api.vm.TruffleVM} this language is |
297 * being executed in. | 311 * being executed in. |
298 * | 312 * |
299 * @return writer, never <code>null</code> | 313 * @return writer, never <code>null</code> |
300 */ | 314 */ |
315 public OutputStream err() { | |
316 return err; | |
317 } | |
318 | |
319 @Deprecated | |
301 public Writer stdErr() { | 320 public Writer stdErr() { |
302 return err; | 321 return new OutputStreamWriter(err); |
303 } | 322 } |
304 } | 323 } |
305 | 324 |
306 private static final AccessAPI API = new AccessAPI(); | 325 private static final AccessAPI API = new AccessAPI(); |
307 | 326 |
308 @SuppressWarnings("rawtypes") | 327 @SuppressWarnings("rawtypes") |
309 private static final class AccessAPI extends Accessor { | 328 private static final class AccessAPI extends Accessor { |
310 @Override | 329 @Override |
311 protected Env attachEnv(Object vm, TruffleLanguage<?> language, Writer stdOut, Writer stdErr, Reader stdIn) { | 330 protected Env attachEnv(Object vm, TruffleLanguage<?> language, OutputStream stdOut, OutputStream stdErr, InputStream stdIn) { |
312 Env env = new Env(vm, language, stdOut, stdErr, stdIn); | 331 Env env = new Env(vm, language, stdOut, stdErr, stdIn); |
313 return env; | 332 return env; |
314 } | 333 } |
315 | 334 |
316 @Override | 335 @Override |