GeneratorContext#

class GeneratorContext#

GeneratorContext is a class that is used when using Generators (or Stubs) directly; it is used to allow the outer context (typically, either a Generator or “top-level” code) to specify certain information to the inner context to ensure that inner and outer Generators are compiled in a compatible way.

If you are using this at “top level” (e.g. with the JIT), you can construct a GeneratorContext with a Target:

auto my_stub = MyStub(
    GeneratorContext(get_target_from_environment()),
    // inputs
    { ... },
    // generator params
    { ... }
);

Note that all Generators embed a GeneratorContext, so if you are using a Stub from within a Generator, you can just pass ‘context()’ for the GeneratorContext:

struct SomeGen : Generator<SomeGen> {
 void generate() {
   ...
   auto my_stub = MyStub(
     context(),  // GeneratorContext
     // inputs
     { ... },
     // generator params
     { ... }
   );
   ...
 }
};