public static final class TruffleInstrument.Env extends Object
| Modifier and Type | Method and Description |
|---|---|
OutputStream |
err()
Standard error writer for
PolyglotEngine this
instrument is being executed in. |
Object |
findMetaObject(Node node,
Object value)
Find a meta-object of a value, if any.
|
SourceSection |
findSourceLocation(Node node,
Object value)
Find a source location where a value is declared, if any.
|
Instrumenter |
getInstrumenter()
Returns the instrumenter which lets you instrument guest language ASTs.
|
Map<String,InstrumentInfo> |
getInstruments()
Returns a map mime-type to instrument identifier of all instruments that are installed in
the environment.
|
Map<String,LanguageInfo> |
getLanguages()
Returns a map mime-type to language identifier of all languages that are installed in the
environment.
|
InputStream |
in()
Input associated with
PolyglotEngine this
instrument is being executed in. |
boolean |
isEngineRoot(RootNode root)
Returns
true if the given root node is considered an engine evaluation root
for the current execution context. |
<S> S |
lookup(InstrumentInfo instrument,
Class<S> type)
Returns an additional service provided by this instrument, specified by type.
|
<S> S |
lookup(LanguageInfo language,
Class<S> type)
Queries a
language implementation for a special service. |
OutputStream |
out()
Standard output writer for
PolyglotEngine this
instrument is being executed in. |
CallTarget |
parse(Source source,
String... argumentNames)
Evaluates source of (potentially different) language using the current context.The names
of arguments are parameters for the resulting {#link CallTarget} that allow the
source to reference the actual parameters passed to
CallTarget.call(java.lang.Object...). |
void |
registerService(Object service)
Registers additional service.
|
String |
toString(Node node,
Object value)
Uses the original language of the node to print a string representation of this value.
|
public Instrumenter getInstrumenter()
Instrumenterpublic InputStream in()
PolyglotEngine this
instrument is being executed in.nullpublic OutputStream out()
PolyglotEngine this
instrument is being executed in.nullpublic OutputStream err()
PolyglotEngine this
instrument is being executed in.nullpublic void registerService(Object service)
initialization of the instrument. These services are made available to users via
PolyglotRuntime.Instrument.lookup(java.lang.Class<T>) query method.
This method can only be called from
TruffleInstrument.onCreate(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env) method -
then the services are collected and cannot be changed anymore.service - a service to be returned from associated
PolyglotRuntime.Instrument.lookup(java.lang.Class<T>)IllegalStateException - if the method is called later than from
TruffleInstrument.onCreate(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)
methodpublic <S> S lookup(LanguageInfo language, Class<S> type)
language implementation for a special service. The
services can be provided by the language by directly implementing them when subclassing
TruffleLanguage.S - the requested typelanguage - identification of the language to querytype - the class of the requested typenull if none is foundpublic <S> S lookup(InstrumentInfo instrument, Class<S> type)
IllegalArgumentException is thrown if a service is
looked up from the current instrument.S - the requested typeinstrument - identification of the instrument to querytype - the class of the requested typenull if none is foundpublic Map<String,LanguageInfo> getLanguages()
public Map<String,InstrumentInfo> getInstruments()
public CallTarget parse(Source source, String... argumentNames) throws IOException
source to reference the actual parameters passed to
CallTarget.call(java.lang.Object...).source - the source to evaluateargumentNames - the names of CallTarget.call(java.lang.Object...) arguments
that can be referenced from the sourceIOException - if the parsing or evaluation fails for some reasonpublic boolean isEngineRoot(RootNode root)
true if the given root node is considered an engine evaluation root
for the current execution context. Multiple such root nodes can appear on stack frames
returned by
TruffleRuntime.iterateFrames(com.oracle.truffle.api.frame.FrameInstanceVisitor).
A debugger implementation might use this information to hide stack frames of other
engines.root - the root node to checktrue if engine root else falsepublic String toString(Node node, Object value)
node - a nodevalue - a known value of that languagepublic Object findMetaObject(Node node, Object value)
null is returned.node - a nodevalue - a value to find the meta-object ofnullpublic SourceSection findSourceLocation(Node node, Object value)
node - a nodevalue - a value to get the source location fornull