Interface Insight.SymbolProvider

Enclosing class:
Insight

public static interface Insight.SymbolProvider
Additional provider of symbols for 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.

@Registration(
    id = "meaningOfWorld", name = "Meaning Of World", version = "demo",
    services = { Insight.SymbolProvider.class }
)
public final class MeaningOfWorldInstrument extends TruffleInstrument {
    @Override
    protected 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.jar
 
Take 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.
Since:
21.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Map<String,? extends Object>
    Map with symbol names and their interop values.
  • Method Details

    • symbolsWithValues

      Map<String,? extends Object> symbolsWithValues() throws Exception
      Map with symbol names and their interop values.
      Returns:
      map mapping names to their primitive, String or TruffleObject values
      Throws:
      Exception - any exception is propagated as an internal error
      Since:
      21.0