Class TruffleLanguage.ParsingRequest

java.lang.Object
com.oracle.truffle.api.TruffleLanguage.ParsingRequest
Enclosing class:
TruffleLanguage<C>

public static final class TruffleLanguage.ParsingRequest extends Object
Request for parsing. Contains information of what to parse and in which context.
Since:
0.22
  • Method Details

    • getSource

      public Source getSource()
      The source code to parse.
      Returns:
      the source code, never null
      Since:
      0.22
    • getOptionValues

      public OptionValues getOptionValues()
      Returns the source option values associated with the parsing request's source and language. This method should be preferred over TruffleLanguage.Env.getOptions(Source) when accessing the source options of a source when possible.

      In order to allow users of the language to specify source options they must be declared by implementing TruffleLanguage.getSourceOptionDescriptors().

      Since:
      25.0
    • getArgumentNames

      public List<String> getArgumentNames()
      Argument names. The result of parsing is an instance of CallTarget that can be invoked without or with some parameters. If the invocation requires some arguments, and the getSource() references them, it is essential to name them. Example that uses the argument names:
      public void parseWithParams(Env env) {
          Source multiply = Source.newBuilder("js",
                          "a * b",
                          "mul.js").build();
          CallTarget method = env.parsePublic(multiply, "a", "b");
          Number fortyTwo = (Number) method.call(6, 7);
          assert 42 == fortyTwo.intValue();
          Number ten = (Number) method.call(2, 5);
          assert 10 == ten.intValue();
      }
      
      Returns:
      symbolic names for parameters of CallTarget.call(java.lang.Object...)
      Since:
      0.22