public static interface Insight.SymbolProvider
Insight scripts. All available instruments are
queried for implementation of this interface. If provided, they can contribute symbols with
their values to be available as globals when executing the Insight scripts.
@TruffleInstrument.Registration( id = "meaningOfWorld", name = "Meaning Of World", version = "demo", services = {Insight.SymbolProvider.class } ) public final class MeaningOfWorldInstrument extendsTruffleInstrument{ @Overrideprotected void onCreate(Env env) {Map<String,Integer> symbols =Collections.singletonMap("meaning", 42);Insight.SymbolProvider provider = () -> symbols; env.registerService(provider); } }
The previous instrument makes variable meanining with value 42 available to
every Insight script when properly registered into the virtual machine. A typical
way is to register your custom instrument is to use property
truffle.class.path.append when launching the virtual machine:
graalvm/bin/java -Dtruffle.class.path.append=meaningOfWorld.jar -jar app.jarTake care when writing your
instruments as they can alter many
aspects of program execution and aren't subject to any security sandbox. See
TruffleInstrument for more information about developing, using and registering
instruments.| Modifier and Type | Method and Description |
|---|---|
Map<String,? extends Object> |
symbolsWithValues()
Map with symbol names and their interop values.
|