comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/vm/TruffleVM.java @ 22122:ac017ff52c07

Javadoc fixes and less of incompatible changes by keeping returned value Object for those who use the old, deprecated, eval methods
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 02 Sep 2015 10:54:29 +0200
parents d045a505c2b3
children 329fe954f6f2
comparison
equal deleted inserted replaced
22121:d045a505c2b3 22122:ac017ff52c07
267 } 267 }
268 268
269 /** 269 /**
270 * Provides own executor for running {@link TruffleVM} scripts. By default 270 * Provides own executor for running {@link TruffleVM} scripts. By default
271 * {@link TruffleVM#eval(com.oracle.truffle.api.source.Source)} and 271 * {@link TruffleVM#eval(com.oracle.truffle.api.source.Source)} and
272 * {@link Symbol#invoke(java.lang.Object, java.lang.Object...) are executed synchronously in 272 * {@link Symbol#invoke(java.lang.Object, java.lang.Object...)} are executed synchronously
273 * the calling thread. Sometimes, however it is more beneficial to run them asynchronously - 273 * in the calling thread. Sometimes, however it is more beneficial to run them
274 * the easiest way to do so is to provide own executor when configuring the { 274 * asynchronously - the easiest way to do so is to provide own executor when configuring the
275 * @link #executor(java.util.concurrent.Executor) the builder}. The executor is expected to 275 * { {@link #executor(java.util.concurrent.Executor) the builder}. The executor is expected
276 * execute all {@link Runnable runnables} passed into its 276 * to execute all {@link Runnable runnables} passed into its
277 * {@link Executor#execute(java.lang.Runnable)} method in the order they arrive and in a 277 * {@link Executor#execute(java.lang.Runnable)} method in the order they arrive and in a
278 * single (yet arbitrary) thread. 278 * single (yet arbitrary) thread.
279 * 279 *
280 * @param executor the executor to use for internal execution inside the {@link #build() to 280 * @param executor the executor to use for internal execution inside the {@link #build() to
281 * be created} {@link TruffleVM} 281 * be created} {@link TruffleVM}
282 * @return instance of this builder 282 * @return instance of this builder
283 */ 283 */
284 @SuppressWarnings("hiding")
284 public Builder executor(Executor executor) { 285 public Builder executor(Executor executor) {
285 this.executor = executor; 286 this.executor = executor;
286 return this; 287 return this;
287 } 288 }
288 289
332 * @throws IOException exception to signal I/O problems or problems with processing the file's 333 * @throws IOException exception to signal I/O problems or problems with processing the file's
333 * content 334 * content
334 * @deprecated use {@link #eval(com.oracle.truffle.api.source.Source)} 335 * @deprecated use {@link #eval(com.oracle.truffle.api.source.Source)}
335 */ 336 */
336 @Deprecated 337 @Deprecated
337 public Symbol eval(URI location) throws IOException { 338 public Object eval(URI location) throws IOException {
338 checkThread(); 339 checkThread();
339 Source s; 340 Source s;
340 String mimeType; 341 String mimeType;
341 if (location.getScheme().equals("file")) { 342 if (location.getScheme().equals("file")) {
342 File file = new File(location); 343 File file = new File(location);
358 } 359 }
359 Language l = langs.get(mimeType); 360 Language l = langs.get(mimeType);
360 if (l == null) { 361 if (l == null) {
361 throw new IOException("No language for " + location + " with MIME type " + mimeType + " found. Supported types: " + langs.keySet()); 362 throw new IOException("No language for " + location + " with MIME type " + mimeType + " found. Supported types: " + langs.keySet());
362 } 363 }
363 return eval(l, s); 364 return eval(l, s).get();
364 } 365 }
365 366
366 /** 367 /**
367 * Evaluates code snippet. Chooses a language registered for a given MIME type (throws 368 * Evaluates code snippet. Chooses a language registered for a given MIME type (throws
368 * {@link IOException} if there is none). And passes the specified code to it for execution. 369 * {@link IOException} if there is none). And passes the specified code to it for execution.
372 * @return result of an execution, possibly <code>null</code> 373 * @return result of an execution, possibly <code>null</code>
373 * @throws IOException thrown to signal errors while processing the code 374 * @throws IOException thrown to signal errors while processing the code
374 * @deprecated use {@link #eval(com.oracle.truffle.api.source.Source)} 375 * @deprecated use {@link #eval(com.oracle.truffle.api.source.Source)}
375 */ 376 */
376 @Deprecated 377 @Deprecated
377 public Symbol eval(String mimeType, Reader reader) throws IOException { 378 public Object eval(String mimeType, Reader reader) throws IOException {
378 checkThread(); 379 checkThread();
379 Language l = langs.get(mimeType); 380 Language l = langs.get(mimeType);
380 if (l == null) { 381 if (l == null) {
381 throw new IOException("No language for MIME type " + mimeType + " found. Supported types: " + langs.keySet()); 382 throw new IOException("No language for MIME type " + mimeType + " found. Supported types: " + langs.keySet());
382 } 383 }
383 return eval(l, Source.fromReader(reader, mimeType)); 384 return eval(l, Source.fromReader(reader, mimeType)).get();
384 } 385 }
385 386
386 /** 387 /**
387 * Evaluates code snippet. Chooses a language registered for a given MIME type (throws 388 * Evaluates code snippet. Chooses a language registered for a given MIME type (throws
388 * {@link IOException} if there is none). And passes the specified code to it for execution. 389 * {@link IOException} if there is none). And passes the specified code to it for execution.
392 * @return result of an execution, possibly <code>null</code> 393 * @return result of an execution, possibly <code>null</code>
393 * @throws IOException thrown to signal errors while processing the code 394 * @throws IOException thrown to signal errors while processing the code
394 * @deprecated use {@link #eval(com.oracle.truffle.api.source.Source)} 395 * @deprecated use {@link #eval(com.oracle.truffle.api.source.Source)}
395 */ 396 */
396 @Deprecated 397 @Deprecated
397 public Symbol eval(String mimeType, String code) throws IOException { 398 public Object eval(String mimeType, String code) throws IOException {
398 checkThread(); 399 checkThread();
399 Language l = langs.get(mimeType); 400 Language l = langs.get(mimeType);
400 if (l == null) { 401 if (l == null) {
401 throw new IOException("No language for MIME type " + mimeType + " found. Supported types: " + langs.keySet()); 402 throw new IOException("No language for MIME type " + mimeType + " found. Supported types: " + langs.keySet());
402 } 403 }
403 return eval(l, Source.fromText(code, mimeType)); 404 return eval(l, Source.fromText(code, mimeType)).get();
404 } 405 }
405 406
406 /** 407 /**
407 * Evaluates provided source. Chooses language registered for a particular 408 * Evaluates provided source. Chooses language registered for a particular
408 * {@link Source#getMimeType() MIME type} (throws {@link IOException} if there is none). The 409 * {@link Source#getMimeType() MIME type} (throws {@link IOException} if there is none). The
409 * language is then allowed to parse and execute the source. 410 * language is then allowed to parse and execute the source.
410 * 411 *
411 * @param source code snippet to execute 412 * @param source code snippet to execute
412 * @return result of an execution, possibly <code>null</code> 413 * @return a {@link Symbol} object that holds result of an execution, never <code>null</code>
413 * @throws IOException thrown to signal errors while processing the code 414 * @throws IOException thrown to signal errors while processing the code
414 */ 415 */
415 public Symbol eval(Source source) throws IOException { 416 public Symbol eval(Source source) throws IOException {
416 String mimeType = source.getMimeType(); 417 String mimeType = source.getMimeType();
417 checkThread(); 418 checkThread();
599 * field when the <code>invoke</code> method returns. 600 * field when the <code>invoke</code> method returns.
600 * 601 *
601 * @param thiz this/self in language that support such concept; use <code>null</code> to let 602 * @param thiz this/self in language that support such concept; use <code>null</code> to let
602 * the language use default this/self or ignore the value 603 * the language use default this/self or ignore the value
603 * @param args arguments to pass when invoking the symbol 604 * @param args arguments to pass when invoking the symbol
604 * @return the value returned by invoking the symbol 605 * @return symbol wrapper around the value returned by invoking the symbol, never
606 * <code>null</code>
605 * @throws IOException signals problem during execution 607 * @throws IOException signals problem during execution
606 */ 608 */
607 public Symbol invoke(final Object thiz, final Object... args) throws IOException { 609 public Symbol invoke(final Object thiz, final Object... args) throws IOException {
608 get(); 610 get();
609 final Debugger[] fillIn = {debugger}; 611 final Debugger[] fillIn = {debugger};