public abstract class PolyglotEngine.Value extends Object
PolyglotEngine functions like PolyglotEngine.findGlobalSymbol(String) and
PolyglotEngine.eval(Source) or a value returned by
a subsequent execution. In case the
PolyglotEngine has been initialized for
asynchronous execution, the
PolyglotEngine.Value represents a future - i.e., it is returned immediately, leaving the execution
running on behind.| Modifier and Type | Method and Description |
|---|---|
<T> T |
as(Class<T> representation)
Creates Java-typed foreign access to the object wrapped by this
Value, a
kind of cross-language "cast". |
PolyglotEngine.Value |
execute(Object... args)
Executes this value, depending on its content.
|
Object |
get()
Returns the object represented by this value, possibly null.
|
PolyglotEngine.Value |
getMetaObject()
Get a meta-object of this value, if any.
|
SourceSection |
getSourceLocation()
Get a source location where this value is declared, if any.
|
public Object get()
Number, String,
Character, Boolean) or a TruffleObject representing more complex
object created by a language.nullException - in case it is not possible to obtain the value of the objectpublic <T> T as(Class<T> representation)
Value, a
kind of cross-language "cast". Results depend on the requested type:
Number, the value is simply cast and returned.
String is produced by the language that returned the value.FunctionalInterface instance is returned if the value
can be executed.List and Map are supported, including when
used in combination with nested generics.This method is useful for Java applications that interoperate with guest language code. The general strategy is to evaluate guest language code that produces the desired language element and then use this method to create a Java object of the appropriate type for Java access to the result. The tutorial "Embedding Truffle Languages in Java" contains examples.
T - the type of the requested viewrepresentation - an interface describing the requested access (must be an interface)Exception - in case it is not possible to obtain the value of the objectClassCastException - if the value cannot be converted to desired viewpublic PolyglotEngine.Value execute(Object... args)
This method is useful for Java applications that interoperate with guest language code. The general strategy is to evaluate guest language code that produces the desired language element. If that element is a guest language function, this method allows direct execution without giving the function a Java type. The tutorial "Embedding Truffle Languages in Java" contains examples.
args - arguments to pass when executing the valuePolyglotEngine.ValueException - signals problem during executionpublic PolyglotEngine.Value getMetaObject()
nullpublic SourceSection getSourceLocation()
null